[gnome-settings-daemon] print-notifications: Connect to message bus asynchronously



commit 727f5998785428a5d9215ba37b5a3f3f57c4f4a0
Author: Marek Kasik <mkasik redhat com>
Date:   Wed Jul 31 14:53:41 2013 +0200

    print-notifications: Connect to message bus asynchronously

 .../gsd-print-notifications-manager.c              |   43 ++++++++++++++-----
 1 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/plugins/print-notifications/gsd-print-notifications-manager.c 
b/plugins/print-notifications/gsd-print-notifications-manager.c
index 3615c82..379d67f 100644
--- a/plugins/print-notifications/gsd-print-notifications-manager.c
+++ b/plugins/print-notifications/gsd-print-notifications-manager.c
@@ -1058,6 +1058,33 @@ cups_connection_test (gpointer user_data)
         }
 }
 
+static void
+gsd_print_notifications_manager_got_dbus_connection (GObject      *source_object,
+                                                     GAsyncResult *res,
+                                                     gpointer      user_data)
+{
+        GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) user_data;
+        GError                       *error = NULL;
+
+        manager->priv->cups_bus_connection = g_bus_get_finish (res, &error);
+
+        if (manager->priv->cups_bus_connection != NULL) {
+                g_dbus_connection_signal_subscribe (manager->priv->cups_bus_connection,
+                                                    NULL,
+                                                    CUPS_DBUS_INTERFACE,
+                                                    NULL,
+                                                    CUPS_DBUS_PATH,
+                                                    NULL,
+                                                    0,
+                                                    on_cups_notification,
+                                                    manager,
+                                                    NULL);
+        } else {
+                g_warning ("Connection to message bus failed: %s", error->message);
+                g_error_free (error);
+        }
+}
+
 static gboolean
 gsd_print_notifications_manager_start_idle (gpointer data)
 {
@@ -1069,18 +1096,10 @@ gsd_print_notifications_manager_start_idle (gpointer data)
 
         cups_connection_test (manager);
 
-        manager->priv->cups_bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
-
-        g_dbus_connection_signal_subscribe (manager->priv->cups_bus_connection,
-                                            NULL,
-                                            CUPS_DBUS_INTERFACE,
-                                            NULL,
-                                            CUPS_DBUS_PATH,
-                                            NULL,
-                                            0,
-                                            on_cups_notification,
-                                            manager,
-                                            NULL);
+        g_bus_get (G_BUS_TYPE_SYSTEM,
+                   NULL,
+                   gsd_print_notifications_manager_got_dbus_connection,
+                   data);
 
         scp_handler (manager, TRUE);
 


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