annotate src/gnomeshortcuts/gnomeshortcuts.c @ 2494:862477de235b

Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author William Pitcock <nenolod@atheme.org>
date Mon, 31 Mar 2008 04:45:30 -0500
parents 1a6fc0bdcfe6
children bd3a24b39058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
1 /* -*- Mode: C; indent-tabs: t; c-basic-offset: 9; tab-width: 9 -*- */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
2 /*
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
3 * This file is part of audacious-gnome-shortcut plugin for audacious
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
4 *
2370
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
5 * Copyright (c) 2007-2008 Sascha Hlusiak <contact@saschahlusiak.de>
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
6 * Name: plugin.c
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
7 * Description: plugin.c
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
8 *
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
9 * audacious-gnome-shortcut is free software; you can redistribute it and/or modify
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
12 * (at your option) any later version.
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
13 *
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
14 * audacious-gnome-shortcut is distributed in the hope that it will be useful,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
17 * GNU General Public License for more details.
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
18 *
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
20 * along with audacious-gnome-shortcut; if not, write to the Free Software
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
22 */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
23
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
24 #include <config.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
25
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
26 #include <string.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
27 #include <dbus/dbus.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
28 #include <dbus/dbus-glib-bindings.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
29 #include <glib-object.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
30
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
31 #include <audacious/plugin.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
32 #include <audacious/auddrct.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
33
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
34 #include <audacious/i18n.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
35 #include <audacious/util.h>
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
36
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
37
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
38 static void init (void);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
39 static void about (void);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
40 static void cleanup (void);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
41 void gnome_remote_init();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
42 void gnome_remote_uninit();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
43
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
44 static gboolean loaded = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
45 static DBusGProxy *media_player_keys_proxy = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
46
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
47 static GeneralPlugin audaciousgnomeshortcuts =
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
48 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
49 .description = "Gnome Shortcuts",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
50 .init = init,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
51 .about = about,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
52 .cleanup = cleanup
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
53 };
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
54
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
55 GeneralPlugin *gnomeshortcuts_gplist[] = { &audaciousgnomeshortcuts, NULL };
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
56 SIMPLE_GENERAL_PLUGIN(gnomeshortcuts, gnomeshortcuts_gplist);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
57
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
58 #define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
59
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
60
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
61 static void
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
62 hotkey_marshal_VOID__STRING_STRING (GClosure *closure,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
63 GValue *return_value,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
64 guint n_param_values,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
65 const GValue *param_values,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
66 gpointer invocation_hint,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
67 gpointer marshal_data)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
68 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
69 typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
70 gpointer arg_1,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
71 gpointer arg_2);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
72 register GMarshalFunc_VOID__STRING_STRING callback;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
73 register GCClosure *cc = (GCClosure*) closure;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
74 register gpointer data1;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
75
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
76 g_return_if_fail (n_param_values == 3);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
77
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
78 if (G_CCLOSURE_SWAP_DATA (closure))
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
79 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
80 data1 = closure->data;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
81 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
82 data1 = g_value_peek_pointer (param_values + 0);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
83 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
84 callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
85
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
86 callback (data1,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
87 g_marshal_value_peek_string (param_values + 1),
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
88 g_marshal_value_peek_string (param_values + 2));
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
89 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
90
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
91 static void
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
92 on_media_player_key_pressed (DBusGProxy *proxy, const gchar *application, const gchar *key)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
93 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
94 if (strcmp ("Audacious", application) == 0) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
95 gint current_volume, old_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
96 static gint volume_static = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
97 gboolean play, mute;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
98
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
99 /* playing or not */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
100 play = audacious_drct_is_playing ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
101
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
102 /* get current volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
103 audacious_drct_get_volume_main (&current_volume);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
104 old_volume = current_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
105 if (current_volume)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
106 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
107 /* volume is not mute */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
108 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
109 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
110 /* volume is mute */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
111 mute = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
112 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
113
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
114 /* mute the playback */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
115 if (strcmp ("Mute", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
116 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
117 if (!mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
118 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
119 volume_static = current_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
120 audacious_drct_set_main_volume (0);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
121 mute = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
122 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
123 audacious_drct_set_main_volume (volume_static);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
124 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
125 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
126 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
127 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
128
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
129 /* decreace volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
130 /* if ((keycode == plugin_cfg.vol_down) && (state == plugin_cfg.vol_down_mask))
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
131 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
132 if (mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
133 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
134 current_volume = old_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
135 old_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
136 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
137 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
138
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
139 if ((current_volume -= plugin_cfg.vol_decrement) < 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
140 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
141 current_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
142 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
143
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
144 if (current_volume != old_volume)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
145 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
146 xmms_remote_set_main_volume (audacioushotkey.xmms_session,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
147 current_volume);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
148 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
149
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
150 old_volume = current_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
151 return TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
152 }*/
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
153
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
154 /* increase volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
155 /* if ((keycode == plugin_cfg.vol_up) && (state == plugin_cfg.vol_up_mask))
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
156 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
157 if (mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
158 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
159 current_volume = old_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
160 old_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
161 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
162 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
163
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
164 if ((current_volume += plugin_cfg.vol_increment) > 100)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
165 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
166 current_volume = 100;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
167 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
168
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
169 if (current_volume != old_volume)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
170 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
171 xmms_remote_set_main_volume (audacioushotkey.xmms_session,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
172 current_volume);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
173 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
174
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
175 old_volume = current_volume;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
176 return TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
177 }*/
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
178
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
179 /* play */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
180 if (strcmp ("Play", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
181 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
182 if (!play)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
183 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
184 audacious_drct_play ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
185 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
186 audacious_drct_pause ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
187 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
188 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
189 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
190
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
191 /* pause */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
192 if (strcmp ("Pause", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
193 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
194 if (!play) audacious_drct_play ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
195 else audacious_drct_pause ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
196
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
197 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
198 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
199
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
200 /* stop */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
201 if (strcmp ("Stop", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
202 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
203 audacious_drct_stop ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
204 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
205 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
206
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
207 /* prev track */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
208 if (strcmp ("Previous", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
209 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
210 audacious_drct_playlist_prev ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
211 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
212 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
213
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
214 /* next track */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
215 if (strcmp ("Next", key) == 0)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
216 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
217 audacious_drct_playlist_next ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
218 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
219 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
220 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
221 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
222
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
223 void gnome_remote_uninit ()
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
224 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
225 GError *error = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
226 if (media_player_keys_proxy == NULL) return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
227
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
228 dbus_g_proxy_disconnect_signal (media_player_keys_proxy, "MediaPlayerKeyPressed",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
229 G_CALLBACK (on_media_player_key_pressed), NULL);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
230
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
231 dbus_g_proxy_call (media_player_keys_proxy,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
232 "ReleaseMediaPlayerKeys", &error,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
233 G_TYPE_STRING, "Audacious",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
234 G_TYPE_INVALID, G_TYPE_INVALID);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
235 if (error != NULL) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
236 g_warning ("Could not release media player keys: %s", error->message);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
237 g_error_free (error);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
238 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
239 g_object_unref(media_player_keys_proxy);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
240 media_player_keys_proxy = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
241 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
242
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
243 void gnome_remote_init ()
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
244 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
245 DBusGConnection *bus;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
246 GError *error = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
247 dbus_g_thread_init();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
248
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
249 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
250 if ((bus == NULL) || error) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
251 g_warning ("Error connecting to DBus: %s", error->message);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
252 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
253 media_player_keys_proxy = dbus_g_proxy_new_for_name (bus,
2385
1a6fc0bdcfe6 Patched gnome-shortcuts for new dbus interface according to bug http://bugzilla.atheme.org/show_bug.cgi?id=171
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2370
diff changeset
254 "org.gnome.SettingsDaemon",
2370
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
255 "/org/gnome/SettingsDaemon/MediaKeys",
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
256 "org.gnome.SettingsDaemon.MediaKeys");
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
257 if (media_player_keys_proxy == NULL) return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
258
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
259 dbus_g_proxy_call (media_player_keys_proxy,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
260 "GrabMediaPlayerKeys", &error,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
261 G_TYPE_STRING, "Audacious",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
262 G_TYPE_UINT, 0,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
263 G_TYPE_INVALID,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
264 G_TYPE_INVALID);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
265 if (error != NULL) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
266 g_error_free (error);
2370
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
267 error = NULL;
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
268 g_object_unref(media_player_keys_proxy);
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
269 media_player_keys_proxy = NULL;
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
270 media_player_keys_proxy = dbus_g_proxy_new_for_name (bus,
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
271 "org.gnome.SettingsDaemon",
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
272 "/org/gnome/SettingsDaemon",
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
273 "org.gnome.SettingsDaemon");
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
274 if (media_player_keys_proxy == NULL) return;
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
275
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
276 dbus_g_proxy_call (media_player_keys_proxy,
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
277 "GrabMediaPlayerKeys", &error,
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
278 G_TYPE_STRING, "Audacious",
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
279 G_TYPE_UINT, 0,
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
280 G_TYPE_INVALID,
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
281 G_TYPE_INVALID);
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
282 if (error != NULL) {
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
283 g_warning ("Could not grab media player keys: %s", error->message);
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
284 g_error_free (error);
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
285 g_object_unref(media_player_keys_proxy);
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
286 media_player_keys_proxy = NULL;
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
287 return;
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
288 }
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
289 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
290
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
291 dbus_g_object_register_marshaller (hotkey_marshal_VOID__STRING_STRING,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
292 G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
293
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
294 dbus_g_proxy_add_signal (media_player_keys_proxy, "MediaPlayerKeyPressed",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
295 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
296
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
297 dbus_g_proxy_connect_signal (media_player_keys_proxy, "MediaPlayerKeyPressed",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
298 G_CALLBACK (on_media_player_key_pressed), NULL, NULL);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
299 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
300 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
301
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
302 static void about (void)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
303 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
304 static GtkWidget *dialog;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
305
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
306 dialog = audacious_info_dialog (_("About Gnome Shortcut Plugin"),
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
307 _("Gnome Shortcut Plugin\n"
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
308 "Let's you control the player with Gnome's shortcuts.\n\n"
2370
200d9534946a Support for new dbus interface for gnome shortcuts. Using old interface as fallback. Should fix
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 2100
diff changeset
309 "Copyright (C) 2007-2008 Sascha Hlusiak <contact@saschahlusiak.de>\n\n"
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
310 ),
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
311 _("OK"), TRUE, NULL, NULL);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
312
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
313 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
314 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
315 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
316
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
317 static void init (void)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
318 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
319 gnome_remote_init();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
320 loaded = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
321 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
322
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
323 static void cleanup (void)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
324 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
325 if (!loaded) return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
326 gnome_remote_uninit();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
327 loaded = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
328 }