Mercurial > audlegacy-plugins
annotate src/hotkey/plugin.c @ 2336:ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
author | Sascha Hlusiak <contact@saschahlusiak.de> |
---|---|
date | Wed, 23 Jan 2008 19:37:05 +0100 |
parents | 0be42d832217 |
children | 7b284f323ad8 |
rev | line source |
---|---|
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
1 /* |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
2 * This file is part of audacious-hotkey plugin for audacious |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
3 * |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
4 * Copyright (c) 2007 - 2008 Sascha Hlusiak <contact@saschahlusiak.de> |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
5 * Name: plugin.c |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
6 * Description: plugin.c |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
7 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
8 * Part of this code is from itouch-ctrl plugin. |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
9 * Authors of itouch-ctrl are listed below: |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
10 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
11 * Copyright (c) 2006 - 2007 Vladimir Paskov <vlado.paskov@gmail.com> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
12 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
13 * Part of this code are from xmms-itouch plugin. |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
14 * Authors of xmms-itouch are listed below: |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
15 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
16 * Copyright (C) 2000-2002 Ville Syrjälä <syrjala@sci.fi> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
17 * Bryn Davies <curious@ihug.com.au> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
18 * Jonathan A. Davis <davis@jdhouse.org> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
19 * Jeremy Tan <nsx@nsx.homeip.net> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
20 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
21 * audacious-hotkey is free software; you can redistribute it and/or modify |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
22 * it under the terms of the GNU General Public License as published by |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
23 * the Free Software Foundation; either version 2 of the License, or |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
24 * (at your option) any later version. |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
25 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
26 * audacious-hotkey is distributed in the hope that it will be useful, |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
29 * GNU General Public License for more details. |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
30 * |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
31 * You should have received a copy of the GNU General Public License |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
32 * along with audacious-hotkey; if not, write to the Free Software |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
34 */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
35 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
36 #include <config.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
37 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
38 #include <stdio.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
39 #include <X11/XF86keysym.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
40 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
41 #include <gdk/gdkx.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
42 #include <audacious/plugin.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
43 #include <audacious/auddrct.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
44 #include <audacious/configdb.h> |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
45 |
1551
a9af4f1aede9
hotkey plugin: stripped unneeded #ifdefs from standalone version
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
1543
diff
changeset
|
46 #include <audacious/i18n.h> |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
47 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
48 #include "plugin.h" |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
49 #include "gui.h" |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
50 #include "grab.h" |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
51 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
52 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
53 /* func defs */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
54 static void init (void); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
55 static void cleanup (void); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
56 |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
57 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
58 /* global vars */ |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
59 static PluginConfig plugin_cfg; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
60 static gboolean loaded = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
61 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
62 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
63 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
64 static GeneralPlugin audacioushotkey = |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
65 { |
1658 | 66 .description = "Global Hotkey", |
67 .init = init, | |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
68 .about = show_about, |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
69 .configure = show_configure, |
1658 | 70 .cleanup = cleanup |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
71 }; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
72 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
73 GeneralPlugin *hotkey_gplist[] = { &audacioushotkey, NULL }; |
1658 | 74 SIMPLE_GENERAL_PLUGIN(hotkey, hotkey_gplist); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
75 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
76 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
77 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
78 PluginConfig* get_config(void) |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
79 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
80 return &plugin_cfg; |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
81 } |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
82 |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
83 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
84 /* |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
85 * plugin activated |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
86 */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
87 static void init (void) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
88 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
89 setup_filter(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
90 load_config ( ); |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
91 grab_keys ( ); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
92 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
93 loaded = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
94 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
95 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
96 /* handle keys */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
97 gboolean handle_keyevent (EVENT event) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
98 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
99 gint current_volume, old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
100 static gint volume_static = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
101 gboolean play, mute; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
102 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
103 /* playing or not */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
104 play = audacious_drct_is_playing (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
105 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
106 /* get current volume */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
107 audacious_drct_get_volume_main (¤t_volume); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
108 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
109 if (current_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
110 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
111 /* volume is not mute */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
112 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
113 } else { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
114 /* volume is mute */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
115 mute = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
116 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
117 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
118 /* mute the playback */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
119 if (event == EVENT_MUTE) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
120 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
121 if (!mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
122 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
123 volume_static = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
124 audacious_drct_set_main_volume (0); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
125 mute = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
126 } else { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
127 audacious_drct_set_main_volume (volume_static); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
128 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
129 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
130 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
131 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
132 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
133 /* decreace volume */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
134 if (event == EVENT_VOL_DOWN) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
135 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
136 if (mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
137 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
138 current_volume = old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
139 old_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
140 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
141 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
142 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
143 if ((current_volume -= plugin_cfg.vol_decrement) < 0) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
144 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
145 current_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
146 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
147 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
148 if (current_volume != old_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
149 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
150 audacious_drct_set_main_volume (current_volume); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
151 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
152 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
153 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
154 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
155 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
156 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
157 /* increase volume */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
158 if (event == EVENT_VOL_UP) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
159 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
160 if (mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
161 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
162 current_volume = old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
163 old_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
164 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
165 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
166 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
167 if ((current_volume += plugin_cfg.vol_increment) > 100) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
168 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
169 current_volume = 100; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
170 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
171 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
172 if (current_volume != old_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
173 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
174 audacious_drct_set_main_volume (current_volume); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
175 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
176 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
177 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
178 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
179 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
180 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
181 /* play */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
182 if (event == EVENT_PLAY) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
183 { |
2281
6ca0d83ce51d
Hotkey: Changed "Play/Pause" to "Play" and "Pause" to "Pause/Resume" since they were doing the same
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2274
diff
changeset
|
184 audacious_drct_play (); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
185 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
186 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
187 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
188 /* pause */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
189 if (event == EVENT_PAUSE) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
190 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
191 if (!play) audacious_drct_play (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
192 else audacious_drct_pause (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
193 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
194 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
195 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
196 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
197 /* stop */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
198 if (event == EVENT_STOP) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
199 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
200 audacious_drct_stop (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
201 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
202 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
203 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
204 /* prev track */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
205 if (event == EVENT_PREV_TRACK) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
206 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
207 audacious_drct_playlist_prev (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
208 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
209 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
210 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
211 /* next track */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
212 if (event == EVENT_NEXT_TRACK) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
213 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
214 audacious_drct_playlist_next (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
215 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
216 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
217 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
218 /* forward */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
219 if (event == EVENT_FORWARD) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
220 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
221 gint time = audacious_drct_get_output_time(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
222 time += 5000; /* Jump 5s into future */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
223 audacious_drct_jump_to_time(time); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
224 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
225 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
226 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
227 /* backward */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
228 if (event == EVENT_BACKWARD) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
229 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
230 gint time = audacious_drct_get_output_time(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
231 if (time > 5000) time -= 5000; /* Jump 5s back */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
232 else time = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
233 audacious_drct_jump_to_time(time); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
234 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
235 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
236 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
237 /* Open Jump-To-File dialog */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
238 if (event == EVENT_JUMP_TO_FILE) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
239 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
240 audacious_drct_show_jtf_box(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
241 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
242 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
243 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
244 /* Toggle Windows */ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
245 if (event == EVENT_TOGGLE_WIN) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
246 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
247 static gboolean is_main, is_eq, is_pl; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
248 is_main = audacious_drct_main_win_is_visible(); |
2289
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
249 if (is_main) { /* Hide windows */ |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
250 is_pl = audacious_drct_pl_win_is_visible(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
251 is_eq = audacious_drct_eq_win_is_visible(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
252 audacious_drct_main_win_toggle(FALSE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
253 audacious_drct_pl_win_toggle(FALSE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
254 audacious_drct_eq_win_toggle(FALSE); |
2289
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
255 } else { /* Show hidden windows */ |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
256 audacious_drct_main_win_toggle(TRUE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
257 audacious_drct_pl_win_toggle(is_pl); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
258 audacious_drct_eq_win_toggle(is_eq); |
2289
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
259 audacious_drct_activate(); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
260 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
261 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
262 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
263 |
2289
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
264 /* Show OSD through AOSD plugin*/ |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
265 if (event == EVENT_SHOW_AOSD) |
2289
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
266 { |
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
267 aud_hook_call("aosd toggle", NULL); |
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
268 return TRUE; |
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
269 } |
515f9c741a5c
Hotkey: New hotkey for showing Audacious OSD with current playing song (like Amarok can do)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2281
diff
changeset
|
270 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
271 return FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
272 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
273 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
274 void add_hotkey(HotkeyConfiguration** pphotkey, KeySym keysym, gint mask, gint type, EVENT event) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
275 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
276 KeyCode keycode; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
277 HotkeyConfiguration *photkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
278 if (keysym == 0) return; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
279 if (pphotkey == NULL) return; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
280 photkey = *pphotkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
281 if (photkey == NULL) return; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
282 keycode = XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
283 if (keycode == 0) return; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
284 if (photkey->key) { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
285 photkey->next = (HotkeyConfiguration*) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
286 malloc(sizeof (HotkeyConfiguration)); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
287 photkey = photkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
288 *pphotkey = photkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
289 photkey->next = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
290 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
291 photkey->key = (gint)keycode; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
292 photkey->mask = mask; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
293 photkey->event = event; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
294 photkey->type = type; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
295 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
296 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
297 void load_defaults (void) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
298 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
299 HotkeyConfiguration* hotkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
300 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
301 hotkey = &(plugin_cfg.first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
302 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
303 add_hotkey(&hotkey, XF86XK_AudioPrev, 0, TYPE_KEY, EVENT_PREV_TRACK); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
304 add_hotkey(&hotkey, XF86XK_AudioPlay, 0, TYPE_KEY, EVENT_PLAY); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
305 add_hotkey(&hotkey, XF86XK_AudioPause, 0, TYPE_KEY, EVENT_PAUSE); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
306 add_hotkey(&hotkey, XF86XK_AudioStop, 0, TYPE_KEY, EVENT_STOP); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
307 add_hotkey(&hotkey, XF86XK_AudioNext, 0, TYPE_KEY, EVENT_NEXT_TRACK); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
308 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
309 /* add_hotkey(&hotkey, XF86XK_AudioRewind, 0, TYPE_KEY, EVENT_BACKWARD); */ |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
310 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
311 add_hotkey(&hotkey, XF86XK_AudioMute, 0, TYPE_KEY, EVENT_MUTE); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
312 add_hotkey(&hotkey, XF86XK_AudioRaiseVolume, 0, TYPE_KEY, EVENT_VOL_UP); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
313 add_hotkey(&hotkey, XF86XK_AudioLowerVolume, 0, TYPE_KEY, EVENT_VOL_DOWN); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
314 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
315 /* add_hotkey(&hotkey, XF86XK_AudioMedia, 0, TYPE_KEY, EVENT_JUMP_TO_FILE); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
316 add_hotkey(&hotkey, XF86XK_Music, 0, TYPE_KEY, EVENT_TOGGLE_WIN); */ |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
317 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
318 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
319 /* load plugin configuration */ |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
320 void load_config (void) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
321 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
322 ConfigDb *cfdb; |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
323 HotkeyConfiguration *hotkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
324 int i,max; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
325 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
326 /* default volume level */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
327 plugin_cfg.vol_increment = 4; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
328 plugin_cfg.vol_decrement = 4; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
329 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
330 /* open configuration database */ |
2124 | 331 cfdb = aud_cfg_db_open ( ); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
332 hotkey = &(plugin_cfg.first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
333 hotkey->next = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
334 hotkey->key = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
335 hotkey->mask = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
336 hotkey->event = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
337 hotkey->type = TYPE_KEY; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
338 max = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
339 aud_cfg_db_get_int (cfdb, "globalHotkey", "NumHotkeys", &max); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
340 if (max == 0) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
341 load_defaults(); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
342 else for (i=0; i<max; i++) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
343 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
344 gchar *text = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
345 gint value; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
346 if (hotkey->key) { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
347 hotkey->next = (HotkeyConfiguration*) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
348 malloc(sizeof (HotkeyConfiguration)); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
349 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
350 hotkey->next = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
351 hotkey->key = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
352 hotkey->mask = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
353 hotkey->event = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
354 hotkey->type = TYPE_KEY; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
355 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
356 text = g_strdup_printf("Hotkey_%d_key", i); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
357 aud_cfg_db_get_int (cfdb, "globalHotkey", text, &(hotkey->key)); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
358 g_free(text); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
359 |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
360 text = g_strdup_printf("Hotkey_%d_mask", i); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
361 aud_cfg_db_get_int (cfdb, "globalHotkey", text, &(hotkey->mask)); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
362 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
363 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
364 text = g_strdup_printf("Hotkey_%d_type", i); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
365 aud_cfg_db_get_int (cfdb, "globalHotkey", text, &(hotkey->type)); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
366 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
367 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
368 text = g_strdup_printf("Hotkey_%d_event", i); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
369 value = (gint)hotkey->event; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
370 aud_cfg_db_get_int (cfdb, "globalHotkey", text, &value); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
371 hotkey->event = (EVENT) value; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
372 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
373 } |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
374 |
2124 | 375 aud_cfg_db_close (cfdb); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
376 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
377 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
378 /* save plugin configuration */ |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
379 void save_config (void) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
380 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
381 ConfigDb *cfdb; |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
382 int max; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
383 HotkeyConfiguration *hotkey; |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
384 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
385 /* open configuration database */ |
2124 | 386 cfdb = aud_cfg_db_open ( ); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
387 hotkey = &(plugin_cfg.first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
388 max = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
389 while (hotkey) { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
390 gchar *text = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
391 if (hotkey->key) { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
392 text = g_strdup_printf("Hotkey_%d_key", max); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
393 aud_cfg_db_set_int (cfdb, "globalHotkey", text, hotkey->key); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
394 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
395 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
396 text = g_strdup_printf("Hotkey_%d_mask", max); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
397 aud_cfg_db_set_int (cfdb, "globalHotkey", text, hotkey->mask); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
398 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
399 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
400 text = g_strdup_printf("Hotkey_%d_type", max); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
401 aud_cfg_db_set_int (cfdb, "globalHotkey", text, hotkey->type); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
402 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
403 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
404 text = g_strdup_printf("Hotkey_%d_event", max); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
405 aud_cfg_db_set_int (cfdb, "globalHotkey", text, hotkey->event); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
406 g_free(text); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
407 max++; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
408 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
409 |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
410 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
411 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
412 aud_cfg_db_set_int (cfdb, "globalHotkey", "NumHotkeys", max); |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
413 |
2124 | 414 aud_cfg_db_close (cfdb); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
415 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
416 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
417 static void cleanup (void) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
418 { |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
419 HotkeyConfiguration* hotkey; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
420 if (!loaded) return; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
421 ungrab_keys (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
422 release_filter(); |
2336
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
423 hotkey = &(plugin_cfg.first); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
424 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
425 while (hotkey) |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
426 { |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
427 HotkeyConfiguration * old; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
428 old = hotkey; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
429 hotkey = hotkey->next; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
430 free(old); |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
431 } |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
432 plugin_cfg.first.next = NULL; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
433 plugin_cfg.first.key = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
434 plugin_cfg.first.event = 0; |
ad45d65e9ae7
Hotkey Plugin: Complete GUI rework. Ability to use more than one binding for the same action.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2330
diff
changeset
|
435 plugin_cfg.first.mask = 0; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
436 loaded = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
437 } |
2274
d9706e29e968
Hotkey: Added grabbing of mouse buttons with modificators so you can control it with the mouse from any application
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2273
diff
changeset
|
438 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
439 gboolean is_loaded (void) |
2274
d9706e29e968
Hotkey: Added grabbing of mouse buttons with modificators so you can control it with the mouse from any application
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2273
diff
changeset
|
440 { |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
441 return loaded; |
2274
d9706e29e968
Hotkey: Added grabbing of mouse buttons with modificators so you can control it with the mouse from any application
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2273
diff
changeset
|
442 } |