[Rawstudio-commit] r3586 - trunk/src

Klaus Post klauspost at gmail.com
Sun Oct 24 22:30:15 CEST 2010


Author: post
Date: 2010-10-24 22:30:15 +0200 (Sun, 24 Oct 2010)
New Revision: 3586

Modified:
   trunk/src/gtk-interface.c
   trunk/src/rs-preview-widget.c
   trunk/src/rs-preview-widget.h
Log:
Add preferences to select display and exposure mask colorspaces.

Modified: trunk/src/gtk-interface.c
===================================================================
--- trunk/src/gtk-interface.c	2010-10-24 18:29:20 UTC (rev 3585)
+++ trunk/src/gtk-interface.c	2010-10-24 20:30:15 UTC (rev 3586)
@@ -459,6 +459,20 @@
 	update_example(quick);
 }
 
+static void
+closed_preferences(GtkEntry *entry, gint response_id, gpointer user_data)
+{
+	RS_BLOB *rs = (RS_BLOB*)user_data;
+	rs_preview_widget_update(RS_PREVIEW_WIDGET(rs->preview), TRUE);
+	gtk_widget_destroy(GTK_WIDGET(entry));
+}
+
+static void
+colorspace_changed(RSColorSpaceSelector *selector, RSColorSpace *color_space, gpointer user_data)
+{
+	rs_conf_set_string((const gchar*)user_data, G_OBJECT_TYPE_NAME(color_space));
+}
+
 static GtkWidget *
 gui_make_preference_quick_export()
 {
@@ -575,8 +589,13 @@
 	GtkWidget *histsize_hbox;
 	GtkObject *histsize_adj;
 	gint histogram_height;
+	GtkWidget *cs_hbox;
+	GtkWidget *cs_label;
+	GtkWidget* cs_widget;
 	GtkWidget *local_cache_check;
 	GtkWidget *system_theme_check;
+	gchar *str;
+	RSColorSpace *color_space;
 
 /*
 	GtkWidget *batch_page;
@@ -599,8 +618,6 @@
 	gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
 	g_signal_connect_swapped(dialog, "delete_event",
 		G_CALLBACK (gtk_widget_destroy), dialog);
-	g_signal_connect_swapped(dialog, "response",
-		G_CALLBACK (gtk_widget_destroy), dialog);
 
 	vbox = GTK_DIALOG (dialog)->vbox;
 
@@ -639,6 +656,31 @@
 
 	local_cache_check = checkbox_from_conf(CONF_CACHEDIR_IS_LOCAL, _("Place cache in home directory"), FALSE);
 	gtk_box_pack_start (GTK_BOX (preview_page), local_cache_check, FALSE, TRUE, 0);
+	
+	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_all(RS_COLOR_SPACE_SELECTOR(cs_widget));
+	rs_color_space_selector_set_selected_by_name(RS_COLOR_SPACE_SELECTOR(cs_widget), "RSSrgb");
+	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");
+	gtk_box_pack_start (GTK_BOX (cs_hbox), cs_label, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (cs_hbox), cs_widget, TRUE, TRUE, 0);
+	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_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");
+	if ((str = rs_conf_get_string("exposure-mask-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), "exposure-mask-colorspace");
+	gtk_box_pack_start (GTK_BOX (cs_hbox), cs_label, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (cs_hbox), cs_widget, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (preview_page), cs_hbox, FALSE, TRUE, 0);
+
 /*
 	batch_page = gtk_vbox_new(FALSE, 4);
 	gtk_container_set_border_width (GTK_CONTAINER (batch_page), 6);
@@ -708,7 +750,7 @@
 
 	button_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
 	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button_close, GTK_RESPONSE_CLOSE);
-
+	g_signal_connect(dialog, "response", G_CALLBACK(closed_preferences), rs);
 	gtk_widget_show_all(dialog);
 
 	return;

Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c	2010-10-24 18:29:20 UTC (rev 3585)
+++ trunk/src/rs-preview-widget.c	2010-10-24 20:30:15 UTC (rev 3586)
@@ -333,8 +333,13 @@
 	preview->exposure_mask = FALSE;
 	preview->crop_near = CROP_NEAR_NOTHING;
 	preview->keep_quick_enabled = FALSE;
-	preview->display_color_space = rs_color_space_new_singleton("RSSrgb");
+	gchar* name;
+	if ((name = rs_conf_get_string("display-colorspace")))
+		preview->display_color_space = rs_color_space_new_singleton(name);
+	else
+		preview->display_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);
@@ -444,6 +449,32 @@
 	return widget;
 }
 
+void
+rs_preview_widget_update_display_colorspace(RSPreviewWidget *preview, gboolean force)
+{
+	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);
+	else if (!preview->exposure_mask && (name = rs_conf_get_string("display-colorspace")))
+		new_cs = rs_color_space_new_singleton(name);
+
+	if (new_cs == preview->display_color_space && !force)
+		return;
+
+	preview->display_color_space = new_cs;
+	
+	rs_toolbox_set_histogram_input(preview->toolbox, preview->navigator_filter_end, preview->display_color_space);
+	if (preview->navigator)
+		rs_navigator_set_colorspace(RS_NAVIGATOR(preview->navigator), preview->display_color_space);
+	rs_loupe_set_colorspace(preview->loupe, preview->display_color_space);
+	for(i=0;i<MAX_VIEWS;i++)
+	{
+		DIRTY(preview->dirty[i], ALL);
+		rs_filter_param_set_object(RS_FILTER_PARAM(preview->request[i]), "colorspace", preview->display_color_space);
+	}
+}
 /**
  * Select zoom-to-fit of a RSPreviewWidget
  * @param preview A RSPreviewWidget
@@ -644,7 +675,7 @@
 		"height", NAVIGATOR_HEIGHT,
 		NULL);
 
-	rs_toolbox_set_histogram_input(preview->toolbox, preview->navigator_filter_end, preview->display_color_space);
+	rs_preview_widget_update_display_colorspace(preview, TRUE);
 }
 
 /**
@@ -926,9 +957,13 @@
 	{
 		gint view;
 		preview->exposure_mask = show_exposure_mask;
+
+		rs_preview_widget_update_display_colorspace(preview, FALSE);
 		for(view=0;view<preview->views;view++)
+		{
 			rs_filter_set_recursive(preview->filter_end[view], "exposure-mask", preview->exposure_mask, NULL);
 			DIRTY(preview->dirty[view], SCREEN);
+		}
 		rs_preview_widget_update(preview, FALSE);
 	}
 }
@@ -970,6 +1005,8 @@
 	if (rs_filter_request_get_quick(preview->request[0]) && !preview->keep_quick_enabled)
 		full_redraw = TRUE;
 
+	rs_preview_widget_update_display_colorspace(preview, FALSE);
+
 	if (full_redraw)
 	{
 		rect.x = 0;

Modified: trunk/src/rs-preview-widget.h
===================================================================
--- trunk/src/rs-preview-widget.h	2010-10-24 18:29:20 UTC (rev 3585)
+++ trunk/src/rs-preview-widget.h	2010-10-24 20:30:15 UTC (rev 3586)
@@ -169,6 +169,9 @@
 extern void
 rs_preview_widget_quick_end(RSPreviewWidget *preview);
 
+extern void 
+rs_preview_widget_update_display_colorspace(RSPreviewWidget *preview, gboolean force);
+
 #define RS_PREVIEW_TYPE_WIDGET             (rs_preview_widget_get_type ())
 #define RS_PREVIEW_WIDGET(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_PREVIEW_TYPE_WIDGET, RSPreviewWidget))
 #define RS_PREVIEW_WIDGET_CLASS(obj)       (G_TYPE_CHECK_CLASS_CAST ((obj), RS_PREVIEW_WIDGET, RSPreviewWidgetClass))




More information about the Rawstudio-commit mailing list