Commit 58d17e70 authored by Michael Natterer's avatar Michael Natterer 😴

app: add Image -> Color Management -> Color Management Enabled

To enable/disable color management for the image.
parent e69bb901
...@@ -173,6 +173,16 @@ static const GimpActionEntry image_actions[] = ...@@ -173,6 +173,16 @@ static const GimpActionEntry image_actions[] =
GIMP_HELP_IMAGE_PROPERTIES } GIMP_HELP_IMAGE_PROPERTIES }
}; };
static const GimpToggleActionEntry image_toggle_actions[] =
{
{ "image-color-management-enabled", NULL,
NC_("image-action", "_Enable Color Management"), NULL,
NC_("image-action", "Whether the image is color managed"),
G_CALLBACK (image_color_management_enabled_cmd_callback),
TRUE,
GIMP_HELP_IMAGE_COLOR_MANAGEMENT_ENABLED }
};
static const GimpRadioActionEntry image_convert_base_type_actions[] = static const GimpRadioActionEntry image_convert_base_type_actions[] =
{ {
{ "image-convert-rgb", GIMP_STOCK_CONVERT_RGB, { "image-convert-rgb", GIMP_STOCK_CONVERT_RGB,
...@@ -289,6 +299,10 @@ image_actions_setup (GimpActionGroup *group) ...@@ -289,6 +299,10 @@ image_actions_setup (GimpActionGroup *group)
image_actions, image_actions,
G_N_ELEMENTS (image_actions)); G_N_ELEMENTS (image_actions));
gimp_action_group_add_toggle_actions (group, "image-action",
image_toggle_actions,
G_N_ELEMENTS (image_toggle_actions));
gimp_action_group_add_radio_actions (group, "image-convert-action", gimp_action_group_add_radio_actions (group, "image-convert-action",
image_convert_base_type_actions, image_convert_base_type_actions,
G_N_ELEMENTS (image_convert_base_type_actions), G_N_ELEMENTS (image_convert_base_type_actions),
...@@ -331,14 +345,15 @@ void ...@@ -331,14 +345,15 @@ void
image_actions_update (GimpActionGroup *group, image_actions_update (GimpActionGroup *group,
gpointer data) gpointer data)
{ {
GimpImage *image = action_data_get_image (data); GimpImage *image = action_data_get_image (data);
gboolean is_indexed = FALSE; gboolean is_indexed = FALSE;
gboolean is_u8_gamma = FALSE; gboolean is_u8_gamma = FALSE;
gboolean aux = FALSE; gboolean aux = FALSE;
gboolean lp = FALSE; gboolean lp = FALSE;
gboolean sel = FALSE; gboolean sel = FALSE;
gboolean groups = FALSE; gboolean groups = FALSE;
gboolean profile = FALSE; gboolean color_managed = FALSE;
gboolean profile = FALSE;
if (image) if (image)
{ {
...@@ -393,13 +408,16 @@ image_actions_update (GimpActionGroup *group, ...@@ -393,13 +408,16 @@ image_actions_update (GimpActionGroup *group,
groups = ! gimp_item_stack_is_flat (GIMP_ITEM_STACK (layers)); groups = ! gimp_item_stack_is_flat (GIMP_ITEM_STACK (layers));
profile = (gimp_image_get_color_profile (image) != NULL); color_managed = gimp_image_get_is_color_managed (image);
profile = (gimp_image_get_color_profile (image) != NULL);
} }
#define SET_LABEL(action,label) \ #define SET_LABEL(action,label) \
gimp_action_group_set_action_label (group, action, (label)) gimp_action_group_set_action_label (group, action, (label))
#define SET_SENSITIVE(action,condition) \ #define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0) gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
if (profile) if (profile)
{ {
...@@ -430,6 +448,9 @@ image_actions_update (GimpActionGroup *group, ...@@ -430,6 +448,9 @@ image_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("image-convert-gamma", image); SET_SENSITIVE ("image-convert-gamma", image);
SET_SENSITIVE ("image-convert-linear", image && !is_indexed); SET_SENSITIVE ("image-convert-linear", image && !is_indexed);
SET_SENSITIVE ("image-color-management-enabled", image);
SET_ACTIVE ("image-color-management-enabled", image && color_managed);
SET_SENSITIVE ("image-color-profile-assign", image); SET_SENSITIVE ("image-color-profile-assign", image);
SET_SENSITIVE ("image-color-profile-convert", image); SET_SENSITIVE ("image-color-profile-convert", image);
SET_SENSITIVE ("image-color-profile-discard", image && profile); SET_SENSITIVE ("image-color-profile-discard", image && profile);
...@@ -456,4 +477,5 @@ image_actions_update (GimpActionGroup *group, ...@@ -456,4 +477,5 @@ image_actions_update (GimpActionGroup *group,
#undef SET_LABEL #undef SET_LABEL
#undef SET_SENSITIVE #undef SET_SENSITIVE
#undef SET_ACTIVE
} }
...@@ -326,6 +326,23 @@ image_convert_gamma_cmd_callback (GtkAction *action, ...@@ -326,6 +326,23 @@ image_convert_gamma_cmd_callback (GtkAction *action,
gimp_image_flush (image); gimp_image_flush (image);
} }
void
image_color_management_enabled_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
gboolean enabled;
return_if_no_image (image, data);
enabled = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (enabled != gimp_image_get_is_color_managed (image))
{
gimp_image_set_is_color_managed (image, enabled, TRUE);
gimp_image_flush (image);
}
}
static void static void
image_profile_assign_dialog_unset (GimpImage *image) image_profile_assign_dialog_unset (GimpImage *image)
{ {
......
...@@ -19,61 +19,63 @@ ...@@ -19,61 +19,63 @@
#define __IMAGE_COMMANDS_H__ #define __IMAGE_COMMANDS_H__
void image_new_cmd_callback (GtkAction *action, void image_new_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_convert_base_type_cmd_callback (GtkAction *action, void image_convert_base_type_cmd_callback (GtkAction *action,
GtkAction *current, GtkAction *current,
gpointer data); gpointer data);
void image_convert_precision_cmd_callback (GtkAction *action, void image_convert_precision_cmd_callback (GtkAction *action,
GtkAction *current, GtkAction *current,
gpointer data); gpointer data);
void image_convert_gamma_cmd_callback (GtkAction *action, void image_convert_gamma_cmd_callback (GtkAction *action,
GtkAction *current, GtkAction *current,
gpointer data); gpointer data);
void image_color_profile_assign_cmd_callback (GtkAction *action, void image_color_management_enabled_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_color_profile_convert_cmd_callback (GtkAction *action, void image_color_profile_assign_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_color_profile_discard_cmd_callback (GtkAction *action, void image_color_profile_convert_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_color_profile_save_cmd_callback (GtkAction *action, void image_color_profile_discard_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_color_profile_save_cmd_callback (GtkAction *action,
gpointer data);
void image_resize_cmd_callback (GtkAction *action, void image_resize_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_resize_to_layers_cmd_callback (GtkAction *action, void image_resize_to_layers_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_resize_to_selection_cmd_callback (GtkAction *action, void image_resize_to_selection_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_print_size_cmd_callback (GtkAction *action, void image_print_size_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_scale_cmd_callback (GtkAction *action, void image_scale_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_flip_cmd_callback (GtkAction *action, void image_flip_cmd_callback (GtkAction *action,
gint value, gint value,
gpointer data); gpointer data);
void image_rotate_cmd_callback (GtkAction *action, void image_rotate_cmd_callback (GtkAction *action,
gint value, gint value,
gpointer data); gpointer data);
void image_crop_to_selection_cmd_callback (GtkAction *action, void image_crop_to_selection_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_crop_to_content_cmd_callback (GtkAction *action, void image_crop_to_content_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_duplicate_cmd_callback (GtkAction *action, void image_duplicate_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_merge_layers_cmd_callback (GtkAction *action, void image_merge_layers_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_flatten_image_cmd_callback (GtkAction *action, void image_flatten_image_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_configure_grid_cmd_callback (GtkAction *action, void image_configure_grid_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void image_properties_cmd_callback (GtkAction *action, void image_properties_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
#endif /* __IMAGE_COMMANDS_H__ */ #endif /* __IMAGE_COMMANDS_H__ */
...@@ -152,6 +152,7 @@ ...@@ -152,6 +152,7 @@
#define GIMP_HELP_IMAGE_DUPLICATE "gimp-image-duplicate" #define GIMP_HELP_IMAGE_DUPLICATE "gimp-image-duplicate"
#define GIMP_HELP_IMAGE_MERGE_LAYERS "gimp-image-merge-layers" #define GIMP_HELP_IMAGE_MERGE_LAYERS "gimp-image-merge-layers"
#define GIMP_HELP_IMAGE_FLATTEN "gimp-image-flatten" #define GIMP_HELP_IMAGE_FLATTEN "gimp-image-flatten"
#define GIMP_HELP_IMAGE_COLOR_MANAGEMENT_ENABLED "gimp-image-color-management-enabled"
#define GIMP_HELP_IMAGE_COLOR_PROFILE_ASSIGN "gimp-image-color-profile-assign" #define GIMP_HELP_IMAGE_COLOR_PROFILE_ASSIGN "gimp-image-color-profile-assign"
#define GIMP_HELP_IMAGE_COLOR_PROFILE_CONVERT "gimp-image-color-profile-convert" #define GIMP_HELP_IMAGE_COLOR_PROFILE_CONVERT "gimp-image-color-profile-convert"
#define GIMP_HELP_IMAGE_COLOR_PROFILE_DISCARD "gimp-image-color-profile-discard" #define GIMP_HELP_IMAGE_COLOR_PROFILE_DISCARD "gimp-image-color-profile-discard"
......
...@@ -352,6 +352,8 @@ ...@@ -352,6 +352,8 @@
<separator /> <separator />
</menu> </menu>
<menu action="image-color-management-menu" name="Color Management"> <menu action="image-color-management-menu" name="Color Management">
<menuitem action="image-color-management-enabled" />
<separator />
<menuitem action="image-color-profile-assign" /> <menuitem action="image-color-profile-assign" />
<menuitem action="image-color-profile-convert" /> <menuitem action="image-color-profile-convert" />
<menuitem action="image-color-profile-discard" /> <menuitem action="image-color-profile-discard" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment