[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: Load the inhibit proxy interface in an async callback

noreply at xfce.org noreply at xfce.org
Tue May 24 14:34:03 CEST 2016


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 92189ef3ac1ff909591a4662d520f28f672793a0
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Tue May 24 15:31:56 2016 +0300

    Load the inhibit proxy interface in an async callback
    
    Otherwise we may end up waiting for another part of xfpm that
    hasn't loaded yet.
---
 .../power-manager-plugin/power-manager-button.c    | 41 +++++++++++++---------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/panel-plugins/power-manager-plugin/power-manager-button.c b/panel-plugins/power-manager-plugin/power-manager-button.c
index 9f0fa6d..780b713 100644
--- a/panel-plugins/power-manager-plugin/power-manager-button.c
+++ b/panel-plugins/power-manager-plugin/power-manager-button.c
@@ -910,6 +910,22 @@ power_manager_button_class_init (PowerManagerButtonClass *klass)
 }
 
 static void
+inhibit_proxy_ready_cb (GObject *source_object,
+                        GAsyncResult *res,
+                        gpointer user_data)
+{
+    GError *error = NULL;
+    PowerManagerButton *button = POWER_MANAGER_BUTTON (user_data);
+
+    button->priv->inhibit_proxy = g_dbus_proxy_new_finish (res, &error);
+    if (error != NULL)
+    {
+        g_warning ("error getting inhibit proxy: %s", error->message);
+        g_clear_error (&error);
+    }
+}
+
+static void
 power_manager_button_init (PowerManagerButton *button)
 {
     GError *error = NULL;
@@ -938,22 +954,15 @@ power_manager_button_init (PowerManagerButton *button)
         button->priv->channel = xfconf_channel_get ("xfce4-power-manager");
     }
 
-    button->priv->inhibit_proxy = g_dbus_proxy_new_sync (g_bus_get_sync (G_BUS_TYPE_SESSION,
-                                                                         NULL,
-                                                                         NULL),
-                                                         G_DBUS_PROXY_FLAGS_NONE,
-                                                         NULL,
-                                                         "org.freedesktop.PowerManagement",
-                                                         "/org/freedesktop/PowerManagement/Inhibit",
-                                                         "org.freedesktop.PowerManagement.Inhibit",
-                                                         NULL,
-                                                         &error);
-
-    if (error != NULL)
-    {
-        g_warning ("error getting inhibit proxy: %s", error->message);
-        g_clear_error (&error);
-    }
+    g_dbus_proxy_new (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
+                      G_DBUS_PROXY_FLAGS_NONE,
+                      NULL,
+                      "org.freedesktop.PowerManagement",
+                      "/org/freedesktop/PowerManagement/Inhibit",
+                      "org.freedesktop.PowerManagement.Inhibit",
+                      NULL,
+                      inhibit_proxy_ready_cb,
+                      button);
 
     /* Sane defaults for the systray and panel icon */
 #ifdef XFCE_PLUGIN

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list