void-packages/srcpkgs/xfce4-power-manager/patches/0002-Load-the-inhibit-proxy...

74 lines
3.0 KiB
Diff

From 92189ef3ac1ff909591a4662d520f28f672793a0 Mon Sep 17 00:00:00 2001
From: Eric Koegel <eric.koegel@gmail.com>
Date: Tue, 24 May 2016 15:31:56 +0300
Subject: [PATCH] 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 panel-plugins/power-manager-plugin/power-manager-button.c panel-plugins/power-manager-plugin/power-manager-button.c
index 9f0fa6d..780b713 100644
--- panel-plugins/power-manager-plugin/power-manager-button.c
+++ 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
--
2.4.11