[gnome-color-manager: 5/7] Port (again) to the new API for GDBus



commit 13500a6cc6b2e8f052f252cdef4eeb4886392dcc
Author: Richard Hughes <richard hughsie com>
Date:   Sat Jun 12 09:11:55 2010 +0100

    Port (again) to the new API for GDBus

 configure.ac      |    2 +-
 src/gcm-inspect.c |   75 ++++++++++++++++++----------------------------------
 2 files changed, 27 insertions(+), 50 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3857282..16f6b0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ GTK_REQUIRED=2.90.0
 GNOMEDESKTOP_REQUIRED=2.14.0
 VTE_REQUIRED=0.25.1
 CANBERRA_REQUIRED=0.10
-GIO_REQUIRED=2.25.8
+GIO_REQUIRED=2.25.9
 
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
diff --git a/src/gcm-inspect.c b/src/gcm-inspect.c
index 3f65e00..d05bedb 100644
--- a/src/gcm-inspect.c
+++ b/src/gcm-inspect.c
@@ -492,17 +492,31 @@ out:
 }
 
 /**
- * gcm_inspect_proxy_appeared_cb:
+ * gcm_inspect_get_properties:
  **/
-static void
-gcm_inspect_proxy_appeared_cb (GDBusConnection *connection,
-                               const gchar *name,
-                               const gchar *name_owner,
-                               GDBusProxy *proxy,
-                               GMainLoop *loop)
+static gboolean
+gcm_inspect_get_properties (void)
 {
+	GDBusProxy *proxy;
+	GError *error = NULL;
 	GVariant *result;
 
+	/* connect to the named instance */
+	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+					       G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+					       NULL,
+					       GCM_DBUS_SERVICE,
+					       GCM_DBUS_PATH,
+					       GCM_DBUS_INTERFACE,
+					       NULL,
+					       &error);
+	if (proxy == NULL) {
+		/* TRANSLATORS: the DBus method failed */
+		g_print ("%s: %s\n", _("The request failed"), error->message);
+		g_error_free (error);
+		goto out;
+	}
+
 	/* get rendering intents */
 	result = g_dbus_proxy_get_cached_property (proxy, "RenderingIntentDisplay");
 	if (result != NULL) {
@@ -518,58 +532,21 @@ gcm_inspect_proxy_appeared_cb (GDBusConnection *connection,
 	}
 
 	/* get colorspaces */
-	result = g_dbus_proxy_get_cached_property (proxy, "RenderingIntentDisplay");
+	result = g_dbus_proxy_get_cached_property (proxy, "ColorspaceRgb");
 	if (result != NULL) {
 		/* TRANSLATORS: this is the rendering intent of the output */
 		g_print ("%s\t%s\n", _("RGB Colorspace:"), g_variant_get_string (result, NULL));
 		g_variant_unref (result);
 	}
-	result = g_dbus_proxy_get_cached_property (proxy, "RenderingIntentSoftproof");
+	result = g_dbus_proxy_get_cached_property (proxy, "ColorspaceCmyk");
 	if (result != NULL) {
 		/* TRANSLATORS: this is the rendering intent of the printer */
 		g_print ("%s\t%s\n", _("CMYK Colorspace:"), g_variant_get_string (result, NULL));
 		g_variant_unref (result);
 	}
-
-	g_main_loop_quit (loop);
-}
-
-/**
- * gcm_inspect_proxy_vanished_cb:
- **/
-static void
-gcm_inspect_proxy_vanished_cb (GDBusConnection *connection,
-                               const gchar *name,
-                               GMainLoop *loop)
-{
-	/* TRANSLATORS: the DBus method failed */
-	g_print ("%s\n", _("The request failed"));
-	g_main_loop_quit (loop);
-}
-
-/**
- * gcm_inspect_get_properties:
- **/
-static gboolean
-gcm_inspect_get_properties (void)
-{
-	guint proxy_id;
-	GMainLoop *loop = NULL;
-
-	loop = g_main_loop_new (NULL, FALSE);
-	proxy_id = g_bus_watch_proxy (G_BUS_TYPE_SESSION,
-				      GCM_DBUS_SERVICE,
-				      G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
-				      GCM_DBUS_PATH,
-				      GCM_DBUS_INTERFACE,
-				      G_TYPE_DBUS_PROXY,
-				      G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
-				      (GBusProxyAppearedCallback) gcm_inspect_proxy_appeared_cb,
-				      (GBusProxyVanishedCallback) gcm_inspect_proxy_vanished_cb,
-				      loop, /* user_data */
-				      NULL); /* user_data_free_func */
-	g_main_loop_run (loop);
-	g_bus_unwatch_proxy (proxy_id);
+out:
+	if (proxy != NULL)
+		g_object_unref (proxy);
 	return TRUE;
 }
 



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