annotate src/gnomeshortcuts/gnomeshortcuts.c @ 2835:f1b6f1b2cdb3

fixed FSF address
author Andrew O. Shadoura <bugzilla@tut.by>
date Mon, 14 Jul 2008 03:35:13 +0300
parents bd3a24b39058
children 3134a0987162
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
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2576
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1724
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
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 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
38 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
39 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
40 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
41 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
42
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
43 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
44 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
45
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
46 static GeneralPlugin audaciousgnomeshortcuts =
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
47 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
48 .description = "Gnome Shortcuts",
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
49 .init = init,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
50 .about = about,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
51 .cleanup = cleanup
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
52 };
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 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
55 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
56
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
57 #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
58
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 static void
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
61 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
62 GValue *return_value,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
63 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
64 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
65 gpointer invocation_hint,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
66 gpointer marshal_data)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
67 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
68 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
69 gpointer arg_1,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
70 gpointer arg_2);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
71 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
72 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
73 register gpointer data1;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
74
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
75 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
76
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
77 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
78 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
79 data1 = closure->data;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
80 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
81 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
82 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
83 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
84
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
85 callback (data1,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
86 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
87 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
88 }
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 static void
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
91 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
92 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
93 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
94 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
95 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
96 gboolean play, mute;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
97
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
98 /* playing or not */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
99 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
100
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
101 /* get current volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
102 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
103 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
104 if (current_volume)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
105 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
106 /* 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
107 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
108 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
109 /* volume is mute */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
110 mute = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
111 }
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 /* mute the playback */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
114 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
115 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
116 if (!mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
117 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
118 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
119 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
120 mute = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
121 } else {
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 (volume_static);
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
123 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
124 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
125 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
126 }
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 /* decreace volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
129 /* 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
130 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
131 if (mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
132 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
133 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
134 old_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
135 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
136 }
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 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
139 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
140 current_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
141 }
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 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
144 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
145 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
146 current_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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
149 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
150 return TRUE;
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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
153 /* increase volume */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
154 /* 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
155 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
156 if (mute)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
157 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
158 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
159 old_volume = 0;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
160 mute = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
161 }
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 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
164 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
165 current_volume = 100;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
166 }
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 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
169 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
170 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
171 current_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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
174 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
175 return TRUE;
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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
178 /* play */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
179 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
180 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
181 if (!play)
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
182 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
183 audacious_drct_play ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
184 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
185 audacious_drct_pause ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
186 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
187 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
188 }
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 /* pause */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
191 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
192 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
193 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
194 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
195
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
196 return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
197 }
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 /* stop */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
200 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
201 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
202 audacious_drct_stop ();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
203 return;
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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
206 /* prev track */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
207 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
208 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
209 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
210 return;
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
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
213 /* next track */
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
214 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
215 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
216 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
217 return;
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 }
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 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
223 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
224 GError *error = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
225 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
226
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
227 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
228 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
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_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
231 "ReleaseMediaPlayerKeys", &error,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
232 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
233 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
234 if (error != NULL) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
235 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
236 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
237 }
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
238 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
239 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
240 }
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 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
243 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
244 DBusGConnection *bus;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
245 GError *error = NULL;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
246 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
247
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
248 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
249 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
250 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
251 } else {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
252 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
253 "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
254 "/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
255 "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
256 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
257
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
258 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
259 "GrabMediaPlayerKeys", &error,
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
260 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
261 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
262 G_TYPE_INVALID,
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 if (error != NULL) {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
265 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
266 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
267 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
268 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
269 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
270 "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
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 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
274
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 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
276 "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
277 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
278 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
279 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
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 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
282 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
283 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
284 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
285 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
286 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
287 }
1724
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
288 }
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 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
291 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
292
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
293 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
294 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
295
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
296 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
297 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
298 }
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 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
302 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
303 static GtkWidget *dialog;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
304
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
305 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
306 _("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
307 "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
308 "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
309 ),
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
310 _("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
311
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
312 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
313 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
314 }
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 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
317 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
318 gnome_remote_init();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
319 loaded = TRUE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
320 }
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 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
323 {
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
324 if (!loaded) return;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
325 gnome_remote_uninit();
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
326 loaded = FALSE;
655949f889ec New Gnome shortcuts plugin to listen for Gnome's shortcuts over dbus
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff changeset
327 }