Mercurial > audlegacy-plugins
annotate src/hotkey/plugin.c @ 2891:c27da2c06805
initial code for bookmarks
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Tue, 12 Aug 2008 23:49:32 +0200 |
parents | f1b6f1b2cdb3 |
children | 3134a0987162 |
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 |
2835 | 33 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
1543
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 |
2661
1eb29b830013
Backed out changeset c1258ae018ee
Matti Hamalainen <ccr@tnsp.org>
parents:
2660
diff
changeset
|
36 #include <config.h> |
1543
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 |
1551
a9af4f1aede9
hotkey plugin: stripped unneeded #ifdefs from standalone version
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
1543
diff
changeset
|
45 #include <audacious/i18n.h> |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
46 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
47 #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
|
48 #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
|
49 #include "grab.h" |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
50 |
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 /* func defs */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
53 static void init (void); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
54 static void cleanup (void); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
55 |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
56 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
57 /* global vars */ |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
58 static PluginConfig plugin_cfg; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
59 static gboolean loaded = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
60 |
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 static GeneralPlugin audacioushotkey = |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
64 { |
1658 | 65 .description = "Global Hotkey", |
66 .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
|
67 .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
|
68 .configure = show_configure, |
1658 | 69 .cleanup = cleanup |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
70 }; |
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 GeneralPlugin *hotkey_gplist[] = { &audacioushotkey, NULL }; |
1658 | 73 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
|
74 |
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 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
77 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
|
78 { |
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
79 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
|
80 } |
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 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
83 /* |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
84 * plugin activated |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
85 */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
86 static void init (void) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
87 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
88 setup_filter(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
89 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
|
90 grab_keys ( ); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
91 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
92 loaded = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
93 } |
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 /* 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
|
96 gboolean handle_keyevent (EVENT event) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
97 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
98 gint current_volume, old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
99 static gint volume_static = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
100 gboolean play, mute; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
101 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
102 /* playing or not */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
103 play = audacious_drct_is_playing (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
104 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
105 /* get current volume */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
106 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
|
107 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
108 if (current_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
109 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
110 /* volume is not mute */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
111 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
112 } else { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
113 /* volume is mute */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
114 mute = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
115 } |
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 /* 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
|
118 if (event == EVENT_MUTE) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
119 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
120 if (!mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
121 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
122 volume_static = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
123 audacious_drct_set_main_volume (0); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
124 mute = TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
125 } else { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
126 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
|
127 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
128 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
129 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
130 } |
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 /* 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
|
133 if (event == EVENT_VOL_DOWN) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
134 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
135 if (mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
136 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
137 current_volume = old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
138 old_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
139 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
140 } |
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 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
|
143 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
144 current_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
145 } |
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 if (current_volume != old_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
148 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
149 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
|
150 } |
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 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
153 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
154 } |
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 /* 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
|
157 if (event == EVENT_VOL_UP) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
158 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
159 if (mute) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
160 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
161 current_volume = old_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
162 old_volume = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
163 mute = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
164 } |
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 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
|
167 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
168 current_volume = 100; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
169 } |
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 if (current_volume != old_volume) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
172 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
173 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
|
174 } |
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 old_volume = current_volume; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
177 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
178 } |
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 /* 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
|
181 if (event == EVENT_PLAY) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
182 { |
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
|
183 audacious_drct_play (); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
184 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
185 } |
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 /* 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
|
188 if (event == EVENT_PAUSE) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
189 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
190 if (!play) audacious_drct_play (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
191 else audacious_drct_pause (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
192 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
193 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
194 } |
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 /* 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
|
197 if (event == EVENT_STOP) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
198 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
199 audacious_drct_stop (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
200 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
201 } |
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 /* 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
|
204 if (event == EVENT_PREV_TRACK) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
205 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
206 audacious_drct_playlist_prev (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
207 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
208 } |
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 /* 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
|
211 if (event == EVENT_NEXT_TRACK) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
212 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
213 audacious_drct_playlist_next (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
214 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
215 } |
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 /* 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
|
218 if (event == EVENT_FORWARD) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
219 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
220 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
|
221 time += 5000; /* Jump 5s into future */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
222 audacious_drct_jump_to_time(time); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
223 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
224 } |
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 /* 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
|
227 if (event == EVENT_BACKWARD) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
228 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
229 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
|
230 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
|
231 else time = 0; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
232 audacious_drct_jump_to_time(time); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
233 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
234 } |
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 /* 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
|
237 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
|
238 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
239 audacious_drct_show_jtf_box(); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
240 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
241 } |
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 /* 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
|
244 if (event == EVENT_TOGGLE_WIN) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
245 { |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
246 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
|
247 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
|
248 if (is_main) { /* Hide windows */ |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
249 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
|
250 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
|
251 audacious_drct_main_win_toggle(FALSE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
252 audacious_drct_pl_win_toggle(FALSE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
253 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
|
254 } else { /* Show hidden windows */ |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
255 audacious_drct_main_win_toggle(TRUE); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
256 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
|
257 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
|
258 audacious_drct_activate(); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
259 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
260 return TRUE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
261 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
262 |
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
|
263 /* 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
|
264 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
|
265 { |
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 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
|
267 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
|
268 } |
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 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
270 return FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
271 } |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
272 |
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
|
273 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
|
274 { |
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 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 *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
|
288 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
|
289 } |
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 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
|
291 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
|
292 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
|
293 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
|
294 } |
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 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
|
297 { |
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 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
|
299 |
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 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
|
301 |
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 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 |
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 /* 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
|
309 |
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 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
|
311 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
|
312 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
|
313 |
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 /* 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
|
315 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
|
316 } |
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 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
318 /* 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
|
319 void load_config (void) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
320 { |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2501
diff
changeset
|
321 mcs_handle_t *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
|
322 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
|
323 int i,max; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
324 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
325 /* default volume level */ |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
326 plugin_cfg.vol_increment = 4; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
327 plugin_cfg.vol_decrement = 4; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
328 |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
329 /* open configuration database */ |
2124 | 330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 { |
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 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 } |
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 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
|
356 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
|
357 g_free(text); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
358 |
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
|
359 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
|
360 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
|
361 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
|
362 |
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 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
|
364 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
|
365 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
|
366 |
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 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 } |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
373 |
2124 | 374 aud_cfg_db_close (cfdb); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
375 } |
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 /* 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
|
378 void save_config (void) |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
379 { |
2523
769e17da93dd
Replaced s/ConfigDb/mcs_handle_t/g, as per changes in the core.
Matti Hamalainen <ccr@tnsp.org>
parents:
2501
diff
changeset
|
380 mcs_handle_t *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
|
381 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
|
382 HotkeyConfiguration *hotkey; |
2273
f893d05f707b
Hotkey: some cleaning and simplifying
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2124
diff
changeset
|
383 |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
384 /* open configuration database */ |
2124 | 385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 |
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 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
|
396 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
|
397 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
|
398 |
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 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
|
400 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
|
401 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
|
402 |
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 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
|
404 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
|
405 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
|
406 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
|
407 } |
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 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
|
410 } |
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 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
|
412 |
2124 | 413 aud_cfg_db_close (cfdb); |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
414 } |
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 static void cleanup (void) |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
417 { |
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
|
418 HotkeyConfiguration* hotkey; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
419 if (!loaded) return; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
420 ungrab_keys (); |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
421 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
|
422 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
|
423 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
|
424 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
|
425 { |
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 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
|
427 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
|
428 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
|
429 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
|
430 } |
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 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
|
432 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
|
433 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
|
434 plugin_cfg.first.mask = 0; |
1543
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
435 loaded = FALSE; |
ec4e8ec829b1
Include global hotkey plugin in build system (src/hotkey)
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
diff
changeset
|
436 } |
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
|
437 |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
438 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
|
439 { |
2330
0be42d832217
Splitted core/gui/grabbing sources; Fixed memory leak when closing configuration dialog.
Sascha Hlusiak <contact@saschahlusiak.de>
parents:
2289
diff
changeset
|
440 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
|
441 } |