show the AdobeRGB profile in the menu, indicate input profile from image
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 19 Apr 2008 17:55:41 +0000 (17:55 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 19 Apr 2008 17:55:41 +0000 (17:55 +0000)
src/color-man.h
src/image.c
src/image.h
src/layout.c
src/layout_image.c
src/layout_image.h
src/preferences.c
src/typedefs.h

index 088f562..effd864 100644 (file)
 #define COLOR_MAN_H
 
 typedef enum {
-       COLOR_PROFILE_NONE = 0,
-       COLOR_PROFILE_FILE,
-       COLOR_PROFILE_SRGB,
+       COLOR_PROFILE_NONE = -1,
+       COLOR_PROFILE_MEM = -2,
+       COLOR_PROFILE_SRGB = 0,
        COLOR_PROFILE_ADOBERGB,
-       COLOR_PROFILE_MEM
+       COLOR_PROFILE_FILE,
 } ColorManProfileType;
 
 typedef enum {
index 5d0686c..6a021ac 100644 (file)
@@ -339,8 +339,8 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
 
        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 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
                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 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
                {
                return FALSE;
                }
+       imd->color_profile_from_image = COLOR_PROFILE_NONE;
 
        if (imd->color_profile_use_image && exif)
                {
@@ -392,6 +394,7 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
                                {
                                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 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
                                {
                                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 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
                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 @@ gint image_color_profile_get_use(ImageWindow *imd)
        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 @@ ImageWindow *image_new(gint frame)
        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;
index b660057..cad9529 100644 (file)
@@ -104,6 +104,7 @@ gint image_color_profile_get(ImageWindow *imd,
                             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);
index 5506316..9912705 100644 (file)
@@ -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 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
        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 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
                            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 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
                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);
index e0ce1f3..cf9b881 100644 (file)
@@ -1305,6 +1305,13 @@ gint layout_image_color_profile_get_use(LayoutWindow *lw)
        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
index a2ec930..a513f0b 100644 (file)
@@ -35,6 +35,7 @@ gint layout_image_color_profile_get(LayoutWindow *lw,
                                    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);
index 0eabf70..b9c09b2 100644 (file)
@@ -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 @@ static void config_tab_advanced(GtkWidget *notebook)
                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);
 
index 57a6f86..ca24131 100644 (file)
@@ -365,6 +365,7 @@ struct _ImageWindow
        gint color_profile_input;
        gint color_profile_screen;
        gint color_profile_use_image;
+       gint color_profile_from_image;
        gpointer cm;
 
        AlterType delay_alter_type;