[totem/gnome-2-32] [scrsaver] Adapt to GDBus API change
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem/gnome-2-32] [scrsaver] Adapt to GDBus API change
- Date: Wed, 4 Aug 2010 15:31:16 +0000 (UTC)
commit 6c93ed2a0590b5ed1964ca599fc57f58e113bd9b
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Jun 13 15:55:27 2010 +0200
[scrsaver] Adapt to GDBus API change
The g_bus_watch_proxy/g_bus_unwatch_proxy API has been removed.
Instead, it is now possible to use well-known names for GBusProxy.
https://bugzilla.gnome.org/show_bug.cgi?id=621445
lib/totem-scrsaver.c | 77 ++++++++++++++++++++++++++------------------------
1 files changed, 40 insertions(+), 37 deletions(-)
---
diff --git a/lib/totem-scrsaver.c b/lib/totem-scrsaver.c
index 8622079..cbda040 100644
--- a/lib/totem-scrsaver.c
+++ b/lib/totem-scrsaver.c
@@ -62,7 +62,6 @@ struct TotemScrsaverPrivate {
GDBusProxy *gs_proxy;
gboolean have_screensaver_dbus;
- guint watch_id;
guint32 cookie;
gboolean old_dbus_api;
@@ -213,65 +212,69 @@ screensaver_disable_dbus (TotemScrsaver *scr)
}
static void
-screensaver_dbus_appeared_cb (GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
- GDBusProxy *proxy,
- gpointer user_data)
+screensaver_update_dbus_presence (TotemScrsaver *scr)
{
- TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
TotemScrsaverPrivate *priv = scr->priv;
+ gchar *name_owner;
- priv->gs_proxy = g_object_ref (proxy);
-
- priv->have_screensaver_dbus = TRUE;
+ name_owner = g_dbus_proxy_get_name_owner (priv->gs_proxy);
+ if (name_owner) {
+ priv->have_screensaver_dbus = TRUE;
+ g_free (name_owner);
+ } else {
+ priv->have_screensaver_dbus = FALSE;
+ }
}
static void
-screensaver_dbus_disappeared_cb (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+screensaver_dbus_owner_changed_cb (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
{
TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
- TotemScrsaverPrivate *priv = scr->priv;
- if (priv->gs_proxy) {
- g_object_unref (priv->gs_proxy);
- priv->gs_proxy = NULL;
- }
-
- priv->have_screensaver_dbus = FALSE;
+ screensaver_update_dbus_presence (scr);
}
static void
-screensaver_init_dbus (TotemScrsaver *scr)
+screensaver_dbus_proxy_new_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
TotemScrsaverPrivate *priv = scr->priv;
- priv->watch_id = g_bus_watch_proxy (G_BUS_TYPE_SESSION,
- GS_SERVICE,
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- GS_PATH,
- GS_INTERFACE,
- G_TYPE_DBUS_PROXY,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
- G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
- screensaver_dbus_appeared_cb,
- screensaver_dbus_disappeared_cb,
- scr, NULL);
+ priv->gs_proxy = g_dbus_proxy_new_for_bus_finish (result, NULL);
+ if (!priv->gs_proxy)
+ return;
+
+ screensaver_update_dbus_presence (scr);
+
+ g_signal_connect (priv->gs_proxy, "notify::g-name-owner",
+ G_CALLBACK (screensaver_dbus_owner_changed_cb),
+ scr);
}
static void
-screensaver_finalize_dbus (TotemScrsaver *scr)
+screensaver_init_dbus (TotemScrsaver *scr)
{
- TotemScrsaverPrivate *priv = scr->priv;
+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL,
+ GS_SERVICE,
+ GS_PATH,
+ GS_INTERFACE,
+ NULL,
+ screensaver_dbus_proxy_new_cb,
+ scr);
+}
+static void
+screensaver_finalize_dbus (TotemScrsaver *scr)
+{
if (scr->priv->gs_proxy) {
g_object_unref (scr->priv->gs_proxy);
}
-
- if (priv->watch_id > 0)
- g_bus_unwatch_proxy (priv->watch_id);
}
#ifdef GDK_WINDOWING_X11
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]