[gnome-color-manager] Allow the display policy to be disable, atom, clut or both due to popular request



commit de8a490a4653098ad724431e513978392386d758
Author: Richard Hughes <richard hughsie com>
Date:   Tue Nov 10 09:28:25 2009 +0000

    Allow the display policy to be disable, atom, clut or both due to popular request

 data/gcm-prefs.ui                   |   34 +++++++++++++++++++++++++++--
 data/gnome-color-manager.schemas.in |   14 +++++++++++-
 src/gcm-clut.c                      |    3 +-
 src/gcm-prefs.c                     |   40 +++++++++++++++++++++++++++-------
 src/gcm-utils.c                     |    6 +++-
 src/gcm-utils.h                     |    8 +++++-
 6 files changed, 87 insertions(+), 18 deletions(-)
---
diff --git a/data/gcm-prefs.ui b/data/gcm-prefs.ui
index a22b6e8..6516200 100644
--- a/data/gcm-prefs.ui
+++ b/data/gcm-prefs.ui
@@ -444,6 +444,20 @@
                     <property name="orientation">vertical</property>
                     <property name="spacing">3</property>
                     <child>
+                      <object class="GtkRadioButton" id="radiobutton_ouput_disable">
+                        <property name="label" translatable="yes">Do not enable display correction</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">radiobutton_ouput_global</property>
+                      </object>
+                      <packing>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
                       <object class="GtkRadioButton" id="radiobutton_ouput_global">
                         <property name="label" translatable="yes">Apply _global display correction</property>
                         <property name="visible">True</property>
@@ -454,12 +468,12 @@
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="position">0</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                     <child>
                       <object class="GtkRadioButton" id="radiobutton_ouput_atom">
-                        <property name="label" translatable="yes">_Use profile when viewing images</property>
+                        <property name="label" translatable="yes">_Set profile only for color managed applications</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
@@ -468,7 +482,21 @@
                         <property name="group">radiobutton_ouput_global</property>
                       </object>
                       <packing>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="radiobutton_ouput_both">
+                        <property name="label" translatable="yes">Do global correction and set profile for color managed applications</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">radiobutton_ouput_global</property>
+                      </object>
+                      <packing>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                   </object>
diff --git a/data/gnome-color-manager.schemas.in b/data/gnome-color-manager.schemas.in
index bdb848b..9b100cc 100644
--- a/data/gnome-color-manager.schemas.in
+++ b/data/gnome-color-manager.schemas.in
@@ -25,7 +25,19 @@
       <default>true</default>
       <locale name="C">
         <short>If the display should be globally corrected or left to applications.</short>
-        <long>If set to TRUE then the video LUT is set with the display profile and applications will have nothing to read from __ICC_PROFILE</long>
+        <long>If set to TRUE then the video LUT is set with the display profile</long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/gnome-color-manager/set_icc_profile_atom</key>
+      <applyto>/apps/gnome-color-manager/set_icc_profile_atom</applyto>
+      <owner>gnome-color-manager</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Set the _ICC_PROFILE atom for applications.</short>
+        <long>If set to TRUE then the __ICC_PROFILE atom will be set, which applications use to convert true color to screen color.</long>
       </locale>
     </schema>
 
diff --git a/src/gcm-clut.c b/src/gcm-clut.c
index 2051bf8..c70e796 100644
--- a/src/gcm-clut.c
+++ b/src/gcm-clut.c
@@ -35,6 +35,7 @@
 #include <gconf/gconf-client.h>
 
 #include "gcm-clut.h"
+#include "gcm-utils.h"
 #include "gcm-profile.h"
 
 #include "egg-debug.h"
@@ -418,7 +419,7 @@ gcm_clut_init (GcmClut *clut)
 	clut->priv->array = g_ptr_array_new_with_free_func (g_free);
 	clut->priv->profile = NULL;
 	clut->priv->gconf_client = gconf_client_get_default ();
-	clut->priv->gamma = gconf_client_get_float (clut->priv->gconf_client, "/apps/gnome-color-manager/default_gamma", NULL);
+	clut->priv->gamma = gconf_client_get_float (clut->priv->gconf_client, GCM_SETTINGS_DEFAULT_GAMMA, NULL);
 	if (clut->priv->gamma < 0.1f) {
 		egg_warning ("failed to get setup parameters");
 		clut->priv->gamma = 1.0f;
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 3c9f7bc..e113fe0 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -245,7 +245,7 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 		gcm_prefs_calibrate_scanner (calib);
 		break;
 	default:
-		egg_error ("calibration not supported for this device");
+		egg_warning ("calibration not supported for this device");
 		goto out;
 	}
 
@@ -1139,15 +1139,23 @@ static void
 gcm_prefs_radio_cb (GtkWidget *widget, gpointer user_data)
 {
 	const gchar *name;
-	gboolean ret = FALSE;
+	gboolean use_global = FALSE;
+	gboolean use_atom = FALSE;
 
 	/* find out what button was pressed */
 	name = gtk_widget_get_name (widget);
-	if (g_strcmp0 (name, "radiobutton_ouput_global") == 0)
-		ret = TRUE;
+	if (g_strcmp0 (name, "radiobutton_ouput_both") == 0) {
+		use_global = TRUE;
+		use_atom = TRUE;
+	} else if (g_strcmp0 (name, "radiobutton_ouput_global") == 0) {
+		use_global = TRUE;
+	} else if (g_strcmp0 (name, "radiobutton_ouput_atom") == 0) {
+		use_atom = TRUE;
+	}
 
 	/* save new preference */
-	gconf_client_set_bool (gconf_client, "/apps/gnome-color-manager/global_display_correction", ret, NULL);
+	gconf_client_set_bool (gconf_client, GCM_SETTINGS_GLOBAL_DISPLAY_CORRECTION, use_global, NULL);
+	gconf_client_set_bool (gconf_client, GCM_SETTINGS_SET_ICC_PROFILE_ATOM, use_atom, NULL);
 
 	/* set the new setting */
 	g_idle_add ((GSourceFunc) gcm_prefs_reset_devices_idle_cb, NULL);
@@ -1168,7 +1176,8 @@ main (int argc, char **argv)
 	guint xid = 0;
 	GError *error = NULL;
 	GMainLoop *loop;
-	gboolean ret;
+	gboolean use_global;
+	gboolean use_atom;
 	GtkTreeSelection *selection;
 	const gchar *subsystems[] = {"usb", NULL};
 	GtkWidget *info_bar_label;
@@ -1354,13 +1363,20 @@ main (int argc, char **argv)
 
 	/* setup defaults */
 	gconf_client = gconf_client_get_default ();
-	ret = gconf_client_get_bool (gconf_client, "/apps/gnome-color-manager/global_display_correction", NULL);
-	if (ret) {
+	use_global = gconf_client_get_bool (gconf_client, GCM_SETTINGS_GLOBAL_DISPLAY_CORRECTION, NULL);
+	use_atom = gconf_client_get_bool (gconf_client, GCM_SETTINGS_SET_ICC_PROFILE_ATOM, NULL);
+	if (use_global && use_atom) {
+		widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_both"));
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	} else if (use_global) {
 		widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_global"));
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-	} else {
+	} else if (use_atom) {
 		widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_atom"));
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	} else {
+		widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_disable"));
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
 	}
 
 	/* now connect radiobuttons */
@@ -1370,6 +1386,12 @@ main (int argc, char **argv)
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_atom"));
 	g_signal_connect (widget, "clicked",
 			  G_CALLBACK (gcm_prefs_radio_cb), NULL);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_both"));
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gcm_prefs_radio_cb), NULL);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "radiobutton_ouput_disable"));
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gcm_prefs_radio_cb), NULL);
 
 	/* do all this after the window has been set up */
 	g_idle_add (gcm_prefs_startup_idle_cb, NULL);
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index c18abbe..1f5aeec 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -227,6 +227,7 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 	gchar *id = NULL;
 	guint size;
 	gboolean use_global;
+	gboolean use_atom;
 	gboolean leftmost_screen = FALSE;
 	GcmDeviceType type;
 	GnomeRRScreen *rr_screen = NULL;
@@ -281,7 +282,7 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 	clut = gcm_clut_new ();
 
 	/* only set the CLUT if we're not seting the atom */
-	use_global = gconf_client_get_bool (gconf_client, "/apps/gnome-color-manager/global_display_correction", NULL);
+	use_global = gconf_client_get_bool (gconf_client, GCM_SETTINGS_GLOBAL_DISPLAY_CORRECTION, NULL);
 	if (use_global) {
 		g_object_set (clut,
 			      "profile", profile,
@@ -315,7 +316,8 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 	leftmost_screen = (x == 0 && y == 0);
 
 	/* either remove the atoms or set them */
-	if (use_global || profile == NULL) {
+	use_atom = gconf_client_get_bool (gconf_client, GCM_SETTINGS_SET_ICC_PROFILE_ATOM, NULL);
+	if (!use_atom || profile == NULL) {
 
 		/* remove the output atom if there's nothing to show */
 		ret = gcm_xserver_remove_output_profile (xserver, output_name, error);
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index 4f99a24..2f39bee 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -26,8 +26,12 @@
 
 #include "gcm-device.h"
 
-#define GCM_STOCK_ICON		"gnome-color-manager"
-#define GCM_PROFILE_PATH	"/.color/icc"
+#define GCM_STOCK_ICON				"gnome-color-manager"
+#define GCM_PROFILE_PATH			"/.color/icc"
+
+#define GCM_SETTINGS_DEFAULT_GAMMA		"/apps/gnome-color-manager/default_gamma"
+#define GCM_SETTINGS_GLOBAL_DISPLAY_CORRECTION	"/apps/gnome-color-manager/global_display_correction"
+#define GCM_SETTINGS_SET_ICC_PROFILE_ATOM	"/apps/gnome-color-manager/set_icc_profile_atom"
 
 gboolean	 gcm_utils_set_gamma_for_device		(GcmDevice		*device,
 							 GError			**error);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]