[gnome-settings-daemon/wip/muktupavels/flashback: 13/15] media-keys: watch org.gnome.Shell.KeyGrabber dbus name
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/muktupavels/flashback: 13/15] media-keys: watch org.gnome.Shell.KeyGrabber dbus name
- Date: Thu, 19 Feb 2015 22:23:46 +0000 (UTC)
commit 091c3e3f15197d6426e6a037ed149c6a27cae81d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Dec 14 00:29:08 2014 +0200
media-keys: watch org.gnome.Shell.KeyGrabber dbus name
plugins/media-keys/Makefile.am | 8 ++--
plugins/media-keys/gsd-media-keys-manager.c | 54 ++++++++++++++++---
...yGrabber.xml => org.gnome.Shell.KeyGrabber.xml} | 2 +-
3 files changed, 50 insertions(+), 14 deletions(-)
---
diff --git a/plugins/media-keys/Makefile.am b/plugins/media-keys/Makefile.am
index d8f2e6a..6ab3c6e 100644
--- a/plugins/media-keys/Makefile.am
+++ b/plugins/media-keys/Makefile.am
@@ -22,11 +22,11 @@ gsd-marshal.h: gsd-marshal.list
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=gsd_marshal $< --header --internal > $@
shell-key-grabber.c: shell-key-grabber.h
-shell-key-grabber.h: Makefile.am org.gnome.ShellKeyGrabber.xml
- gdbus-codegen --interface-prefix org.gnome. \
+shell-key-grabber.h: Makefile.am org.gnome.Shell.KeyGrabber.xml
+ gdbus-codegen --interface-prefix org.gnome.Shell \
--generate-c-code shell-key-grabber \
--c-namespace Shell \
- $(srcdir)/org.gnome.ShellKeyGrabber.xml
+ $(srcdir)/org.gnome.Shell.KeyGrabber.xml
libmedia_keys_la_SOURCES = \
gsd-media-keys-plugin.c \
@@ -122,7 +122,7 @@ gsd_test_media_keys_LDADD = \
EXTRA_DIST = \
gsd-marshal.list \
README.media-keys-API \
- org.gnome.ShellKeyGrabber.xml \
+ org.gnome.Shell.KeyGrabber.xml \
$(plugin_in_files)
CLEANFILES = \
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 227da6f..7738bd2 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -74,6 +74,9 @@
#define SHELL_DBUS_NAME "org.gnome.Shell"
#define SHELL_DBUS_PATH "/org/gnome/Shell"
+#define SHELL_KEY_GRABBER_DBUS_NAME "org.gnome.Shell.KeyGrabber"
+#define SHELL_KEY_GRABBER_DBUS_PATH "/org/gnome/Shell/KeyGrabber"
+
#define CUSTOM_BINDING_SCHEMA SETTINGS_BINDING_DIR ".custom-keybinding"
#define SHELL_GRABBER_RETRY_INTERVAL 1
@@ -172,6 +175,7 @@ struct GsdMediaKeysManagerPrivate
GsdShellOSD *shell_osd_proxy;
/* Shell KeyGrabber stuff */
+ gint key_grabber_id;
ShellKeyGrabber *key_grabber;
GCancellable *grab_cancellable;
@@ -2315,13 +2319,6 @@ shell_presence_changed (GsdMediaKeysManager *manager)
name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (manager->priv->shell_proxy));
if (name_owner) {
- shell_key_grabber_proxy_new_for_bus (G_BUS_TYPE_SESSION,
- 0,
- name_owner,
- SHELL_DBUS_PATH,
- manager->priv->grab_cancellable,
- on_key_grabber_ready, manager);
-
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
0, NULL,
name_owner,
@@ -2331,8 +2328,6 @@ shell_presence_changed (GsdMediaKeysManager *manager)
on_screencast_proxy_ready, manager);
g_free (name_owner);
} else {
- g_ptr_array_set_size (manager->priv->keys, 0);
- g_clear_object (&manager->priv->key_grabber);
g_clear_object (&manager->priv->screencast_proxy);
}
}
@@ -2554,6 +2549,35 @@ inhibit_done (GObject *source,
}
static void
+on_shell_key_grabber_name_appeared (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ GsdMediaKeysManager *manager = GSD_MEDIA_KEYS_MANAGER (user_data);
+
+ shell_key_grabber_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+ 0,
+ SHELL_KEY_GRABBER_DBUS_NAME,
+ SHELL_KEY_GRABBER_DBUS_PATH,
+ manager->priv->grab_cancellable,
+ on_key_grabber_ready,
+ manager);
+}
+
+static void
+on_shell_key_grabber_name_vanished (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ GsdMediaKeysManager *manager = GSD_MEDIA_KEYS_MANAGER (user_data);
+
+ if (manager->priv->keys != NULL)
+ g_ptr_array_set_size (manager->priv->keys, 0);
+ g_clear_object (&manager->priv->key_grabber);
+}
+
+static void
gsd_media_keys_manager_init (GsdMediaKeysManager *manager)
{
GError *error;
@@ -2604,6 +2628,13 @@ gsd_media_keys_manager_init (GsdMediaKeysManager *manager)
inhibit_done,
manager);
+ manager->priv->key_grabber_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ SHELL_KEY_GRABBER_DBUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_shell_key_grabber_name_appeared,
+ on_shell_key_grabber_name_vanished,
+ manager,
+ NULL);
}
static void
@@ -2626,6 +2657,11 @@ gsd_media_keys_manager_finalize (GObject *object)
g_clear_object (&media_keys_manager->priv->logind_proxy);
g_clear_object (&media_keys_manager->priv->screen_saver_proxy);
+ if (media_keys_manager->priv->key_grabber_id != 0) {
+ g_bus_unwatch_name (media_keys_manager->priv->key_grabber_id);
+ media_keys_manager->priv->key_grabber_id = 0;
+ }
+
G_OBJECT_CLASS (gsd_media_keys_manager_parent_class)->finalize (object);
}
diff --git a/plugins/media-keys/org.gnome.ShellKeyGrabber.xml
b/plugins/media-keys/org.gnome.Shell.KeyGrabber.xml
similarity index 94%
rename from plugins/media-keys/org.gnome.ShellKeyGrabber.xml
rename to plugins/media-keys/org.gnome.Shell.KeyGrabber.xml
index a245481..ddd6d82 100644
--- a/plugins/media-keys/org.gnome.ShellKeyGrabber.xml
+++ b/plugins/media-keys/org.gnome.Shell.KeyGrabber.xml
@@ -1,5 +1,5 @@
<node>
- <interface name="org.gnome.Shell">
+ <interface name="org.gnome.Shell.KeyGrabber">
<annotation name="org.gtk.GDBus.C.Name" value="KeyGrabber"/>
<method name="GrabAccelerator">
<arg type="s" direction="in" name="accelerator"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]