[gnome-color-manager/colord: 28/72] Re-enable the re-profiling notifications now colord supports modified



commit 4d4c1fa67c7c8dd1a624c837bc061b4337a69c8d
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jan 18 12:49:22 2011 +0000

    Re-enable the re-profiling notifications now colord supports modified

 autogen.sh        |    2 -
 configure.ac      |    2 +-
 src/Makefile.am   |    2 +-
 src/gcm-session.c |   81 ++++++++++++++++++++++++++++++++++++++---------------
 4 files changed, 60 insertions(+), 27 deletions(-)
---
diff --git a/autogen.sh b/autogen.sh
index ba87bc0..16bbd82 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -23,6 +23,4 @@ which gnome-autogen.sh || {
     exit 1
 }
 
-(cd $srcdir && gtkdocize) || exit 1
-
 REQUIRED_AUTOMAKE_VERSION=1.7 GNOME_DATADIR="$gnome_datadir" USE_GNOME2_MACROS=1 USE_COMMON_DOC_BUILD=yes . gnome-autogen.sh
diff --git a/configure.ac b/configure.ac
index ea9599c..a8d8463 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,7 +112,7 @@ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 2.91.0)
 PKG_CHECK_MODULES(GUDEV, gudev-1.0)
 PKG_CHECK_MODULES(LCMS, lcms2)
 PKG_CHECK_MODULES(X11, x11)
-PKG_CHECK_MODULES(COLORD, colord)
+PKG_CHECK_MODULES(COLORD, colord >= 0.1.1)
 PKG_CHECK_MODULES(SETTINGS_DAEMON, gnome-settings-daemon)
 PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.9, has_new_libusb=yes, has_new_libusb=no)
 if test x$has_new_libusb = xyes; then
diff --git a/src/Makefile.am b/src/Makefile.am
index e21ff2b..05cec59 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,7 +119,7 @@ bin_PROGRAMS =						\
 if HAVE_EXIV
 libexec_PROGRAMS = gcm-helper-exiv
 gcm_helper_exiv_SOURCES = gcm-helper-exiv.cpp
-gcm_helper_exiv_LDADD = $(EXIV_LIBS)
+gcm_helper_exiv_LDADD = $(EXIV_LIBS) $(GLIB_LIBS)
 gcm_helper_exiv_CXXFLAGS = -Wall
 endif
 
diff --git a/src/gcm-session.c b/src/gcm-session.c
index e48c6fa..4e4bc52 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -45,7 +45,15 @@ static GDBusConnection *connection = NULL;
 
 #define GCM_SESSION_NOTIFY_TIMEOUT	30000 /* ms */
 
-#if 0
+/**
+ * cd_device_get_title:
+ **/
+static const gchar *
+cd_device_get_title (CdDevice *device)
+{
+	return "FIXME!";
+}
+
 /**
  * gcm_session_notify_cb:
  **/
@@ -56,11 +64,16 @@ gcm_session_notify_cb (NotifyNotification *notification, gchar *action, gpointer
 	GError *error = NULL;
 
 	if (g_strcmp0 (action, "display") == 0) {
-		g_settings_set_int (settings, GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD, 0);
+		g_settings_set_int (settings,
+				    GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD,
+				    0);
 	} else if (g_strcmp0 (action, "printer") == 0) {
-		g_settings_set_int (settings, GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD, 0);
+		g_settings_set_int (settings,
+				    GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD,
+				    0);
 	} else if (g_strcmp0 (action, "recalibrate") == 0) {
-		ret = g_spawn_command_line_async ("gcm-prefs", &error);
+		ret = g_spawn_command_line_async ("gnome-control-center color",
+						  &error);
 		if (!ret) {
 			g_warning ("failed to spawn: %s", error->message);
 			g_error_free (error);
@@ -72,7 +85,9 @@ gcm_session_notify_cb (NotifyNotification *notification, gchar *action, gpointer
  * gcm_session_notify_recalibrate:
  **/
 static gboolean
-gcm_session_notify_recalibrate (const gchar *title, const gchar *message, CdDeviceKind kind)
+gcm_session_notify_recalibrate (const gchar *title,
+				const gchar *message,
+				CdDeviceKind kind)
 {
 	gboolean ret;
 	GError *error = NULL;
@@ -84,14 +99,23 @@ gcm_session_notify_recalibrate (const gchar *title, const gchar *message, CdDevi
 	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, NULL, NULL);
+	notify_notification_add_action (notification,
+					"recalibrate",
+					_("Recalibrate now"),
+					gcm_session_notify_cb,
+					NULL, 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, NULL, NULL);
+	notify_notification_add_action (notification,
+					cd_device_kind_to_string (kind),
+					_("Ignore"),
+					gcm_session_notify_cb,
+					NULL, NULL);
 
 	ret = notify_notification_show (notification, &error);
 	if (!ret) {
-		g_warning ("failed to show notification: %s", error->message);
+		g_warning ("failed to show notification: %s",
+			   error->message);
 		g_error_free (error);
 	}
 	return ret;
@@ -121,36 +145,41 @@ gcm_session_notify_device (CdDevice *device)
 	if (kind == CD_DEVICE_KIND_DISPLAY) {
 
 		/* get from GSettings */
-		threshold = g_settings_get_int (settings, GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD);
+		threshold = g_settings_get_int (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."), cd_device_get_title (device));
+		message = g_strdup_printf (_("The display '%s' should be recalibrated soon."),
+					   cd_device_get_title (device));
 	} else {
 
 		/* get from GSettings */
-		threshold = g_settings_get_int (settings, GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD);
+		threshold = g_settings_get_int (settings,
+						GCM_SETTINGS_RECALIBRATE_DISPLAY_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."), cd_device_get_title (device));
+		message = g_strdup_printf (_("The printer '%s' should be recalibrated soon."),
+					   cd_device_get_title (device));
 	}
 
 	/* check if we need to notify */
-	since = timeval.tv_sec - cd_device_get_modified_time (device);
+	since = timeval.tv_sec - cd_device_get_modified (device);
 	if (threshold > since)
 		gcm_session_notify_recalibrate (title, message, kind);
 	g_free (message);
 }
-#endif
 
-#if 0
 /**
- * gcm_session_added_cb:
+ * gcm_session_device_added_notify_cb:
  **/
 static void
-gcm_session_added_cb (CdClient *client_, CdDevice *device, gpointer user_data)
+gcm_session_device_added_notify_cb (CdClient *client_,
+				    CdDevice *device,
+				    gpointer user_data)
 {
 	CdDeviceKind kind;
-	const gchar *profile;
+	CdProfile *profile;
+	const gchar *filename;
 	gchar *basename = NULL;
 	gboolean allow_notifications;
 
@@ -161,21 +190,24 @@ gcm_session_added_cb (CdClient *client_, CdDevice *device, gpointer user_data)
 		return;
 
 	/* ensure we have a profile */
-	profile = cd_device_get_default_profile_filename (device);
+	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 */
-	basename = g_path_get_basename (profile);
+	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), profile);
+		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 (settings, GCM_SETTINGS_SHOW_NOTIFICATIONS);
+	allow_notifications = g_settings_get_boolean (settings,
+						      GCM_SETTINGS_SHOW_NOTIFICATIONS);
 	if (!allow_notifications)
 		goto out;
 
@@ -184,7 +216,6 @@ gcm_session_added_cb (CdClient *client_, CdDevice *device, gpointer user_data)
 out:
 	g_free (basename);
 }
-#endif
 
 /**
  * gcm_session_get_profile_for_window:
@@ -826,6 +857,10 @@ main (int argc, char *argv[])
 
 	/* monitor daemon */
 	client = cd_client_new ();
+	g_signal_connect (client, "device-added",
+			  G_CALLBACK (gcm_session_device_added_notify_cb),
+			  NULL);
+
 	ret = cd_client_connect_sync (client, NULL, &error);
 	if (!ret) {
 		g_warning ("failed to connect to colord: %s", error->message);



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