Mercurial > geeqie.yaz
changeset 1547:2a3efbdf73b0
moved color profiles from statusbar to View menu
author | nadvornik |
---|---|
date | Mon, 13 Apr 2009 08:09:56 +0000 |
parents | 66ee3bfce17c |
children | b5608391f479 0434f34b1ee4 |
files | src/layout.c src/layout_image.c src/layout_util.c src/typedefs.h |
diffstat | 4 files changed, 248 insertions(+), 184 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout.c Sun Apr 12 17:58:55 2009 +0000 +++ b/src/layout.c Mon Apr 13 08:09:56 2009 +0000 @@ -391,177 +391,7 @@ return button; } -/* - *----------------------------------------------------------------------------- - * color profile button (and menu) - *----------------------------------------------------------------------------- - */ - -#ifdef HAVE_LCMS - -static void layout_color_menu_enable_cb(GtkWidget *widget, gpointer data) -{ - LayoutWindow *lw = data; - - layout_image_color_profile_set_use(lw, (!layout_image_color_profile_get_use(lw))); - layout_image_refresh(lw); -} - -static void layout_color_menu_use_image_cb(GtkWidget *widget, gpointer data) -{ - LayoutWindow *lw = data; - gint input, screen; - gboolean use_image; - - if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; - layout_image_color_profile_set(lw, input, screen, !use_image); - layout_image_refresh(lw); -} - -#define COLOR_MENU_KEY "color_menu_key" - -static void layout_color_menu_input_cb(GtkWidget *widget, gpointer data) -{ - LayoutWindow *lw = data; - gint type; - gint input, screen; - gboolean use_image; - - if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; - - type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY)); - if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return; - - if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; - if (type == input) return; - - layout_image_color_profile_set(lw, type, screen, use_image); - layout_image_refresh(lw); -} - -static void layout_color_menu_screen_cb(GtkWidget *widget, gpointer data) -{ - LayoutWindow *lw = data; - gint type; - gint input, screen; - gboolean use_image; - - if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; - - type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), COLOR_MENU_KEY)); - if (type < 0 || type > 1) return; - - if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; - if (type == screen) return; - - layout_image_color_profile_set(lw, input, type, use_image); - layout_image_refresh(lw); -} - -static gchar *layout_color_name_parse(const gchar *name) -{ - if (!name || !*name) return g_strdup(_("Empty")); - return g_strdelimit(g_strdup(name), "_", '-'); -} - -#endif /* HAVE_LCMS */ - -static void layout_color_button_press_cb(GtkWidget *widget, gpointer data) -{ -#ifndef HAVE_LCMS - gchar *msg = g_strdup_printf(_("This installation of %s was not built with support for color profiles."), GQ_APPNAME); - file_util_warning_dialog(_("Color profiles not supported"), - msg, - GTK_STOCK_DIALOG_INFO, widget); - g_free(msg); - return; -#else - LayoutWindow *lw = data; - GtkWidget *menu; - GtkWidget *item; - gchar *buf; - gboolean active; - gint input = 0; - gint screen = 0; - gboolean use_image = FALSE; - gboolean from_image; - gint image_profile; - gint i; - - if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; - - image_profile = layout_image_color_profile_get_from_image(lw); - from_image = use_image && (image_profile != COLOR_PROFILE_NONE); - menu = popup_menu_short_lived(); - - active = layout_image_color_profile_get_use(lw); - menu_item_add_check(menu, _("Use _color profiles"), active, - G_CALLBACK(layout_color_menu_enable_cb), lw); - - menu_item_add_divider(menu); - - item = menu_item_add_check(menu, _("Use profile from _image"), use_image, - G_CALLBACK(layout_color_menu_use_image_cb), lw); - gtk_widget_set_sensitive(item, image_profile == COLOR_PROFILE_MEM || (image_profile > COLOR_PROFILE_NONE && image_profile < COLOR_PROFILE_FILE)); - - for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) - { - const gchar *label; - - switch (i) - { - case COLOR_PROFILE_SRGB: label = _("sRGB"); break; - case COLOR_PROFILE_ADOBERGB: label = _("AdobeRGB compatible"); break; - default: label = "fixme"; break; - } - buf = g_strdup_printf(_("Input _%d: %s%s"), i, label, (i == image_profile) ? " *" : ""); - item = menu_item_add_radio(menu, (i == COLOR_PROFILE_SRGB) ? NULL : item, - buf, (input == i), - G_CALLBACK(layout_color_menu_input_cb), lw); - g_free(buf); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i)); - gtk_widget_set_sensitive(item, active && !from_image); - } - - for (i = 0; i < COLOR_PROFILE_INPUTS; i++) - { - const gchar *name = options->color_profile.input_name[i]; - const gchar *file = options->color_profile.input_file[i]; - gchar *end; - - if (!name || !name[0]) name = filename_from_path(file); - - end = layout_color_name_parse(name); - buf = g_strdup_printf(_("Input _%d: %s"), i + COLOR_PROFILE_FILE, end); - g_free(end); - - item = menu_item_add_radio(menu, item, - buf, (i + COLOR_PROFILE_FILE == input), - G_CALLBACK(layout_color_menu_input_cb), lw); - g_free(buf); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE)); - gtk_widget_set_sensitive(item, active && !from_image && is_readable_file(file)); - } - - menu_item_add_divider(menu); - - item = menu_item_add_radio(menu, NULL, - _("Screen sRGB"), (screen == 0), - G_CALLBACK(layout_color_menu_screen_cb), lw); - - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0)); - gtk_widget_set_sensitive(item, active); - - item = menu_item_add_radio(menu, item, - _("_Screen profile"), (screen == 1), - G_CALLBACK(layout_color_menu_screen_cb), lw); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1)); - gtk_widget_set_sensitive(item, active && is_readable_file(options->color_profile.screen_file)); - - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); -#endif /* HAVE_LCMS */ -} - +#if 0 static GtkWidget *layout_color_button(LayoutWindow *lw) { GtkWidget *button; @@ -585,7 +415,7 @@ return button; } - +#endif /* *----------------------------------------------------------------------------- * write button @@ -849,13 +679,9 @@ gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0); gtk_widget_show(lw->info_sort); - lw->info_color = layout_color_button(lw); - gtk_widget_show(lw->info_color); - lw->info_write = layout_write_button(lw); gtk_widget_show(lw->info_write); - if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format)); @@ -871,7 +697,6 @@ hbox = lw->info_box; } lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE); - if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); lw->info_pixel = layout_status_label(NULL, hbox, FALSE, PIXEL_LABEL_WIDTH, TRUE); if (lw->options.info_pixel_hidden) gtk_widget_hide(gtk_widget_get_parent(lw->info_pixel)); @@ -1803,7 +1628,6 @@ lw->info_box = NULL; lw->info_progress_bar = NULL; lw->info_sort = NULL; - lw->info_color = NULL; lw->info_status = NULL; lw->info_details = NULL; lw->info_pixel = NULL;
--- a/src/layout_image.c Sun Apr 12 17:58:55 2009 +0000 +++ b/src/layout_image.c Mon Apr 13 08:09:56 2009 +0000 @@ -1082,13 +1082,13 @@ image_color_profile_set_use(lw->image, enable); - if (lw->info_color) - { +// if (lw->info_color) +// { #ifndef HAVE_LCMS - enable = FALSE; +// enable = FALSE; #endif - gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, enable); - } +// gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, enable); +// } } gboolean layout_image_color_profile_get_use(LayoutWindow *lw)
--- a/src/layout_util.c Sun Apr 12 17:58:55 2009 +0000 +++ b/src/layout_util.c Mon Apr 13 08:09:56 2009 +0000 @@ -21,6 +21,7 @@ #include "collect.h" #include "collect-dlg.h" #include "compat.h" +#include "color-man.h" #include "dupe.h" #include "editors.h" #include "filedata.h" @@ -53,6 +54,7 @@ static gboolean layout_bar_enabled(LayoutWindow *lw); static gboolean layout_bar_sort_enabled(LayoutWindow *lw); +static void layout_util_sync_color(LayoutWindow *lw); /* *----------------------------------------------------------------------------- @@ -1035,6 +1037,163 @@ #endif + +/* + *----------------------------------------------------------------------------- + * color profile button (and menu) + *----------------------------------------------------------------------------- + */ + +static void layout_color_menu_enable_cb(GtkToggleAction *action, gpointer data) +{ +#ifdef HAVE_LCMS + LayoutWindow *lw = data; + + layout_image_color_profile_set_use(lw, gtk_toggle_action_get_active(action)); + layout_util_sync_color(lw); + layout_image_refresh(lw); +#endif +} + +static void layout_color_menu_use_image_cb(GtkToggleAction *action, gpointer data) +{ +#ifdef HAVE_LCMS + LayoutWindow *lw = data; + gint input, screen; + gboolean use_image; + + if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; + layout_image_color_profile_set(lw, input, screen, gtk_toggle_action_get_active(action)); + layout_util_sync_color(lw); + layout_image_refresh(lw); +#endif +} + +static void layout_color_menu_input_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) +{ +#ifdef HAVE_LCMS + LayoutWindow *lw = data; + gint type; + gint input, screen; + gboolean use_image; + + type = gtk_radio_action_get_current_value(action); + if (type < 0 || type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) return; + + if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; + if (type == input) return; + + layout_image_color_profile_set(lw, type, screen, use_image); + layout_image_refresh(lw); +#endif +} + +#if 0 +static gchar *layout_color_name_parse(const gchar *name) +{ + if (!name || !*name) return g_strdup(_("Empty")); + return g_strdelimit(g_strdup(name), "_", '-'); +} + + +static void layout_color_button_press_cb(GtkWidget *widget, gpointer data) +{ +#ifndef HAVE_LCMS + gchar *msg = g_strdup_printf(_("This installation of %s was not built with support for color profiles."), GQ_APPNAME); + file_util_warning_dialog(_("Color profiles not supported"), + msg, + GTK_STOCK_DIALOG_INFO, widget); + g_free(msg); + return; +#else + LayoutWindow *lw = data; + GtkWidget *menu; + GtkWidget *item; + gchar *buf; + gboolean active; + gint input = 0; + gint screen = 0; + gboolean use_image = FALSE; + gboolean from_image; + gint image_profile; + gint i; + + if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; + + image_profile = layout_image_color_profile_get_from_image(lw); + from_image = use_image && (image_profile != COLOR_PROFILE_NONE); + menu = popup_menu_short_lived(); + + active = layout_image_color_profile_get_use(lw); + menu_item_add_check(menu, _("Use _color profiles"), active, + G_CALLBACK(layout_color_menu_enable_cb), lw); + + menu_item_add_divider(menu); + + item = menu_item_add_check(menu, _("Use profile from _image"), use_image, + G_CALLBACK(layout_color_menu_use_image_cb), lw); + gtk_widget_set_sensitive(item, image_profile == COLOR_PROFILE_MEM || (image_profile > COLOR_PROFILE_NONE && image_profile < COLOR_PROFILE_FILE)); + + for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) + { + const gchar *label; + + switch (i) + { + case COLOR_PROFILE_SRGB: label = _("sRGB"); break; + case COLOR_PROFILE_ADOBERGB: label = _("AdobeRGB compatible"); break; + default: label = "fixme"; break; + } + buf = g_strdup_printf(_("Input _%d: %s%s"), i, label, (i == image_profile) ? " *" : ""); + item = menu_item_add_radio(menu, (i == COLOR_PROFILE_SRGB) ? NULL : item, + buf, (input == i), + G_CALLBACK(layout_color_menu_input_cb), lw); + g_free(buf); + g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i)); + gtk_widget_set_sensitive(item, active && !from_image); + } + + for (i = 0; i < COLOR_PROFILE_INPUTS; i++) + { + const gchar *name = options->color_profile.input_name[i]; + const gchar *file = options->color_profile.input_file[i]; + gchar *end; + + if (!name || !name[0]) name = filename_from_path(file); + + end = layout_color_name_parse(name); + buf = g_strdup_printf(_("Input _%d: %s"), i + COLOR_PROFILE_FILE, end); + g_free(end); + + item = menu_item_add_radio(menu, item, + buf, (i + COLOR_PROFILE_FILE == input), + G_CALLBACK(layout_color_menu_input_cb), lw); + g_free(buf); + g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE)); + gtk_widget_set_sensitive(item, active && !from_image && is_readable_file(file)); + } + + menu_item_add_divider(menu); + + item = menu_item_add_radio(menu, NULL, + _("Screen sRGB"), (screen == 0), + G_CALLBACK(layout_color_menu_screen_cb), lw); + + g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0)); + gtk_widget_set_sensitive(item, active); + + item = menu_item_add_radio(menu, item, + _("_Screen profile"), (screen == 1), + G_CALLBACK(layout_color_menu_screen_cb), lw); + g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1)); + gtk_widget_set_sensitive(item, active && is_readable_file(options->color_profile.screen_file)); + + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); +#endif /* HAVE_LCMS */ +} + +#endif + /* *----------------------------------------------------------------------------- * recent menu @@ -1147,6 +1306,7 @@ { "ViewMenu", NULL, N_("_View"), NULL, NULL, NULL }, { "DirMenu", NULL, N_("_View Directory as"), NULL, NULL, NULL }, { "ZoomMenu", NULL, N_("_Zoom"), NULL, NULL, NULL }, + { "ColorMenu", NULL, N_("Color _Management"), NULL, NULL, NULL }, { "ConnectZoomMenu", NULL, N_("_Connected Zoom"), NULL, NULL, NULL }, { "SplitMenu", NULL, N_("_Split"), NULL, NULL, NULL }, { "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL }, @@ -1268,6 +1428,8 @@ { "SBar", NULL, N_("_Info"), "<control>K", NULL, CB(layout_menu_bar_cb), FALSE }, { "SBarSort", NULL, N_("Sort _manager"), "<control>S", NULL, CB(layout_menu_bar_sort_cb), FALSE }, { "SlideShow", NULL, N_("Toggle _slideshow"),"S", NULL, CB(layout_menu_slideshow_cb), FALSE }, + { "UseColorProfiles", NULL, N_("Use _color profiles"), NULL, NULL, CB(layout_color_menu_enable_cb), FALSE}, + { "UseImageProfile", NULL, N_("Use profile from _image"), NULL, NULL, CB(layout_color_menu_use_image_cb), FALSE}, }; static GtkRadioActionEntry menu_radio_entries[] = { @@ -1282,6 +1444,14 @@ { "SplitSingle", NULL, N_("Single"), "Y", NULL, SPLIT_NONE } }; +static GtkRadioActionEntry menu_color_radio_entries[] = { + { "ColorProfile0", NULL, N_("Input _0: sRGB"), NULL, NULL, COLOR_PROFILE_SRGB }, + { "ColorProfile1", NULL, N_("Input _1: AdobeRGB compatible"), NULL, NULL, COLOR_PROFILE_ADOBERGB }, + { "ColorProfile2", NULL, N_("Input _2"), NULL, NULL, COLOR_PROFILE_FILE }, + { "ColorProfile3", NULL, N_("Input _3"), NULL, NULL, COLOR_PROFILE_FILE + 1 }, + { "ColorProfile4", NULL, N_("Input _4"), NULL, NULL, COLOR_PROFILE_FILE + 2 }, + { "ColorProfile5", NULL, N_("Input _5"), NULL, NULL, COLOR_PROFILE_FILE + 3 } +}; #undef CB @@ -1367,6 +1537,16 @@ " <menuitem action='PanView'/>" " <placeholder name='WindowSection'/>" " <separator/>" +" <menu action='ColorMenu'>" +" <menuitem action='UseColorProfiles'/>" +" <menuitem action='UseImageProfile'/>" +" <menuitem action='ColorProfile0'/>" +" <menuitem action='ColorProfile1'/>" +" <menuitem action='ColorProfile2'/>" +" <menuitem action='ColorProfile3'/>" +" <menuitem action='ColorProfile4'/>" +" <menuitem action='ColorProfile5'/>" +" </menu>" " <menu action='ZoomMenu'>" " <menuitem action='ZoomIn'/>" " <menuitem action='ZoomOut'/>" @@ -1721,6 +1901,10 @@ gtk_action_group_add_radio_actions(lw->action_group, menu_view_dir_radio_entries, VIEW_DIR_TYPES_COUNT, 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw); + gtk_action_group_add_radio_actions(lw->action_group, + menu_color_radio_entries, COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS, + 0, G_CALLBACK(layout_color_menu_input_cb), lw); + lw->ui_manager = gtk_ui_manager_new(); gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); @@ -1877,6 +2061,62 @@ * misc *----------------------------------------------------------------------------- */ +static gchar *layout_color_name_parse(const gchar *name) +{ + if (!name || !*name) return g_strdup(_("Empty")); + return g_strdelimit(g_strdup(name), "_", '-'); +} + +static void layout_util_sync_color(LayoutWindow *lw) +{ + GtkAction *action; + gint input = 0; + gint screen = 0; + gboolean use_color; + gboolean use_image = FALSE; + gint i; + gchar action_name[15]; + + if (!lw->action_group) return; + if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; + + use_color = layout_image_color_profile_get_use(lw); + + action = gtk_action_group_get_action(lw->action_group, "UseColorProfiles"); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_color); + + action = gtk_action_group_get_action(lw->action_group, "UseImageProfile"); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_image); + gtk_action_set_sensitive(action, use_color); + + for (i = 0; i < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS; i++) + { + sprintf(action_name, "ColorProfile%d", i); + action = gtk_action_group_get_action(lw->action_group, action_name); + + if (i >= COLOR_PROFILE_FILE) + { + const gchar *name = options->color_profile.input_name[i - COLOR_PROFILE_FILE]; + const gchar *file = options->color_profile.input_file[i - COLOR_PROFILE_FILE]; + gchar *end; + gchar *buf; + + if (!name || !name[0]) name = filename_from_path(file); + + end = layout_color_name_parse(name); + buf = g_strdup_printf(_("Input _%d: %s"), i, end); + g_free(end); + + g_object_set(G_OBJECT(action), "label", buf, NULL); + g_free(buf); + + gtk_action_set_visible(action, file && file[0]); + } + + gtk_action_set_sensitive(action, !use_image); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), (i == input)); + } +} static void layout_util_sync_views(LayoutWindow *lw) { @@ -1914,6 +2154,7 @@ action = gtk_action_group_get_action(lw->action_group, "SlideShow"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_slideshow_active(lw)); + layout_util_sync_color(lw); } void layout_util_sync_thumb(LayoutWindow *lw)