Author: post
Date: 2011-04-25 15:01:15 +0200 (Mon, 25 Apr 2011)
New Revision: 4013

Modified:
   trunk/librawstudio/rs-color-space-selector.c
   trunk/librawstudio/rs-color-space-selector.h
   trunk/librawstudio/rs-color-space.c
   trunk/librawstudio/rs-color-space.h
   trunk/librawstudio/rs-curve.c
   trunk/librawstudio/rs-output.c
   trunk/plugins/colorspace-adobergb/colorspace-adobergb.c
   trunk/plugins/colorspace-prophoto/colorspace-prophoto.c
   trunk/plugins/colorspace-srgb/colorspace-srgb.c
   trunk/src/gtk-helper.c
   trunk/src/gtk-helper.h
   trunk/src/gtk-interface.c
   trunk/src/rs-preview-widget.c
   trunk/src/rs-toolbox.c
Log:
Overhaul of the Color Management system, to enable system display profiles and 
fix curves not being updated on load. Note that this also changes histogram 
behaviour, so they now use the former "exposure mask" colorspace, since showing 
display values doesn't make sense.

Modified: trunk/librawstudio/rs-color-space-selector.c
===================================================================
--- trunk/librawstudio/rs-color-space-selector.c        2011-04-24 11:02:46 UTC 
(rev 4012)
+++ trunk/librawstudio/rs-color-space-selector.c        2011-04-25 13:01:15 UTC 
(rev 4013)
@@ -62,16 +62,16 @@
 static void
 changed(GtkComboBox *combo_box)
 {
-       RSColorSpace *colorspace = NULL;
        GtkTreeIter iter;
        RSColorSpaceSelector *selector = RS_COLOR_SPACE_SELECTOR(combo_box);
+       const gchar *type = NULL;
 
        if (gtk_combo_box_get_active_iter(combo_box, &iter))
        {
-               gtk_tree_model_get(selector->priv->model, &iter, 
COLUMN_COLORSPACE, &colorspace, -1);
+               gtk_tree_model_get(selector->priv->model, &iter, 
COLUMN_TYPENAME, &type, -1);
 
-               if (colorspace)
-                       g_signal_emit(selector, signals[SELECTED_SIGNAL], 0, 
colorspace);
+               if (type)
+                       g_signal_emit(selector, signals[SELECTED_SIGNAL], 0, 
type);
        }
 }
 
@@ -93,8 +93,8 @@
                0,
                NULL,
                NULL,
-               g_cclosure_marshal_VOID__OBJECT,
-               G_TYPE_NONE, 1, RS_TYPE_COLOR_SPACE);
+               g_cclosure_marshal_VOID__POINTER,
+               G_TYPE_NONE, 1, G_TYPE_POINTER);
 }
 
 static void
@@ -137,17 +137,34 @@
                RSColorSpaceClass *klass;
                klass = g_type_class_ref(spaces[i]);
 
-               gtk_list_store_append(GTK_LIST_STORE(selector->priv->model), 
&iter);
-               gtk_list_store_set(GTK_LIST_STORE(selector->priv->model), &iter,
-                       COLUMN_TEXT, klass->name,
-                   COLUMN_TYPENAME, g_type_name(spaces[i]),
-                       COLUMN_COLORSPACE, 
rs_color_space_new_singleton(g_type_name(spaces[i])),
-                       -1);
-
+               if (klass->is_internal)
+               {
+                       
gtk_list_store_append(GTK_LIST_STORE(selector->priv->model), &iter);
+                       
gtk_list_store_set(GTK_LIST_STORE(selector->priv->model), &iter,
+                               COLUMN_TEXT, klass->name,
+                                       COLUMN_TYPENAME, g_type_name(spaces[i]),
+                               COLUMN_COLORSPACE, 
rs_color_space_new_singleton(g_type_name(spaces[i])),
+                               -1);
+               }
                g_type_class_unref(klass);
        }
 }
 
+void
+rs_color_space_selector_add_single(RSColorSpaceSelector *selector, const 
gchar* klass_name, const gchar* readable_name, RSColorSpace* space)
+{
+       GtkTreeIter iter;
+
+       g_return_if_fail(RS_IS_COLOR_SPACE_SELECTOR(selector));
+
+       gtk_list_store_append(GTK_LIST_STORE(selector->priv->model), &iter);
+       gtk_list_store_set(GTK_LIST_STORE(selector->priv->model), &iter,
+                       COLUMN_TEXT, readable_name,
+                       COLUMN_TYPENAME, klass_name,
+                       COLUMN_COLORSPACE, space,
+                       -1);
+}
+
 RSColorSpace *
 rs_color_space_selector_set_selected_by_name(RSColorSpaceSelector *selector, 
const gchar *type_name)
 {

Modified: trunk/librawstudio/rs-color-space-selector.h
===================================================================
--- trunk/librawstudio/rs-color-space-selector.h        2011-04-24 11:02:46 UTC 
(rev 4012)
+++ trunk/librawstudio/rs-color-space-selector.h        2011-04-25 13:01:15 UTC 
(rev 4013)
@@ -52,6 +52,9 @@
 void
 rs_color_space_selector_add_all(RSColorSpaceSelector *selector);
 
+void
+rs_color_space_selector_add_single(RSColorSpaceSelector *selector, const 
gchar* klass_name, const gchar* readable_name, RSColorSpace* space);
+
 RSColorSpace *
 rs_color_space_selector_set_selected_by_name(RSColorSpaceSelector *selector, 
const gchar *type_name);
 

Modified: trunk/librawstudio/rs-color-space.c
===================================================================
--- trunk/librawstudio/rs-color-space.c 2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/librawstudio/rs-color-space.c 2011-04-25 13:01:15 UTC (rev 4013)
@@ -24,6 +24,7 @@
 static void
 rs_color_space_class_init(RSColorSpaceClass *klass)
 {
+       klass->is_internal = FALSE;
 }
 
 static void

Modified: trunk/librawstudio/rs-color-space.h
===================================================================
--- trunk/librawstudio/rs-color-space.h 2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/librawstudio/rs-color-space.h 2011-04-25 13:01:15 UTC (rev 4013)
@@ -84,6 +84,7 @@
 
        const RSIccProfile *(*get_icc_profile)(const RSColorSpace *color_space, 
gboolean linear_profile);
        const RS1dFunction *(*get_gamma_function)(const RSColorSpace 
*color_space);
+       gboolean is_internal;
 } RSColorSpaceClass;
 
 #define RS_COLOR_SPACE_REQUIRES_CMS(color_space) (!!((color_space)->flags & 
RS_COLOR_SPACE_FLAG_REQUIRES_CMS))

Modified: trunk/librawstudio/rs-curve.c
===================================================================
--- trunk/librawstudio/rs-curve.c       2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/librawstudio/rs-curve.c       2011-04-25 13:01:15 UTC (rev 4013)
@@ -42,7 +42,7 @@
 
        gint last_width[2];
        PangoLayout* help_layout;
-
+       gboolean histogram_uptodate;
 };
 
 struct _RSCurveWidgetClass
@@ -210,8 +210,22 @@
        gint i;
        for (i = 0; i < 256; i++)
                curve->histogram_data[i] = input[i];
+
+       if (curve->bg_buffer)
+               g_free(curve->bg_buffer);
+       curve->bg_buffer = NULL;
+       curve->histogram_uptodate = TRUE;
+       rs_curve_draw_histogram(curve);
 }
 
+static void filter_changed(RSFilter *filter, RSFilterChangedMask mask, 
RSCurveWidget *curve)
+{
+       if (curve->bg_buffer)
+               g_free(curve->bg_buffer);
+       curve->bg_buffer = NULL;
+       curve->histogram_uptodate = FALSE;
+}
+
 /**
  * Set an image to base the histogram of
  * @param curve A RSCurveWidget
@@ -224,10 +238,12 @@
        g_return_if_fail (RS_IS_CURVE_WIDGET(curve));
        g_return_if_fail (RS_IS_FILTER(input));
 
+       if (input != curve->input)
+       {
+               g_signal_connect(input, "changed", G_CALLBACK(filter_changed), 
curve);
+       }
+
        curve->input = input;
-       if (curve->input)
-               rs_filter_set_recursive(RS_FILTER(input), "read-out-curve", 
curve, NULL);
-
        curve->display_color_space = display_color_space;
 }
 
@@ -242,7 +258,7 @@
 {
        g_assert(RS_IS_CURVE_WIDGET(curve));
 
-       if (curve->input)
+       if (curve->input && !curve->histogram_uptodate)
        {
                RSFilterRequest *request = rs_filter_request_new();
                rs_filter_request_set_quick(RS_FILTER_REQUEST(request), TRUE);
@@ -252,11 +268,6 @@
                g_object_unref(request);
                g_object_unref(response);
        }
-
-       if (curve->bg_buffer)
-               g_free(curve->bg_buffer);
-       curve->bg_buffer = NULL;
-
        rs_curve_draw(curve);
 }
 
@@ -864,15 +875,10 @@
        g_return_val_if_fail(RS_IS_CURVE_WIDGET (widget), FALSE);
        g_return_val_if_fail(event != NULL, FALSE);
 
-       RSCurveWidget *curve = RS_CURVE_WIDGET(widget);
-
        /* Do nothing if there's more expose events */
        if (event->count > 0)
                return FALSE;
 
-       if (curve->input)
-               rs_filter_set_recursive(RS_FILTER(curve->input), 
"read-out-curve", curve, NULL);
-
        rs_curve_draw(RS_CURVE_WIDGET(widget));
 
        return FALSE;

Modified: trunk/librawstudio/rs-output.c
===================================================================
--- trunk/librawstudio/rs-output.c      2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/librawstudio/rs-output.c      2011-04-25 13:01:15 UTC (rev 4013)
@@ -146,7 +146,7 @@
 }
 
 static void
-colorspace_changed(RSColorSpaceSelector *selector, RSColorSpace *color_space, 
gpointer user_data)
+colorspace_changed(RSColorSpaceSelector *selector, const gchar 
*color_space_name, gpointer user_data)
 {
        RSOutput *output = RS_OUTPUT(user_data);
 
@@ -154,10 +154,10 @@
        const gchar *confpath = g_object_get_data(G_OBJECT(selector), 
"conf-path");
 
        if (name)
-               g_object_set(output, name, color_space, NULL);
+               g_object_set(output, name, 
rs_color_space_new_singleton(color_space_name), NULL);
 
        if (confpath)
-               rs_conf_set_string(confpath, G_OBJECT_TYPE_NAME(color_space));
+               rs_conf_set_string(confpath, color_space_name);
 }
 
 /**

Modified: trunk/plugins/colorspace-adobergb/colorspace-adobergb.c
===================================================================
--- trunk/plugins/colorspace-adobergb/colorspace-adobergb.c     2011-04-24 
11:02:46 UTC (rev 4012)
+++ trunk/plugins/colorspace-adobergb/colorspace-adobergb.c     2011-04-25 
13:01:15 UTC (rev 4013)
@@ -61,6 +61,7 @@
        colorclass->name = "Adobe RGB (1998) Compatible";
        colorclass->description = _("Print friendly color space, compatible 
with Adobe RGB (1998)");
        colorclass->get_gamma_function = get_gamma_function;
+       colorclass->is_internal = TRUE;
 
        klass->icc_profile = rs_icc_profile_new_from_file(PACKAGE_DATA_DIR 
G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S 
"compatibleWithAdobeRGB1998.icc");
        klass->icc_profile_linear = 
rs_icc_profile_new_from_file(PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE 
G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S 
"compatibleWithAdobeRGB1998-linear.icc");

Modified: trunk/plugins/colorspace-prophoto/colorspace-prophoto.c
===================================================================
--- trunk/plugins/colorspace-prophoto/colorspace-prophoto.c     2011-04-24 
11:02:46 UTC (rev 4012)
+++ trunk/plugins/colorspace-prophoto/colorspace-prophoto.c     2011-04-25 
13:01:15 UTC (rev 4013)
@@ -61,6 +61,7 @@
        colorclass->name = "ProPhoto RGB";
        colorclass->description = _("Large gamut color space");
        colorclass->get_gamma_function = get_gamma_function;
+       colorclass->is_internal = TRUE;
 
        klass->icc_profile = rs_icc_profile_new_from_file(PACKAGE_DATA_DIR 
G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S 
"prophoto.icc");
        klass->icc_profile_linear = 
rs_icc_profile_new_from_file(PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE 
G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S "prophoto-linear.icc");

Modified: trunk/plugins/colorspace-srgb/colorspace-srgb.c
===================================================================
--- trunk/plugins/colorspace-srgb/colorspace-srgb.c     2011-04-24 11:02:46 UTC 
(rev 4012)
+++ trunk/plugins/colorspace-srgb/colorspace-srgb.c     2011-04-25 13:01:15 UTC 
(rev 4013)
@@ -62,6 +62,7 @@
 
        colorclass->get_icc_profile = get_icc_profile;
        colorclass->get_gamma_function = get_gamma_function;
+       colorclass->is_internal = TRUE;
 
        klass->icc_profile = rs_icc_profile_new_from_file(PACKAGE_DATA_DIR 
G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S 
"sRGB.icc");
        klass->icc_profile_linear = 
rs_icc_profile_new_from_file(PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE 
G_DIR_SEPARATOR_S "profiles" G_DIR_SEPARATOR_S "sRGB-linear.icc");

Modified: trunk/src/gtk-helper.c
===================================================================
--- trunk/src/gtk-helper.c      2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/src/gtk-helper.c      2011-04-25 13:01:15 UTC (rev 4013)
@@ -756,3 +756,79 @@
        gtk_container_add (GTK_CONTAINER (expander), in);
        return expander;
 }
+
+RSColorSpace*
+rs_get_display_profile(GtkWidget *widget)
+{
+       if (NULL == widget || (!GTK_IS_WIDGET(widget)) || 
(!GDK_IS_WINDOW(widget->window)))
+               return rs_color_space_new_singleton("RSSrgb");
+
+       /* Mainly from UFraw */
+       guint8 *buffer = NULL;
+       gint buffer_size = 0;
+#if defined GDK_WINDOWING_X11
+       GdkScreen *screen = gtk_widget_get_screen(widget);
+       if (screen == NULL)
+               screen = gdk_screen_get_default();
+       int monitor = gdk_screen_get_monitor_at_window (screen, widget->window);
+       char *atom_name;
+       if (monitor > 0)
+               atom_name = g_strdup_printf("_ICC_PROFILE_%d", monitor);
+       else
+               atom_name = g_strdup("_ICC_PROFILE");
+
+       GdkAtom type = GDK_NONE;
+       gint format = 0;
+       gdk_property_get(gdk_screen_get_root_window(screen),
+               gdk_atom_intern(atom_name, FALSE), GDK_NONE,
+               0, 64 * 1024 * 1024, FALSE,
+               &type, &format, &buffer_size, &buffer);
+       g_free(atom_name);
+
+#elif defined GDK_WINDOWING_QUARTZ
+       GdkScreen *screen = gtk_widget_get_screen(widget);
+       if (screen == NULL)
+               screen = gdk_screen_get_default();
+       int monitor = gdk_screen_get_monitor_at_window(screen, widget->window);
+
+       CMProfileRef prof = NULL;
+       CMGetProfileByAVID(monitor, &prof);
+       if ( prof==NULL )
+               return;
+
+       ProfileTransfer transfer = { NULL, 0 };
+       //The following code does not work on 64bit OSX.  Disable if we are 
compiling there.
+#ifndef __LP64__
+       Boolean foo;
+       CMFlattenProfile(prof, 0, dt_ctl_lcms_flatten_profile, &transfer, &foo);
+       CMCloseProfile(prof);
+#endif
+       buffer = transfer.data;
+       buffer_size = transfer.len;
+
+#elif defined G_OS_WIN32
+       (void)widget;
+       HDC hdc = GetDC(NULL);
+       if (hdc == NULL)
+               return;
+
+       DWORD len = 0;
+       GetICMProfile (hdc, &len, NULL);
+       gchar *path = g_new (gchar, len);
+
+       if (GetICMProfile(hdc, &len, path))
+       {
+               gsize size;
+               g_file_get_contents(path, (gchar**)&buffer, &size, NULL);
+               *buffer_size = size;
+       }
+       g_free(path);
+       ReleaseDC(NULL, hdc);
+#endif
+
+       if (NULL == buffer || 0 == buffer_size)
+               return rs_color_space_new_singleton("RSSrgb");
+
+       RSIccProfile* profile = rs_icc_profile_new_from_memory((gchar*)buffer, 
buffer_size, FALSE);
+       return rs_color_space_icc_new_from_icc(profile);
+}

Modified: trunk/src/gtk-helper.h
===================================================================
--- trunk/src/gtk-helper.h      2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/src/gtk-helper.h      2011-04-25 13:01:15 UTC (rev 4013)
@@ -89,3 +89,5 @@
 extern void gui_box_notify(GConfClient *client, guint cnxn_id, GConfEntry 
*entry, gpointer user_data);
 #endif
 extern GtkWidget * gui_box(const gchar *title, GtkWidget *in, gchar *key, 
gboolean default_expanded);
+
+extern RSColorSpace* rs_get_display_profile(GtkWidget *widget);

Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c   2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/src/gtk-interface.c   2011-04-25 13:01:15 UTC (rev 4013)
@@ -740,9 +740,13 @@
 }
 
 static void
-colorspace_changed(RSColorSpaceSelector *selector, RSColorSpace *color_space, 
gpointer user_data)
+colorspace_changed(RSColorSpaceSelector *selector, const gchar 
*color_space_name, gpointer user_data)
 {
-       rs_conf_set_string((const gchar*)user_data, 
G_OBJECT_TYPE_NAME(color_space));
+       rs_conf_set_string((const gchar*)user_data, color_space_name);
+       /* OMG, gconf_client_set_string, is applied in the main loop, until 
then, old values are returned */
+       GTK_CATCHUP();
+       
rs_preview_widget_update_display_colorspace(RS_PREVIEW_WIDGET(rs_get_blob()->preview),
 TRUE);
+       rs_preview_widget_update(RS_PREVIEW_WIDGET(rs_get_blob()->preview), 
TRUE);
 }
 
 static GtkWidget *
@@ -934,8 +938,9 @@
        cs_hbox = gtk_hbox_new(FALSE, 0);
        cs_label = gtk_label_new(_("Display Colorspace:"));
        cs_widget = rs_color_space_selector_new();
+       rs_color_space_selector_add_single(RS_COLOR_SPACE_SELECTOR(cs_widget), 
"_builtin_display", "System Display Profile", NULL);
        rs_color_space_selector_add_all(RS_COLOR_SPACE_SELECTOR(cs_widget));
-       
rs_color_space_selector_set_selected_by_name(RS_COLOR_SPACE_SELECTOR(cs_widget),
 "RSSrgb");
+       
rs_color_space_selector_set_selected_by_name(RS_COLOR_SPACE_SELECTOR(cs_widget),
 "_builtin_display");
        if ((str = rs_conf_get_string("display-colorspace")))
                color_space = 
rs_color_space_selector_set_selected_by_name(RS_COLOR_SPACE_SELECTOR(cs_widget),
 str);
        g_signal_connect(cs_widget, "colorspace-selected", 
G_CALLBACK(colorspace_changed), "display-colorspace");
@@ -944,7 +949,7 @@
        gtk_box_pack_start (GTK_BOX (preview_page), cs_hbox, FALSE, TRUE, 0);
 
        cs_hbox = gtk_hbox_new(FALSE, 0);
-       cs_label = gtk_label_new(_("Exposure Mask Colorspace:"));
+       cs_label = gtk_label_new(_("Histogram, Curve & Exp. Mask:"));
        cs_widget = rs_color_space_selector_new();
        rs_color_space_selector_add_all(RS_COLOR_SPACE_SELECTOR(cs_widget));
        
rs_color_space_selector_set_selected_by_name(RS_COLOR_SPACE_SELECTOR(cs_widget),
 "RSSrgb");

Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c       2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/src/rs-preview-widget.c       2011-04-25 13:01:15 UTC (rev 4013)
@@ -198,6 +198,7 @@
        GtkWidget *navigator;
 
        RSColorSpace *display_color_space;
+       RSColorSpace *exposure_color_space;
        guint status_num;
 };
 
@@ -333,13 +334,23 @@
        preview->exposure_mask = FALSE;
        preview->crop_near = CROP_NEAR_NOTHING;
        preview->keep_quick_enabled = FALSE;
+
        gchar* name;
+       preview->display_color_space = NULL;
        if ((name = rs_conf_get_string("display-colorspace")))
-               preview->display_color_space = 
rs_color_space_new_singleton(name);
+       {
+               if (0 != g_strcmp0(name, "_builtin_display"))
+                       preview->display_color_space = 
rs_color_space_new_singleton(name);
+       }
+       if (!preview->display_color_space)
+               preview->display_color_space = 
rs_get_display_profile(GTK_WIDGET(preview));
+
+       name = rs_conf_get_string("exposure-mask-colorspace");
+       if (name)
+               preview->exposure_color_space = 
rs_color_space_new_singleton(name);
        else
-               preview->display_color_space = 
rs_color_space_new_singleton("RSSrgb");
+               preview->exposure_color_space = 
rs_color_space_new_singleton("RSSrgb");
 
-
        preview->vadjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 
100.0, 1.0, 10.0, 10.0));
        preview->hadjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 
100.0, 1.0, 10.0, 10.0));
        g_signal_connect(G_OBJECT(preview->vadjustment), "value-changed", 
G_CALLBACK(adjustment_changed), preview);
@@ -449,7 +460,7 @@
        preview = RS_PREVIEW_WIDGET(widget);
        preview->toolbox = RS_TOOLBOX(toolbox);
 
-       rs_toolbox_set_histogram_input(preview->toolbox, 
preview->navigator_filter_end, preview->display_color_space);
+       rs_toolbox_set_histogram_input(preview->toolbox, 
preview->navigator_filter_end, preview->exposure_color_space);
        return widget;
 }
 
@@ -458,20 +469,36 @@
 {
        gint i;
        gchar *name;
-       RSColorSpace *new_cs = rs_color_space_new_singleton("RSSrgb");
-       if (preview->exposure_mask && (name = 
rs_conf_get_string("exposure-mask-colorspace")))
-               new_cs = rs_color_space_new_singleton(name);
+
+
+       RSColorSpace *new_cs = rs_get_display_profile(GTK_WIDGET(preview));
+       RSColorSpace *exp_cs = rs_color_space_new_singleton("RSSrgb");
+
+       name = rs_conf_get_string("exposure-mask-colorspace");
+       if (name)
+               exp_cs = rs_color_space_new_singleton(name);
+
+       /* If exposure mask, use the cs for that */
+       if (preview->exposure_mask)
+               new_cs = g_object_ref(exp_cs);
        else if (!preview->exposure_mask && (name = 
rs_conf_get_string("display-colorspace")))
-               new_cs = rs_color_space_new_singleton(name);
+       {
+               if (0 == g_strcmp0(name, "_builtin_display"))
+                       new_cs = rs_get_display_profile(GTK_WIDGET(preview));
+               else
+                       new_cs = rs_color_space_new_singleton(name);
+       }
 
-       if (new_cs == preview->display_color_space && !force)
+       if (preview->zoom_to_fit && preview->navigator)
+               rs_navigator_set_colorspace(RS_NAVIGATOR(preview->navigator), 
new_cs);
+
+       if (preview->display_color_space == new_cs && 
preview->exposure_color_space == exp_cs)
                return;
 
        preview->display_color_space = new_cs;
-       
-       rs_toolbox_set_histogram_input(preview->toolbox, 
preview->navigator_filter_end, preview->display_color_space);
-       if (preview->zoom_to_fit && preview->navigator)
-               rs_navigator_set_colorspace(RS_NAVIGATOR(preview->navigator), 
preview->display_color_space);
+       preview->exposure_color_space = exp_cs;
+
+       rs_toolbox_set_histogram_input(preview->toolbox, 
preview->navigator_filter_end, preview->exposure_color_space);
        rs_loupe_set_colorspace(preview->loupe, preview->display_color_space);
        for(i=0;i<MAX_VIEWS;i++)
        {
@@ -654,11 +681,12 @@
 
        if (preview->photo)
        {
+               rs_preview_widget_update_display_colorspace(preview, TRUE);
+               rs_toolbox_set_histogram_input(preview->toolbox, 
preview->navigator_filter_end, preview->exposure_color_space);
                rs_preview_widget_set_photo_settings(preview);
                photo->thumbnail_filter = preview->navigator_filter_end;
                g_signal_connect(G_OBJECT(preview->photo), "lens-changed", 
G_CALLBACK(lens_changed), preview);
                g_signal_connect(G_OBJECT(preview->photo), "profile-changed", 
G_CALLBACK(profile_changed), preview);
-               rs_preview_widget_update_display_colorspace(preview, TRUE);
        }
 }
 
@@ -2668,6 +2696,8 @@
        RS_IMAGE16 *image = rs_filter_response_get_image(response);
        g_object_unref(response);
 
+       rs_filter_param_set_object(RS_FILTER_PARAM(request), "colorspace", 
preview->exposure_color_space);
+
        /* We set input to the cache placed before exposure mask */
        response = rs_filter_get_image8(preview->filter_cache3[view], request);
        GdkPixbuf *buffer = rs_filter_response_get_image8(response);

Modified: trunk/src/rs-toolbox.c
===================================================================
--- trunk/src/rs-toolbox.c      2011-04-24 11:02:46 UTC (rev 4012)
+++ trunk/src/rs-toolbox.c      2011-04-25 13:01:15 UTC (rev 4013)
@@ -94,6 +94,7 @@
        gint selected_snapshot;
        RS_PHOTO *photo;
        RSFilter* histogram_input;
+       RSColorSpace* histogram_colorspace;
        GtkWidget *histogram;
        rs_profile_camera last_camera;
 
@@ -1184,6 +1185,9 @@
                        rs_profile_selector_select_profile(toolbox->selector, 
icc_profile);
        }
        toolbox->mute_from_sliders = FALSE;
+
+       /* Update histogram in curve editor */
+       
rs_curve_draw_histogram(RS_CURVE_WIDGET(toolbox->curve[toolbox->selected_snapshot]));
        gtk_widget_set_sensitive(toolbox->transforms, !!(toolbox->photo));
 }
 
@@ -1223,15 +1227,15 @@
 
 void rs_toolbox_set_histogram_input(RSToolbox * toolbox, RSFilter *input, 
RSColorSpace *display_color_space)
 {
-       int i;
        g_assert(RS_IS_TOOLBOX(toolbox));
        g_assert(RS_IS_FILTER(input));
+       gint i;
 
        toolbox->histogram_input = input;
-       rs_histogram_set_input(RS_HISTOGRAM_WIDGET(toolbox->histogram), input, 
display_color_space);
+       toolbox->histogram_colorspace = display_color_space;
        for( i = 0 ; i < 3 ; i++)
                rs_curve_set_input(RS_CURVE_WIDGET(toolbox->curve[i]), input, 
display_color_space);
-       
+       rs_histogram_set_input(RS_HISTOGRAM_WIDGET(toolbox->histogram), input, 
display_color_space);
 }
 
 static void


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to