Mercurial > audlegacy-plugins
annotate src/gnomeshortcuts/gnomeshortcuts.c @ 2193:80d7ab8f2ec5
removed some duplicated code
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Wed, 28 Nov 2007 16:19:57 +0300 |
parents | 14adeaf9c20f |
children | 200d9534946a |
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 * |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
5 * Copyright (c) 2007 Sascha Hlusiak <contact@saschahlusiak.de> |
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 |
2100
14adeaf9c20f
fix compile on ancient DBus systems
William Pitcock <nenolod@atheme.org>
parents:
1724
diff
changeset
|
24 #define DBUS_API_SUBJECT_TO_CHANGE |
14adeaf9c20f
fix compile on ancient DBus systems
William Pitcock <nenolod@atheme.org>
parents:
1724
diff
changeset
|
25 |
1724
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
26 #include <config.h> |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
27 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
28 #include <string.h> |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
29 #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
|
30 #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
|
31 #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
|
32 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
33 #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
|
34 #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
|
35 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
36 #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
|
37 #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
|
38 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
39 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
46 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
|
47 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
|
48 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
49 static GeneralPlugin audaciousgnomeshortcuts = |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
50 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
51 .description = "Gnome Shortcuts", |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
52 .init = init, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
53 .about = about, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
54 .cleanup = cleanup |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
55 }; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
56 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
57 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
|
58 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
|
59 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
60 #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
|
61 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
62 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
63 static void |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
64 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
|
65 GValue *return_value, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
66 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
|
67 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
|
68 gpointer invocation_hint, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
69 gpointer marshal_data) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
70 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
71 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
|
72 gpointer arg_1, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
73 gpointer arg_2); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
74 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
|
75 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
|
76 register gpointer data1; |
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 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
|
79 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
80 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
|
81 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
82 data1 = closure->data; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
83 } else { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
84 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
|
85 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
86 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
|
87 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
88 callback (data1, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
89 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
|
90 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
|
91 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
92 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
93 static void |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
94 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
|
95 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 gboolean play, mute; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
100 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
101 /* playing or not */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
102 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
|
103 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
104 /* get current volume */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
105 audacious_drct_get_volume_main (¤t_volume); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
106 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
|
107 if (current_volume) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
108 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
109 /* 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
|
110 mute = FALSE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
111 } else { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
112 /* volume is mute */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
113 mute = TRUE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
114 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
115 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
116 /* mute the playback */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
117 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
|
118 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
119 if (!mute) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
120 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
121 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
|
122 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
|
123 mute = TRUE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
124 } else { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
125 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
|
126 mute = FALSE; |
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 return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
129 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
130 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
131 /* decreace volume */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
132 /* 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
|
133 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
134 if (mute) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
135 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
136 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
|
137 old_volume = 0; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
138 mute = FALSE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
139 } |
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 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
|
142 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
143 current_volume = 0; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
144 } |
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 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
|
147 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
148 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
|
149 current_volume); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
150 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
151 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
152 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
|
153 return TRUE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
154 }*/ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
155 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
156 /* increase volume */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
157 /* 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
|
158 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
159 if (mute) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
160 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
161 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
|
162 old_volume = 0; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
163 mute = FALSE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
164 } |
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 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
|
167 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
168 current_volume = 100; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
169 } |
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 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
|
172 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
173 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
|
174 current_volume); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
175 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
176 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
177 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
|
178 return TRUE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
179 }*/ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
180 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
181 /* play */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
182 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
|
183 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
184 if (!play) |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
185 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
186 audacious_drct_play (); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
187 } else { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
188 audacious_drct_pause (); |
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 return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
191 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
192 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
193 /* pause */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
194 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
|
195 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
196 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
|
197 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
|
198 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
199 return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
200 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
201 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
202 /* stop */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
203 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
|
204 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
205 audacious_drct_stop (); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
206 return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
207 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
208 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
209 /* prev track */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
210 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
|
211 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
212 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
|
213 return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
214 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
215 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
216 /* next track */ |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
217 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
|
218 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
219 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
|
220 return; |
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 } |
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 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
|
226 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
227 GError *error = NULL; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
228 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
|
229 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
230 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
|
231 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
|
232 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
233 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
|
234 "ReleaseMediaPlayerKeys", &error, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
235 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
|
236 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
|
237 if (error != NULL) { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
238 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
|
239 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
|
240 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
241 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
|
242 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
|
243 } |
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 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
|
246 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
247 DBusGConnection *bus; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
248 GError *error = NULL; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
249 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
|
250 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
251 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
|
252 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
|
253 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
|
254 } else { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
255 media_player_keys_proxy = dbus_g_proxy_new_for_name (bus, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
256 "org.gnome.SettingsDaemon", |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
257 "/org/gnome/SettingsDaemon", |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
258 "org.gnome.SettingsDaemon"); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
259 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
|
260 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
261 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
|
262 "GrabMediaPlayerKeys", &error, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
263 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
|
264 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
|
265 G_TYPE_INVALID, |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
266 G_TYPE_INVALID); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
267 if (error != NULL) { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
268 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
|
269 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
|
270 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
271 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
272 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
|
273 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
|
274 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
275 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
|
276 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
|
277 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
278 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
|
279 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
|
280 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
281 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
282 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
283 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
|
284 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
285 static GtkWidget *dialog; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
286 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
287 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
|
288 _("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
|
289 "Let's you control the player with Gnome's shortcuts.\n\n" |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
290 "Copyright (C) 2007 Sascha Hlusiak <contact@saschahlusiak.de>\n\n" |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
291 ), |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
292 _("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
|
293 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
294 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
|
295 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
|
296 } |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
297 |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
298 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
|
299 { |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
300 gnome_remote_init(); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
301 loaded = TRUE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
302 } |
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 void cleanup (void) |
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 if (!loaded) return; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
307 gnome_remote_uninit(); |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
308 loaded = FALSE; |
655949f889ec
New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
309 } |