changeset 2370:200d9534946a

Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix http://bugzilla.atheme.org/show_bug.cgi?id=167
author Sascha Hlusiak <contact@saschahlusiak.de>
date Sat, 09 Feb 2008 13:17:12 +0100
parents e145ee199e1d
children 47f6f73438c3
files src/gnomeshortcuts/gnomeshortcuts.c
diffstat 1 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/gnomeshortcuts/gnomeshortcuts.c	Fri Feb 08 21:34:13 2008 +0100
+++ b/src/gnomeshortcuts/gnomeshortcuts.c	Sat Feb 09 13:17:12 2008 +0100
@@ -2,7 +2,7 @@
 /*
  *  This file is part of audacious-gnome-shortcut plugin for audacious
  *
- *  Copyright (c) 2007        Sascha Hlusiak <contact@saschahlusiak.de>
+ *  Copyright (c) 2007-2008    Sascha Hlusiak <contact@saschahlusiak.de>
  *  Name: plugin.c
  *  Description: plugin.c
  * 
@@ -21,8 +21,6 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#define DBUS_API_SUBJECT_TO_CHANGE
-
 #include <config.h>
 
 #include <string.h>
@@ -253,9 +251,9 @@
 		g_warning ("Error connecting to DBus: %s", error->message);
 	} else {
 		media_player_keys_proxy = dbus_g_proxy_new_for_name (bus,
-			"org.gnome.SettingsDaemon", 
-			"/org/gnome/SettingsDaemon",
-			"org.gnome.SettingsDaemon");
+			"org.gnome.SettingsDaemon.MediaKeys", 
+			"/org/gnome/SettingsDaemon/MediaKeys",
+			"org.gnome.SettingsDaemon.MediaKeys");
 		if (media_player_keys_proxy == NULL) return;
 
 		dbus_g_proxy_call (media_player_keys_proxy,
@@ -265,8 +263,29 @@
 				G_TYPE_INVALID,
 				G_TYPE_INVALID);
 		if (error != NULL) {
-			g_warning ("Could not release media player keys: %s", error->message);
 			g_error_free (error);
+			error = NULL;
+			g_object_unref(media_player_keys_proxy);
+			media_player_keys_proxy = NULL;
+    			media_player_keys_proxy = dbus_g_proxy_new_for_name (bus,
+				"org.gnome.SettingsDaemon", 
+				"/org/gnome/SettingsDaemon",
+				"org.gnome.SettingsDaemon");
+			if (media_player_keys_proxy == NULL) return;
+
+			dbus_g_proxy_call (media_player_keys_proxy,
+					"GrabMediaPlayerKeys", &error,
+					G_TYPE_STRING, "Audacious",
+					G_TYPE_UINT, 0,
+					G_TYPE_INVALID,
+					G_TYPE_INVALID);
+			if (error != NULL) {
+				g_warning ("Could not grab media player keys: %s", error->message);
+				g_error_free (error);
+				g_object_unref(media_player_keys_proxy);
+				media_player_keys_proxy = NULL;
+				return;
+			}
 		}
 
 		dbus_g_object_register_marshaller (hotkey_marshal_VOID__STRING_STRING,
@@ -287,7 +306,7 @@
 	dialog = audacious_info_dialog (_("About Gnome Shortcut Plugin"),
 				_("Gnome Shortcut Plugin\n"
 				"Let's you control the player with Gnome's shortcuts.\n\n"
-				"Copyright (C) 2007 Sascha Hlusiak <contact@saschahlusiak.de>\n\n"
+				"Copyright (C) 2007-2008 Sascha Hlusiak <contact@saschahlusiak.de>\n\n"
                          	),
                          	_("OK"), TRUE, NULL, NULL);