Mercurial > audlegacy
annotate src/audtool/handlers_general.c @ 4838:53dd85fdf42b
"default" -> "newui".
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 05 Apr 2009 15:28:31 -0500 |
parents | c2886b393206 |
children |
rev | line source |
---|---|
2737 | 1 /* |
2 * Audtool2 | |
3 * Copyright (c) 2007 Audacious development team | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are | |
7 * met: | |
8 * | |
9 * 1. Redistributions of source code must retain the above copyright notice, | |
10 * this list of conditions and the following disclaimer. | |
11 * | |
12 * 2. Redistributions in binary form must reproduce the above copyright | |
13 * notice, this list of conditions and the following disclaimer in the | |
14 * documentation and/or other materials provided with the distribution. | |
15 * | |
16 * 3. The name of the author may not be used to endorse or promote products | |
17 * derived from this software without specific prior written permission. | |
18 * | |
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 * POSSIBILITY OF SUCH DAMAGE. | |
30 */ | |
31 | |
32 #include <stdlib.h> | |
33 #include <string.h> | |
34 #include <glib.h> | |
35 #include <mowgli.h> | |
36 #include <locale.h> | |
37 #include "libaudclient/audctrl.h" | |
38 #include "audtool.h" | |
39 | |
40 void get_volume(gint argc, gchar **argv) | |
41 { | |
42 gint i; | |
43 | |
44 i = audacious_remote_get_main_volume(dbus_proxy); | |
45 | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
46 audtool_report("%d", i); |
2737 | 47 } |
48 | |
49 void set_volume(gint argc, gchar **argv) | |
50 { | |
51 gint i, current_volume; | |
52 | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
53 if (argc < 2) |
2737 | 54 { |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
55 audtool_whine_args(argv[0], "<level>", argv[0]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
56 exit(1); |
2737 | 57 } |
58 | |
59 current_volume = audacious_remote_get_main_volume(dbus_proxy); | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
60 switch (argv[1][0]) |
2737 | 61 { |
62 case '+': | |
63 case '-': | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
64 i = current_volume + atoi(argv[1]); |
2737 | 65 break; |
66 default: | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
67 i = atoi(argv[1]); |
2737 | 68 break; |
69 } | |
70 | |
71 audacious_remote_set_main_volume(dbus_proxy, i); | |
72 } | |
73 | |
74 void mainwin_show(gint argc, gchar **argv) | |
75 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
76 if (argc < 2) { |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
77 audtool_whine_args(argv[0], "<on/off>"); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
78 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
79 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
80 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
81 if (!g_ascii_strcasecmp(argv[1], "on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
82 audacious_remote_main_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
83 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
84 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
85 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
86 audacious_remote_main_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
87 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
88 } |
2737 | 89 } |
90 | |
91 void playlist_show(gint argc, gchar **argv) | |
92 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
93 if (argc < 2) { |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
94 audtool_whine_args(argv[0], "<on/off>"); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
95 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
96 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
97 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
98 if (!g_ascii_strcasecmp(argv[1], "on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
99 audacious_remote_pl_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
100 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
101 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
102 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
103 audacious_remote_pl_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
104 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
105 } |
2737 | 106 } |
107 | |
108 void equalizer_show(gint argc, gchar **argv) | |
109 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
110 if (argc < 2) { |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
111 audtool_whine_args(argv[0], "<on/off>"); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
112 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
113 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
114 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
115 if (!g_ascii_strcasecmp(argv[1] ,"on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
116 audacious_remote_eq_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
117 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
118 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
119 else if (!g_ascii_strcasecmp(argv[1] ,"off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
120 audacious_remote_eq_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
121 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
122 } |
2737 | 123 } |
124 | |
125 void show_preferences_window(gint argc, gchar **argv) | |
126 { | |
3917 | 127 gboolean show = TRUE; |
128 | |
129 if (argc < 2) { | |
130 #if 0 | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
131 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 132 exit(1); |
133 #else | |
134 audacious_remote_toggle_prefs_box(dbus_proxy, show); | |
135 return; | |
136 #endif | |
137 } | |
138 | |
139 if (!g_ascii_strcasecmp(argv[1], "on")) | |
140 show = TRUE; | |
141 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
142 show = FALSE; | |
143 else { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
144 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 145 exit (1); |
146 } | |
147 | |
148 audacious_remote_toggle_prefs_box(dbus_proxy, show); | |
2737 | 149 } |
150 | |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
151 void show_about_window(gint argc, gchar **argv) |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
152 { |
3917 | 153 gboolean show = TRUE; |
154 | |
155 if (argc < 2) { | |
156 #if 0 | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
157 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 158 exit(1); |
159 #else | |
160 audacious_remote_toggle_about_box(dbus_proxy, show); | |
161 return; | |
162 #endif | |
163 } | |
164 | |
165 if (!g_ascii_strcasecmp(argv[1], "on")) | |
166 show = TRUE; | |
167 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
168 show = FALSE; | |
169 else { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
170 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 171 exit (1); |
172 } | |
173 | |
174 audacious_remote_toggle_about_box(dbus_proxy, show); | |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
175 } |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
176 |
2737 | 177 void show_jtf_window(gint argc, gchar **argv) |
178 { | |
3917 | 179 gboolean show = TRUE; |
180 | |
181 if (argc < 2) { | |
182 #if 0 | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
183 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 184 exit(1); |
185 #else | |
186 audacious_remote_toggle_jtf_box(dbus_proxy, show); | |
187 return; | |
188 #endif | |
189 } | |
190 if (!g_ascii_strcasecmp(argv[1], "on")) | |
191 show = TRUE; | |
192 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
193 show = FALSE; | |
194 else { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
195 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 196 exit (1); |
197 } | |
198 | |
199 audacious_remote_toggle_jtf_box(dbus_proxy, show); | |
200 } | |
201 | |
202 void show_filebrowser(gint argc, gchar **argv) | |
203 { | |
204 gboolean show = TRUE; | |
205 | |
206 if (argc < 2) { | |
207 #if 0 | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
208 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 209 exit(1); |
210 #else | |
211 audacious_remote_toggle_filebrowser(dbus_proxy, show); | |
212 return; | |
213 #endif | |
214 } | |
215 | |
216 if (!g_ascii_strcasecmp(argv[1], "on")) | |
217 show = TRUE; | |
218 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
219 show = FALSE; | |
220 else { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
221 audtool_whine_args(argv[0], "<on/off>"); |
3917 | 222 exit (1); |
223 } | |
224 | |
225 audacious_remote_toggle_filebrowser(dbus_proxy, show); | |
2737 | 226 } |
227 | |
228 void shutdown_audacious_server(gint argc, gchar **argv) | |
229 { | |
230 audacious_remote_quit(dbus_proxy); | |
231 } | |
232 | |
233 void get_handlers_list(gint argc, gchar **argv) | |
234 { | |
235 gint i; | |
236 | |
237 for (i = 0; handlers[i].name != NULL; i++) | |
238 { | |
2939
964413953abd
Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents:
2935
diff
changeset
|
239 if (!g_ascii_strcasecmp("<sep>", handlers[i].name)) |
2935
fc8a2ebb2e13
Fix display of help system.
William Pitcock <nenolod@atheme.org>
parents:
2932
diff
changeset
|
240 audtool_report("%s%s:", i == 0 ? "" : "\n", handlers[i].desc); |
2737 | 241 else |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
242 audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc); |
2737 | 243 } |
244 | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
245 audtool_report(""); |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
246 audtool_report("Handlers may be prefixed with `--' (GNU-style long-options) or not, your choice."); |
4432 | 247 audtool_report("Report bugs to http://bugzilla.atheme.org/"); |
2737 | 248 } |
4074 | 249 |
250 void activate(gint argc, gchar **argv) | |
251 { | |
252 audacious_remote_activate(dbus_proxy); | |
253 } | |
254 | |
255 void toggle_aot(gint argc, gchar **argv) | |
256 { | |
257 if (argc < 2) | |
258 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4432
diff
changeset
|
259 audtool_whine_args(argv[0], "<on/off>"); |
4074 | 260 exit(1); |
261 } | |
262 | |
263 if (!g_ascii_strcasecmp(argv[1], "on")) { | |
264 audacious_remote_toggle_aot(dbus_proxy, TRUE); | |
265 return; | |
266 } | |
267 else if (!g_ascii_strcasecmp(argv[1], "off")) { | |
268 audacious_remote_toggle_aot(dbus_proxy, FALSE); | |
269 return; | |
270 } | |
271 } | |
272 | |
273 void get_version(gint argc, gchar **argv) | |
274 { | |
275 gchar *version = NULL; | |
276 version = audacious_remote_get_version(dbus_proxy); | |
277 if(version) | |
278 audtool_report("Audacious %s", version); | |
279 g_free(version); | |
280 } |