[gnome-settings-daemon] color: Add functionality to show optional notifications for when a color profile is out of calibrati



commit 9cfebbdac70fe186bf852da8438b3a5d85e5c05e
Author: Richard Hughes <richard hughsie com>
Date:   Fri May 20 21:02:19 2011 +0100

    color: Add functionality to show optional notifications for when a color profile is out of calibration
    
    This is a hard requirement for many graphics companies, and is already supported
    both on Windows 7 and OSX.
    This is off by default, of course.
    
    More useful functionality will be moved from the gcm-session process to this
    plugin in the near future.

 configure.ac                                       |    6 +
 ...settings-daemon.plugins.color.gschema.xml.in.in |    5 +
 plugins/Makefile.am                                |    1 +
 plugins/color/Makefile.am                          |   45 +++
 plugins/color/color.gnome-settings-plugin.in       |    8 +
 plugins/color/gsd-color-manager.c                  |  361 ++++++++++++++++++++
 plugins/color/gsd-color-manager.h                  |   58 ++++
 plugins/color/gsd-color-plugin.c                   |  111 ++++++
 plugins/color/gsd-color-plugin.h                   |   60 ++++
 po/POTFILES.in                                     |    2 +
 10 files changed, 657 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 80c7c2a..0beef8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,6 +98,11 @@ dnl ---------------------------------------------------------------------------
 PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION)
 
 dnl ---------------------------------------------------------------------------
+dnl - Check for colord
+dnl ---------------------------------------------------------------------------
+PKG_CHECK_MODULES(COLORD, colord >= 0.1.8)
+
+dnl ---------------------------------------------------------------------------
 dnl - Check for libnotify
 dnl ---------------------------------------------------------------------------
 
@@ -525,6 +530,7 @@ plugins/a11y-settings/Makefile
 plugins/automount/Makefile
 plugins/background/Makefile
 plugins/clipboard/Makefile
+plugins/color/Makefile
 plugins/common/Makefile
 plugins/datetime/Makefile
 plugins/dummy/Makefile
diff --git a/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
index 5072d82..ede9a83 100644
--- a/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.color.gschema.xml.in.in
@@ -20,5 +20,10 @@
       <_summary>The duration a printer profile is valid</_summary>
       <_description>This is the number of days after which the printer color profile is considered invalid.</_description>
     </key>
+    <key name="show-notifications" type="b">
+      <default>false</default>
+      <_summary>If notifications are allowed to be shown</_summary>
+      <_description>If notifications should be shown at session start if a profile is invalid.</_description>
+    </key>
   </schema>
 </schemalist>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0772881..9242062 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -6,6 +6,7 @@ enabled_plugins =	\
 	automount	\
 	background	\
 	clipboard	\
+	color		\
 	datetime	\
 	dummy		\
 	housekeeping    \
diff --git a/plugins/color/Makefile.am b/plugins/color/Makefile.am
new file mode 100644
index 0000000..215f634
--- /dev/null
+++ b/plugins/color/Makefile.am
@@ -0,0 +1,45 @@
+plugin_name = color
+
+plugin_LTLIBRARIES = \
+	libcolor.la
+
+libcolor_la_SOURCES = 		\
+	gsd-color-manager.c	\
+	gsd-color-manager.h	\
+	gsd-color-plugin.c	\
+	gsd-color-plugin.h
+
+libcolor_la_CPPFLAGS = \
+	-I$(top_srcdir)/gnome-settings-daemon		\
+	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+	-DBINDIR=\"$(bindir)\"				\
+	$(AM_CPPFLAGS)
+
+libcolor_la_CFLAGS = \
+	$(PLUGIN_CFLAGS)		\
+	$(COLORD_CFLAGS)		\
+	$(SETTINGS_PLUGIN_CFLAGS)	\
+	$(AM_CFLAGS)
+
+libcolor_la_LDFLAGS = 		\
+	$(GSD_PLUGIN_LDFLAGS)
+
+libcolor_la_LIBADD  = 		\
+	$(COLORD_LIBS)		\
+	$(SETTINGS_PLUGIN_LIBS)
+
+plugin_in_files = 		\
+	color.gnome-settings-plugin.in
+
+plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+EXTRA_DIST = 			\
+	$(plugin_in_files)
+
+CLEANFILES = 			\
+	$(plugin_DATA)
+
+DISTCLEANFILES =		\
+	$(plugin_DATA)
+
+ GSD_INTLTOOL_PLUGIN_RULE@
diff --git a/plugins/color/color.gnome-settings-plugin.in b/plugins/color/color.gnome-settings-plugin.in
new file mode 100644
index 0000000..7f961d4
--- /dev/null
+++ b/plugins/color/color.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=color
+IAge=0
+_Name=Color
+_Description=Color plugin
+Authors=Richard Hughes <richard hughsie com>
+Copyright=Copyright © 2011 Richard Hughes
+Website=
diff --git a/plugins/color/gsd-color-manager.c b/plugins/color/gsd-color-manager.c
new file mode 100644
index 0000000..f3a1f83
--- /dev/null
+++ b/plugins/color/gsd-color-manager.c
@@ -0,0 +1,361 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <colord.h>
+#include <libnotify/notify.h>
+
+#include "gnome-settings-profile.h"
+#include "gsd-color-manager.h"
+
+#define GSD_COLOR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_COLOR_MANAGER, GsdColorManagerPrivate))
+
+#define GCM_SESSION_NOTIFY_TIMEOUT                      30000 /* ms */
+#define GCM_SETTINGS_SHOW_NOTIFICATIONS                 "show-notifications"
+#define GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD      "recalibrate-printer-threshold"
+#define GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD      "recalibrate-display-threshold"
+
+struct GsdColorManagerPrivate
+{
+        CdClient        *client;
+        GSettings       *settings;
+};
+
+enum {
+        PROP_0,
+};
+
+static void     gsd_color_manager_class_init  (GsdColorManagerClass *klass);
+static void     gsd_color_manager_init        (GsdColorManager      *color_manager);
+static void     gsd_color_manager_finalize    (GObject             *object);
+
+G_DEFINE_TYPE (GsdColorManager, gsd_color_manager, G_TYPE_OBJECT)
+
+static gpointer manager_object = NULL;
+
+static void
+gcm_session_client_connect_cb (GObject *source_object,
+                               GAsyncResult *res,
+                               gpointer user_data)
+{
+        gboolean ret;
+        GError *error = NULL;
+        GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
+
+        /* connected */
+        g_debug ("connected to colord");
+        ret = cd_client_connect_finish (manager->priv->client, res, &error);
+        if (!ret) {
+                g_warning ("failed to connect to colord: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+gboolean
+gsd_color_manager_start (GsdColorManager *manager,
+                         GError          **error)
+{
+        GsdColorManagerPrivate *priv = manager->priv;
+
+        g_debug ("Starting color manager");
+        gnome_settings_profile_start (NULL);
+
+        cd_client_connect (priv->client,
+                           NULL,
+                           gcm_session_client_connect_cb,
+                           manager);
+
+        gnome_settings_profile_end (NULL);
+        return TRUE;
+}
+
+void
+gsd_color_manager_stop (GsdColorManager *manager)
+{
+        g_debug ("Stopping color manager");
+}
+
+static void
+gcm_session_notify_cb (NotifyNotification *notification,
+                       gchar *action,
+                       gpointer user_data)
+{
+        gboolean ret;
+        GError *error = NULL;
+        GsdColorManager *manager = GSD_COLOR_MANAGER (user_data);
+        GsdColorManagerPrivate *priv = manager->priv;
+
+        if (g_strcmp0 (action, "display") == 0) {
+                g_settings_set_uint (priv->settings,
+                                     GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD,
+                                     0);
+        } else if (g_strcmp0 (action, "printer") == 0) {
+                g_settings_set_uint (priv->settings,
+                                     GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD,
+                                     0);
+        } else if (g_strcmp0 (action, "recalibrate") == 0) {
+                ret = g_spawn_command_line_async (BINDIR "/gnome-control-center color",
+                                                  &error);
+                if (!ret) {
+                        g_warning ("failed to spawn: %s", error->message);
+                        g_error_free (error);
+                }
+        }
+}
+
+static gboolean
+gcm_session_notify_recalibrate (GsdColorManager *manager,
+                                const gchar *title,
+                                const gchar *message,
+                                CdDeviceKind kind)
+{
+        gboolean ret;
+        GError *error = NULL;
+        NotifyNotification *notification;
+        GsdColorManagerPrivate *priv = manager->priv;
+
+        /* show a bubble */
+        notification = notify_notification_new (title, message, "preferences-color");
+        notify_notification_set_timeout (notification, GCM_SESSION_NOTIFY_TIMEOUT);
+        notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+
+        /* TRANSLATORS: button: this is to open GCM */
+        notify_notification_add_action (notification,
+                                        "recalibrate",
+                                        _("Recalibrate now"),
+                                        gcm_session_notify_cb,
+                                        priv, NULL);
+
+        /* TRANSLATORS: button: this is to ignore the recalibrate notifications */
+        notify_notification_add_action (notification,
+                                        cd_device_kind_to_string (kind),
+                                        _("Ignore"),
+                                        gcm_session_notify_cb,
+                                        priv, NULL);
+
+        ret = notify_notification_show (notification, &error);
+        if (!ret) {
+                g_warning ("failed to show notification: %s",
+                           error->message);
+                g_error_free (error);
+        }
+        return ret;
+}
+
+static gchar *
+gcm_session_device_get_title (CdDevice *device)
+{
+        const gchar *vendor;
+        const gchar *model;
+
+        model = cd_device_get_model (device);
+        vendor = cd_device_get_vendor (device);
+        if (model != NULL && vendor != NULL)
+                return g_strdup_printf ("%s - %s", vendor, model);
+        if (vendor != NULL)
+                return g_strdup (vendor);
+        if (model != NULL)
+                return g_strdup (model);
+        return g_strdup (cd_device_get_id (device));
+}
+
+static void
+gcm_session_notify_device (GsdColorManager *manager, CdDevice *device)
+{
+        CdDeviceKind kind;
+        const gchar *title;
+        gchar *device_title = NULL;
+        gchar *message;
+        gint threshold;
+        glong since;
+        GsdColorManagerPrivate *priv = manager->priv;
+
+        /* TRANSLATORS: this is when the device has not been recalibrated in a while */
+        title = _("Recalibration required");
+        device_title = gcm_session_device_get_title (device);
+
+        /* check we care */
+        kind = cd_device_get_kind (device);
+        if (kind == CD_DEVICE_KIND_DISPLAY) {
+
+                /* get from GSettings */
+                threshold = g_settings_get_int (priv->settings,
+                                                GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD);
+
+                /* TRANSLATORS: this is when the display has not been recalibrated in a while */
+                message = g_strdup_printf (_("The display '%s' should be recalibrated soon."),
+                                           device_title);
+        } else {
+
+                /* get from GSettings */
+                threshold = g_settings_get_int (priv->settings,
+                                                GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD);
+
+                /* TRANSLATORS: this is when the printer has not been recalibrated in a while */
+                message = g_strdup_printf (_("The printer '%s' should be recalibrated soon."),
+                                           device_title);
+        }
+
+        /* check if we need to notify */
+        since = (g_get_real_time () / G_USEC_PER_SEC) - cd_device_get_modified (device);
+        if (threshold > since)
+                gcm_session_notify_recalibrate (manager, title, message, kind);
+        g_free (device_title);
+        g_free (message);
+}
+
+static void
+gcm_session_device_added_notify_cb (CdClient *client,
+                                    CdDevice *device,
+                                    GsdColorManager *manager)
+{
+        CdDeviceKind kind;
+        CdProfile *profile;
+        const gchar *filename;
+        gchar *basename = NULL;
+        gboolean allow_notifications;
+        GsdColorManagerPrivate *priv = manager->priv;
+
+        /* check we care */
+        kind = cd_device_get_kind (device);
+        if (kind != CD_DEVICE_KIND_DISPLAY &&
+            kind != CD_DEVICE_KIND_PRINTER)
+                return;
+
+        /* ensure we have a profile */
+        profile = cd_device_get_default_profile (device);
+        if (profile == NULL) {
+                g_debug ("no profile set for %s", cd_device_get_id (device));
+                goto out;
+        }
+
+        /* ensure it's a profile generated by us */
+        filename = cd_profile_get_filename (profile);
+        basename = g_path_get_basename (filename);
+        if (!g_str_has_prefix (basename, "GCM")) {
+                g_debug ("not a GCM profile for %s: %s",
+                         cd_device_get_id (device), filename);
+                goto out;
+        }
+
+        /* do we allow notifications */
+        allow_notifications = g_settings_get_boolean (priv->settings,
+                                                      GCM_SETTINGS_SHOW_NOTIFICATIONS);
+        if (!allow_notifications)
+                goto out;
+
+        /* handle device */
+        gcm_session_notify_device (manager, device);
+out:
+        g_free (basename);
+}
+
+static void
+gsd_color_manager_set_property (GObject        *object,
+                                guint           prop_id,
+                                const GValue   *value,
+                                GParamSpec     *pspec)
+{
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsd_color_manager_get_property (GObject        *object,
+                               guint           prop_id,
+                               GValue         *value,
+                               GParamSpec     *pspec)
+{
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsd_color_manager_dispose (GObject *object)
+{
+        G_OBJECT_CLASS (gsd_color_manager_parent_class)->dispose (object);
+}
+
+static void
+gsd_color_manager_class_init (GsdColorManagerClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsd_color_manager_get_property;
+        object_class->set_property = gsd_color_manager_set_property;
+        object_class->dispose = gsd_color_manager_dispose;
+        object_class->finalize = gsd_color_manager_finalize;
+
+        g_type_class_add_private (klass, sizeof (GsdColorManagerPrivate));
+}
+
+static void
+gsd_color_manager_init (GsdColorManager *manager)
+{
+        GsdColorManagerPrivate *priv;
+        priv = manager->priv = GSD_COLOR_MANAGER_GET_PRIVATE (manager);
+
+        priv->settings = g_settings_new ("org.gnome.settings-daemon.plugins.color");
+        priv->client = cd_client_new ();
+        g_signal_connect (priv->client, "device-added",
+                          G_CALLBACK (gcm_session_device_added_notify_cb),
+                          manager);
+}
+
+static void
+gsd_color_manager_finalize (GObject *object)
+{
+        GsdColorManager *manager;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSD_IS_COLOR_MANAGER (object));
+
+        manager = GSD_COLOR_MANAGER (object);
+
+        g_return_if_fail (manager->priv != NULL);
+
+        g_object_unref (manager->priv->settings);
+        g_object_unref (manager->priv->client);
+
+        G_OBJECT_CLASS (gsd_color_manager_parent_class)->finalize (object);
+}
+
+GsdColorManager *
+gsd_color_manager_new (void)
+{
+        if (manager_object != NULL) {
+                g_object_ref (manager_object);
+        } else {
+                manager_object = g_object_new (GSD_TYPE_COLOR_MANAGER, NULL);
+                g_object_add_weak_pointer (manager_object,
+                                           (gpointer *) &manager_object);
+        }
+
+        return GSD_COLOR_MANAGER (manager_object);
+}
diff --git a/plugins/color/gsd-color-manager.h b/plugins/color/gsd-color-manager.h
new file mode 100644
index 0000000..5180f3b
--- /dev/null
+++ b/plugins/color/gsd-color-manager.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_COLOR_MANAGER_H
+#define __GSD_COLOR_MANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_COLOR_MANAGER         (gsd_color_manager_get_type ())
+#define GSD_COLOR_MANAGER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_COLOR_MANAGER, GsdColorManager))
+#define GSD_COLOR_MANAGER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_COLOR_MANAGER, GsdColorManagerClass))
+#define GSD_IS_COLOR_MANAGER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_COLOR_MANAGER))
+#define GSD_IS_COLOR_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_COLOR_MANAGER))
+#define GSD_COLOR_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_COLOR_MANAGER, GsdColorManagerClass))
+
+typedef struct GsdColorManagerPrivate GsdColorManagerPrivate;
+
+typedef struct
+{
+        GObject                     parent;
+        GsdColorManagerPrivate *priv;
+} GsdColorManager;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} GsdColorManagerClass;
+
+GType                   gsd_color_manager_get_type            (void);
+
+GsdColorManager *       gsd_color_manager_new                 (void);
+gboolean                gsd_color_manager_start               (GsdColorManager *manager,
+                                                               GError         **error);
+void                    gsd_color_manager_stop                (GsdColorManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_COLOR_MANAGER_H */
diff --git a/plugins/color/gsd-color-plugin.c b/plugins/color/gsd-color-plugin.c
new file mode 100644
index 0000000..e5c2392
--- /dev/null
+++ b/plugins/color/gsd-color-plugin.c
@@ -0,0 +1,111 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+#include "gsd-color-plugin.h"
+#include "gsd-color-manager.h"
+
+struct GsdColorPluginPrivate {
+        GsdColorManager *manager;
+};
+
+#define GSD_COLOR_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_COLOR_PLUGIN, GsdColorPluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER (GsdColorPlugin, gsd_color_plugin)
+
+static void
+gsd_color_plugin_init (GsdColorPlugin *plugin)
+{
+        plugin->priv = GSD_COLOR_PLUGIN_GET_PRIVATE (plugin);
+
+        g_debug ("GsdColorPlugin initializing");
+
+        plugin->priv->manager = gsd_color_manager_new ();
+}
+
+static void
+gsd_color_plugin_finalize (GObject *object)
+{
+        GsdColorPlugin *plugin;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSD_IS_COLOR_PLUGIN (object));
+
+        g_debug ("GsdColorPlugin finalizing");
+
+        plugin = GSD_COLOR_PLUGIN (object);
+
+        g_return_if_fail (plugin->priv != NULL);
+
+        if (plugin->priv->manager != NULL) {
+                g_object_unref (plugin->priv->manager);
+        }
+
+        G_OBJECT_CLASS (gsd_color_plugin_parent_class)->finalize (object);
+}
+
+static void
+impl_activate (GnomeSettingsPlugin *plugin)
+{
+        gboolean res;
+        GError  *error;
+
+        g_debug ("Activating color plugin");
+
+        error = NULL;
+        res = gsd_color_manager_start (GSD_COLOR_PLUGIN (plugin)->priv->manager, &error);
+        if (! res) {
+                g_warning ("Unable to start color manager: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+static void
+impl_deactivate (GnomeSettingsPlugin *plugin)
+{
+        g_debug ("Deactivating color plugin");
+        gsd_color_manager_stop (GSD_COLOR_PLUGIN (plugin)->priv->manager);
+}
+
+static void
+gsd_color_plugin_class_init (GsdColorPluginClass *klass)
+{
+        GObjectClass           *object_class = G_OBJECT_CLASS (klass);
+        GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
+
+        object_class->finalize = gsd_color_plugin_finalize;
+
+        plugin_class->activate = impl_activate;
+        plugin_class->deactivate = impl_deactivate;
+
+        g_type_class_add_private (klass, sizeof (GsdColorPluginPrivate));
+}
+
+static void
+gsd_color_plugin_class_finalize (GsdColorPluginClass *klass)
+{
+}
+
diff --git a/plugins/color/gsd-color-plugin.h b/plugins/color/gsd-color-plugin.h
new file mode 100644
index 0000000..3b0a919
--- /dev/null
+++ b/plugins/color/gsd-color-plugin.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2011 Richard Hughes <richard hughsie com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_COLOR_PLUGIN_H__
+#define __GSD_COLOR_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_COLOR_PLUGIN                (gsd_color_plugin_get_type ())
+#define GSD_COLOR_PLUGIN(o)                  (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_COLOR_PLUGIN, GsdColorPlugin))
+#define GSD_COLOR_PLUGIN_CLASS(k)            (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_COLOR_PLUGIN, GsdColorPluginClass))
+#define GSD_IS_COLOR_PLUGIN(o)               (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_COLOR_PLUGIN))
+#define GSD_IS_COLOR_PLUGIN_CLASS(k)         (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_COLOR_PLUGIN))
+#define GSD_COLOR_PLUGIN_GET_CLASS(o)        (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_COLOR_PLUGIN, GsdColorPluginClass))
+
+typedef struct GsdColorPluginPrivate GsdColorPluginPrivate;
+
+typedef struct
+{
+        GnomeSettingsPlugin    parent;
+        GsdColorPluginPrivate *priv;
+} GsdColorPlugin;
+
+typedef struct
+{
+        GnomeSettingsPluginClass parent_class;
+} GsdColorPluginClass;
+
+GType   gsd_color_plugin_get_type            (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_COLOR_PLUGIN_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6101b89..2e49096 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,8 @@ plugins/automount/gsd-automount-plugin.c
 plugins/automount/gsd-autorun.c
 [type: gettext/ini]plugins/background/background.gnome-settings-plugin.in
 [type: gettext/ini]plugins/clipboard/clipboard.gnome-settings-plugin.in
+[type: gettext/ini]plugins/color/color.gnome-settings-plugin.in
+plugins/color/gsd-color-manager.c
 [type: gettext/ini]plugins/dummy/dummy.gnome-settings-plugin.in
 plugins/housekeeping/gsd-disk-space.c
 plugins/housekeeping/gsd-ldsm-dialog.c



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