# HG changeset patch # User nadvornik # Date 1208627741 0 # Node ID 9fe0ca1b52631a6b3ffd4b7c2f24537d2c953c18 # Parent 10efd67e5d3c40aa28782b71470150c68ddc35a9 show the AdobeRGB profile in the menu, indicate input profile from image diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/color-man.h --- a/src/color-man.h Sat Apr 19 17:14:03 2008 +0000 +++ b/src/color-man.h Sat Apr 19 17:55:41 2008 +0000 @@ -14,11 +14,11 @@ #define COLOR_MAN_H typedef enum { - COLOR_PROFILE_NONE = 0, + COLOR_PROFILE_NONE = -1, + COLOR_PROFILE_MEM = -2, + COLOR_PROFILE_SRGB = 0, + COLOR_PROFILE_ADOBERGB, COLOR_PROFILE_FILE, - COLOR_PROFILE_SRGB, - COLOR_PROFILE_ADOBERGB, - COLOR_PROFILE_MEM } ColorManProfileType; typedef enum { diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/image.c --- a/src/image.c Sat Apr 19 17:14:03 2008 +0000 +++ b/src/image.c Sat Apr 19 17:55:41 2008 +0000 @@ -339,8 +339,8 @@ if (imd->cm) return FALSE; - if (imd->color_profile_input >= 1 && - imd->color_profile_input <= COLOR_PROFILE_INPUTS) + if (imd->color_profile_input >= COLOR_PROFILE_FILE && + imd->color_profile_input < COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS) { gint n; @@ -350,9 +350,10 @@ input_type = COLOR_PROFILE_FILE; input_file = options->color_profile.input_file[n]; } - else if (imd->color_profile_input == 0) + else if (imd->color_profile_input >= COLOR_PROFILE_SRGB && + imd->color_profile_input < COLOR_PROFILE_FILE) { - input_type = COLOR_PROFILE_SRGB; + input_type = imd->color_profile_input; input_file = NULL; } else @@ -375,6 +376,7 @@ { return FALSE; } + imd->color_profile_from_image = COLOR_PROFILE_NONE; if (imd->color_profile_use_image && exif) { @@ -392,6 +394,7 @@ { input_type = COLOR_PROFILE_SRGB; input_file = NULL; + imd->color_profile_from_image = COLOR_PROFILE_SRGB; if (debug) printf("Found EXIF ColorSpace of sRGB\n"); } @@ -399,6 +402,7 @@ { input_type = COLOR_PROFILE_ADOBERGB; input_file = NULL; + imd->color_profile_from_image = COLOR_PROFILE_ADOBERGB; if (debug) printf("Found EXIF ColorSpace of AdobeRGB\n"); } @@ -412,6 +416,7 @@ unsigned char *data; guint data_len; if (debug) printf("Found embedded color profile\n"); + imd->color_profile_from_image = COLOR_PROFILE_MEM; data = (unsigned char *) exif_item_get_data(item, &data_len); @@ -1744,6 +1749,13 @@ return imd->color_profile_enable; } +gint image_color_profile_get_from_image(ImageWindow *imd) +{ + if (!imd) return FALSE; + + return imd->color_profile_from_image; +} + void image_set_delay_flip(ImageWindow *imd, gint delay) { if (!imd || @@ -2002,6 +2014,7 @@ imd->color_profile_input = 0; imd->color_profile_screen = 0; imd->color_profile_use_image = FALSE; + imd->color_profile_from_image = COLOR_PROFILE_NONE; imd->auto_refresh_id = -1; imd->auto_refresh_interval = -1; diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/image.h --- a/src/image.h Sat Apr 19 17:14:03 2008 +0000 +++ b/src/image.h Sat Apr 19 17:55:41 2008 +0000 @@ -104,6 +104,7 @@ gint *use_image); void image_color_profile_set_use(ImageWindow *imd, gint enable); gint image_color_profile_get_use(ImageWindow *imd); +gint image_color_profile_get_from_image(ImageWindow *imd); /* set delayed page flipping */ void image_set_delay_flip(ImageWindow *imd, gint delay); diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/layout.c --- a/src/layout.c Sat Apr 19 17:14:03 2008 +0000 +++ b/src/layout.c Sat Apr 19 17:55:41 2008 +0000 @@ -13,6 +13,7 @@ #include "layout.h" #include "image.h" +#include "color-man.h" #include "layout_config.h" #include "layout_image.h" #include "layout_util.h" @@ -389,10 +390,12 @@ gint input = 0; gint screen = 0; gint use_image = 0; + gint from_image = 0; gint i; if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; + from_image = use_image && (layout_image_color_profile_get_from_image(lw) != COLOR_PROFILE_NONE); menu = popup_menu_short_lived(); active = layout_image_color_profile_get_use(lw); @@ -405,15 +408,18 @@ G_CALLBACK(layout_color_menu_use_image_cb), lw); gtk_widget_set_sensitive(item, active); - front = g_strdup_printf(_("Input _%d:"), 0); - buf = g_strdup_printf("%s %s", front, "sRGB"); - g_free(front); - item = menu_item_add_radio(menu, NULL, - buf, (options->color_profile.input_type == 0), + for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) + { + front = g_strdup_printf(_("Input _%d:"), i); + buf = g_strdup_printf("%s %s", front, i == COLOR_PROFILE_SRGB ? _("sRGB") : _("AdobeRGB compatible")); + g_free(front); + item = menu_item_add_radio(menu, (i == 0) ? 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(0)); - gtk_widget_set_sensitive(item, active); + 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++) { @@ -422,18 +428,18 @@ name = options->color_profile.input_name[i]; if (!name) name = filename_from_path(options->color_profile.input_file[i]); - front = g_strdup_printf(_("Input _%d:"), i + 1); + front = g_strdup_printf(_("Input _%d:"), i + COLOR_PROFILE_FILE); end = layout_color_name_parse(name); buf = g_strdup_printf("%s %s", front, end); g_free(front); g_free(end); item = menu_item_add_radio(menu, item, - buf, (i + 1 == input), + 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 + 1)); - gtk_widget_set_sensitive(item, active && options->color_profile.input_file[i]); + g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE)); + gtk_widget_set_sensitive(item, active && options->color_profile.input_file[i] && !from_image); } menu_item_add_divider(menu); diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/layout_image.c --- a/src/layout_image.c Sat Apr 19 17:14:03 2008 +0000 +++ b/src/layout_image.c Sat Apr 19 17:55:41 2008 +0000 @@ -1305,6 +1305,13 @@ return image_color_profile_get_use(lw->image); } +gint layout_image_color_profile_get_from_image(LayoutWindow *lw) +{ + if (!layout_valid(&lw)) return FALSE; + + return image_color_profile_get_from_image(lw->image); +} + /* *---------------------------------------------------------------------------- * list walkers diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/layout_image.h --- a/src/layout_image.h Sat Apr 19 17:14:03 2008 +0000 +++ b/src/layout_image.h Sat Apr 19 17:55:41 2008 +0000 @@ -35,6 +35,7 @@ gint *use_image); void layout_image_color_profile_set_use(LayoutWindow *lw, gint enable); gint layout_image_color_profile_get_use(LayoutWindow *lw); +gint layout_image_color_profile_get_from_image(LayoutWindow *lw); const gchar *layout_image_get_path(LayoutWindow *lw); diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/preferences.c --- a/src/preferences.c Sat Apr 19 17:14:03 2008 +0000 +++ b/src/preferences.c Sat Apr 19 17:55:41 2008 +0000 @@ -18,6 +18,7 @@ #include "filelist.h" #include "fullscreen.h" #include "image.h" +#include "color-man.h" #include "img-view.h" #include "layout_config.h" #include "layout_util.h" @@ -1451,7 +1452,7 @@ GtkWidget *entry; gchar *buf; - buf = g_strdup_printf("Input %d:", i + 1); + buf = g_strdup_printf("Input %d:", i + COLOR_PROFILE_FILE); pref_table_label(table, 0, i + 1, buf, 1.0); g_free(buf); diff -r 10efd67e5d3c -r 9fe0ca1b5263 src/typedefs.h --- a/src/typedefs.h Sat Apr 19 17:14:03 2008 +0000 +++ b/src/typedefs.h Sat Apr 19 17:55:41 2008 +0000 @@ -365,6 +365,7 @@ gint color_profile_input; gint color_profile_screen; gint color_profile_use_image; + gint color_profile_from_image; gpointer cm; AlterType delay_alter_type;