[gnome-color-manager] Add the OutputIntent property to the DBus interface for other applications to consume
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add the OutputIntent property to the DBus interface for other applications to consume
- Date: Wed, 25 Nov 2009 22:58:25 +0000 (UTC)
commit 5b19863c82536809616e2fd199effee053906433
Author: Richard Hughes <richard hughsie com>
Date: Wed Nov 25 22:57:08 2009 +0000
Add the OutputIntent property to the DBus interface for other applications to consume
data/gnome-color-manager.schemas.in | 12 ++++
src/gcm-dbus.c | 105 +++++++++++++++++++++++++++++++++++
src/gcm-inspect.c | 66 ++++++++++++++++++++-
src/gcm-prefs.c | 63 +++++++++++++++------
src/gcm-utils.h | 2 +
src/org.gnome.ColorManager.xml | 40 +++++++++++++
6 files changed, 267 insertions(+), 21 deletions(-)
---
diff --git a/data/gnome-color-manager.schemas.in b/data/gnome-color-manager.schemas.in
index 9b100cc..30017a5 100644
--- a/data/gnome-color-manager.schemas.in
+++ b/data/gnome-color-manager.schemas.in
@@ -41,6 +41,18 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/gnome-color-manager/output_intent</key>
+ <applyto>/apps/gnome-color-manager/output_intent</applyto>
+ <owner>gnome-color-manager</owner>
+ <type>string</type>
+ <default>true</default>
+ <locale name="C">
+ <short>The output intent to use, e.g. 'perceptual'.</short>
+ <long>The output intent to use, e.g. 'perceptual'.</long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
diff --git a/src/gcm-dbus.c b/src/gcm-dbus.c
index 47ad93e..dc7f1d3 100644
--- a/src/gcm-dbus.c
+++ b/src/gcm-dbus.c
@@ -27,6 +27,7 @@
#include "egg-debug.h"
+#include "gcm-utils.h"
#include "gcm-dbus.h"
#include "gcm-client.h"
@@ -39,8 +40,22 @@ struct GcmDbusPrivate
GConfClient *gconf_client;
GcmClient *client;
GTimer *timer;
+ gchar *output_intent;
};
+enum {
+ PROP_0,
+ PROP_OUTPUT_INTENT,
+ PROP_LAST
+};
+
+enum {
+ SIGNAL_CHANGED,
+ SIGNAL_LAST,
+};
+
+static guint signals[SIGNAL_LAST] = { 0 };
+
G_DEFINE_TYPE (GcmDbus, gcm_dbus, G_TYPE_OBJECT)
/**
@@ -77,6 +92,46 @@ gcm_dbus_error_get_type (void)
return etype;
}
+
+/**
+ * gcm_dbus_get_property:
+ **/
+static void
+gcm_dbus_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ GcmDbus *dbus = GCM_DBUS (object);
+ switch (prop_id) {
+ case PROP_OUTPUT_INTENT:
+ g_value_set_string (value, dbus->priv->output_intent);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+ /* reset time */
+ g_timer_reset (dbus->priv->timer);
+}
+
+/**
+ * gcm_dbus_set_property:
+ **/
+static void
+gcm_dbus_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ GcmDbus *dbus = GCM_DBUS (object);
+
+ switch (prop_id) {
+ case PROP_OUTPUT_INTENT:
+ g_free (dbus->priv->output_intent);
+ dbus->priv->output_intent = g_strdup (g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
/**
* gcm_dbus_get_idle_time:
**/
@@ -151,7 +206,39 @@ gcm_dbus_class_init (GcmDbusClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gcm_dbus_finalize;
+ object_class->get_property = gcm_dbus_get_property;
+ object_class->set_property = gcm_dbus_set_property;
g_type_class_add_private (klass, sizeof (GcmDbusPrivate));
+
+ signals[SIGNAL_CHANGED] =
+ g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * GcmDbus:output-intent:
+ */
+ g_object_class_install_property (object_class,
+ PROP_OUTPUT_INTENT,
+ g_param_spec_string ("output-intent",
+ NULL, NULL,
+ NULL,
+ G_PARAM_READABLE));
+}
+
+/**
+ * gcm_dbus_gconf_key_changed_cb:
+ *
+ * We might have to do things when the gconf keys change; do them here.
+ **/
+static void
+gcm_dbus_gconf_key_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, GcmDbus *dbus)
+{
+ /* just emit signal */
+ g_signal_emit (dbus, signals[SIGNAL_CHANGED], 0);
}
/**
@@ -169,6 +256,23 @@ gcm_dbus_init (GcmDbus *dbus)
dbus->priv->client = gcm_client_new ();
dbus->priv->timer = g_timer_new ();
+ /* notify on changes */
+ gconf_client_notify_add (dbus->priv->gconf_client, GCM_SETTINGS_DIR,
+ (GConfClientNotifyFunc) gcm_dbus_gconf_key_changed_cb,
+ dbus, NULL, NULL);
+
+ /* coldplug */
+ dbus->priv->output_intent = gconf_client_get_string (dbus->priv->gconf_client, GCM_SETTINGS_OUTPUT_INTENT, &error);
+ if (dbus->priv->output_intent == NULL) {
+ if (error != NULL) {
+ egg_warning ("failed to get intent: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ /* set defaults as GConf isn't sure */
+ dbus->priv->output_intent = g_strdup ("disabled");
+ }
+
/* get all devices */
ret = gcm_client_add_connected (dbus->priv->client, &error);
if (!ret) {
@@ -189,6 +293,7 @@ gcm_dbus_finalize (GObject *object)
dbus = GCM_DBUS (object);
g_return_if_fail (dbus->priv != NULL);
+ g_free (dbus->priv->output_intent);
g_object_unref (dbus->priv->client);
g_object_unref (dbus->priv->gconf_client);
g_timer_destroy (dbus->priv->timer);
diff --git a/src/gcm-inspect.c b/src/gcm-inspect.c
index 0080efc..ffecc7f 100644
--- a/src/gcm-inspect.c
+++ b/src/gcm-inspect.c
@@ -185,9 +185,6 @@ gcm_inspect_show_profiles_for_device (const gchar *sysfs_path)
goto out;
}
- if (profiles == NULL)
- egg_error ("moo");
-
/* no entries */
if (profiles[0] == NULL) {
/* TRANSLATORS: no rofile has been asigned to this device */
@@ -206,6 +203,65 @@ out:
}
/**
+ * gcm_inspect_get_properties_collect_cb:
+ **/
+static void
+gcm_inspect_get_properties_collect_cb (const char *key, const GValue *value, gpointer user_data)
+{
+ if (g_strcmp0 (key, "OutputIntent") == 0) {
+ /* TRANSLATORS: this is the rendering intent of the output */
+ g_print ("%s %s\n", _("Rendering intent (output):"), g_value_get_string (value));
+ } else {
+ egg_warning ("unhandled property '%s'", key);
+ }
+}
+
+/**
+ * gcm_inspect_get_properties:
+ **/
+static gboolean
+gcm_inspect_get_properties (void)
+{
+ gboolean ret;
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ gchar **profiles = NULL;
+ GHashTable *hash;
+
+ /* get a session bus connection */
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+ /* connect to the interface */
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "org.gnome.ColorManager",
+ "/org/gnome/ColorManager",
+ "org.freedesktop.DBus.Properties");
+
+ /* execute sync method */
+ ret = dbus_g_proxy_call (proxy, "GetAll", &error,
+ G_TYPE_STRING, "org.gnome.ColorManager",
+ G_TYPE_INVALID,
+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &hash,
+ G_TYPE_INVALID);
+ if (!ret) {
+ egg_warning ("failed: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* process results */
+ if (hash != NULL)
+ g_hash_table_foreach (hash, (GHFunc) gcm_inspect_get_properties_collect_cb, NULL);
+out:
+ if (hash != NULL)
+ g_hash_table_unref (hash);
+ g_object_unref (proxy);
+ g_strfreev (profiles);
+ return ret;
+}
+
+/**
* main:
**/
int
@@ -221,7 +277,7 @@ main (int argc, char **argv)
{ "x11", 'x', 0, G_OPTION_ARG_NONE, &x11,
/* TRANSLATORS: command line option */
_("Show X11 properties"), NULL },
- { "device", 'v', 0, G_OPTION_ARG_FILENAME, &sysfs_path,
+ { "device", '\0', 0, G_OPTION_ARG_FILENAME, &sysfs_path,
/* TRANSLATORS: command line option */
_("Get the profiles for a specific device"), NULL },
{ "dump", 'd', 0, G_OPTION_ARG_NONE, &dump,
@@ -249,6 +305,8 @@ main (int argc, char **argv)
gcm_inspect_show_x11_atoms ();
if (sysfs_path != NULL)
gcm_inspect_show_profiles_for_device (sysfs_path);
+ if (dump)
+ gcm_inspect_get_properties ();
g_free (sysfs_path);
return retval;
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 1e9ce9f..8fb57a7 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -1569,6 +1569,43 @@ gcm_prefs_radio_cb (GtkWidget *widget, gpointer user_data)
}
/**
+ * gcm_prefs_renderer_combo_changed_cb:
+ **/
+static void
+gcm_prefs_renderer_combo_changed_cb (GtkWidget *widget, gpointer data)
+{
+ gint active;
+ /* no selection */
+ active = gtk_combo_box_get_active (GTK_COMBO_BOX(widget));
+ if (active == -1)
+ return;
+ //TODO: need to save to GConf
+ egg_warning ("changed to %i", active);
+}
+
+/**
+ * gcm_prefs_setup_rendering_combobox:
+ **/
+static void
+gcm_prefs_setup_rendering_combobox (GtkWidget *widget)
+{
+ /* TRANSLATORS: rendering intent: you probably want to google this */
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Perceptual"));
+
+ /* TRANSLATORS: rendering intent: you probably want to google this */
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Relative colormetric"));
+
+ /* TRANSLATORS: rendering intent: you probably want to google this */
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Saturation"));
+
+ /* TRANSLATORS: rendering intent: you probably want to google this */
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Absolute colormetric"));
+
+ /* TRANSLATORS: rendering intent: you probably want to google this */
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Disable soft proofing"));
+}
+
+/**
* main:
**/
int
@@ -1693,33 +1730,25 @@ main (int argc, char **argv)
gcm_prefs_set_combo_simple_text (widget);
gtk_widget_set_sensitive (widget, FALSE);
g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (gcm_prefs_profile_combo_changed_cb), NULL);
+ G_CALLBACK (gcm_prefs_renderer_combo_changed_cb), NULL);
/* setup rendering lists */
widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_rendering_display"));
gcm_prefs_set_combo_simple_text (widget);
gtk_widget_set_sensitive (widget, FALSE);
-// g_signal_connect (G_OBJECT (widget), "changed",
-// G_CALLBACK (gcm_prefs_profile_combo_changed_cb), NULL);
- /* TRANSLATORS: rendering intent: you probably want to google this */
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Perceptual"));
- /* TRANSLATORS: rendering intent: you probably want to google this */
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Relative colormetric"));
- /* TRANSLATORS: rendering intent: you probably want to google this */
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Saturation"));
- /* TRANSLATORS: rendering intent: you probably want to google this */
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Absolute colormetric"));
- /* TRANSLATORS: rendering intent: you probably want to google this */
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Disable soft proofing"));
-
+ gcm_prefs_setup_rendering_combobox (widget);
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (gcm_prefs_renderer_combo_changed_cb), NULL);
+ //TODO: need to get from GConf
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_rendering_softproof"));
gcm_prefs_set_combo_simple_text (widget);
gtk_widget_set_sensitive (widget, FALSE);
-// g_signal_connect (G_OBJECT (widget), "changed",
-// G_CALLBACK (gcm_prefs_profile_combo_changed_cb), NULL);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Perceptual"));
+ gcm_prefs_setup_rendering_combobox (widget);
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (gcm_prefs_profile_combo_changed_cb), NULL);
+ //TODO: need to get from GConf
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
/* set ranges */
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index 991182e..f946af5 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -29,9 +29,11 @@
#define GCM_STOCK_ICON "gnome-color-manager"
#define GCM_PROFILE_PATH "/.color/icc"
+#define GCM_SETTINGS_DIR "/apps/gnome-color-manager"
#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"
+#define GCM_SETTINGS_OUTPUT_INTENT "/apps/gnome-color-manager/output_intent"
gboolean gcm_utils_set_gamma_for_device (GcmDevice *device,
GError **error);
diff --git a/src/org.gnome.ColorManager.xml b/src/org.gnome.ColorManager.xml
index 36f9d39..29e2d20 100644
--- a/src/org.gnome.ColorManager.xml
+++ b/src/org.gnome.ColorManager.xml
@@ -15,6 +15,34 @@
</doc:doc>
<!--*****************************************************************************************-->
+ <property name="OutputIntent" type="s" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ The rendering itent for the output.
+ </doc:para>
+ <doc:list>
+ <doc:item>
+ <doc:term>perceptual</doc:term><doc:definition>Perceptual</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>rel-colormetric</doc:term><doc:definition>Relative colormetric</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>saturation</doc:term><doc:definition>Saturation</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>abs-colormetric</doc:term><doc:definition>Absolute colormetric</doc:definition>
+ </doc:item>
+ <doc:item>
+ <doc:term>disabled</doc:term><doc:definition>Disabled</doc:definition>
+ </doc:item>
+ </doc:list>
+ </doc:description>
+ </doc:doc>
+ </property>
+
+ <!--*****************************************************************************************-->
<method name="GetProfilesForDevice">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<doc:doc>
@@ -52,6 +80,18 @@
</doc:doc>
</arg>
</method>
+
+ <!-- ************************************************************ -->
+ <signal name="Changed">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Some value on the interface has changed.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </signal>
+
</interface>
</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]