Mercurial > audlegacy
comparison src/audtool/handlers_general.c @ 4613:4e9859e8af94
Oops, forgot to rename one file.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jun 2008 01:31:03 +0300 |
parents | src/audtool/audtool_handlers_general.c@895297e46ee3 |
children | c2886b393206 |
comparison
equal
deleted
inserted
replaced
4612:8a7752f1c662 | 4613:4e9859e8af94 |
---|---|
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 | |
46 audtool_report("%d", i); | |
47 } | |
48 | |
49 void set_volume(gint argc, gchar **argv) | |
50 { | |
51 gint i, current_volume; | |
52 | |
53 if (argc < 2) | |
54 { | |
55 audtool_whine_args(argv[0], "<level>", argv[0]); | |
56 exit(1); | |
57 } | |
58 | |
59 current_volume = audacious_remote_get_main_volume(dbus_proxy); | |
60 switch (argv[1][0]) | |
61 { | |
62 case '+': | |
63 case '-': | |
64 i = current_volume + atoi(argv[1]); | |
65 break; | |
66 default: | |
67 i = atoi(argv[1]); | |
68 break; | |
69 } | |
70 | |
71 audacious_remote_set_main_volume(dbus_proxy, i); | |
72 } | |
73 | |
74 void mainwin_show(gint argc, gchar **argv) | |
75 { | |
76 if (argc < 2) { | |
77 audtool_whine_args(argv[0], "<on/off>"); | |
78 exit(1); | |
79 } | |
80 | |
81 if (!g_ascii_strcasecmp(argv[1], "on")) { | |
82 audacious_remote_main_win_toggle(dbus_proxy, TRUE); | |
83 return; | |
84 } | |
85 else if (!g_ascii_strcasecmp(argv[1], "off")) { | |
86 audacious_remote_main_win_toggle(dbus_proxy, FALSE); | |
87 return; | |
88 } | |
89 } | |
90 | |
91 void playlist_show(gint argc, gchar **argv) | |
92 { | |
93 if (argc < 2) { | |
94 audtool_whine_args(argv[0], "<on/off>"); | |
95 exit(1); | |
96 } | |
97 | |
98 if (!g_ascii_strcasecmp(argv[1], "on")) { | |
99 audacious_remote_pl_win_toggle(dbus_proxy, TRUE); | |
100 return; | |
101 } | |
102 else if (!g_ascii_strcasecmp(argv[1], "off")) { | |
103 audacious_remote_pl_win_toggle(dbus_proxy, FALSE); | |
104 return; | |
105 } | |
106 } | |
107 | |
108 void equalizer_show(gint argc, gchar **argv) | |
109 { | |
110 if (argc < 2) { | |
111 audtool_whine_args(argv[0], "<on/off>"); | |
112 exit(1); | |
113 } | |
114 | |
115 if (!g_ascii_strcasecmp(argv[1] ,"on")) { | |
116 audacious_remote_eq_win_toggle(dbus_proxy, TRUE); | |
117 return; | |
118 } | |
119 else if (!g_ascii_strcasecmp(argv[1] ,"off")) { | |
120 audacious_remote_eq_win_toggle(dbus_proxy, FALSE); | |
121 return; | |
122 } | |
123 } | |
124 | |
125 void show_preferences_window(gint argc, gchar **argv) | |
126 { | |
127 gboolean show = TRUE; | |
128 | |
129 if (argc < 2) { | |
130 #if 0 | |
131 audtool_whine_args(argv[0], "<on/off>"); | |
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 { | |
144 audtool_whine_args(argv[0], "<on/off>"); | |
145 exit (1); | |
146 } | |
147 | |
148 audacious_remote_toggle_prefs_box(dbus_proxy, show); | |
149 } | |
150 | |
151 void show_about_window(gint argc, gchar **argv) | |
152 { | |
153 gboolean show = TRUE; | |
154 | |
155 if (argc < 2) { | |
156 #if 0 | |
157 audtool_whine_args(argv[0], "<on/off>"); | |
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 { | |
170 audtool_whine_args(argv[0], "<on/off>"); | |
171 exit (1); | |
172 } | |
173 | |
174 audacious_remote_toggle_about_box(dbus_proxy, show); | |
175 } | |
176 | |
177 void show_jtf_window(gint argc, gchar **argv) | |
178 { | |
179 gboolean show = TRUE; | |
180 | |
181 if (argc < 2) { | |
182 #if 0 | |
183 audtool_whine_args(argv[0], "<on/off>"); | |
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 { | |
195 audtool_whine_args(argv[0], "<on/off>"); | |
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 | |
208 audtool_whine_args(argv[0], "<on/off>"); | |
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 { | |
221 audtool_whine_args(argv[0], "<on/off>"); | |
222 exit (1); | |
223 } | |
224 | |
225 audacious_remote_toggle_filebrowser(dbus_proxy, show); | |
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 { | |
239 if (!g_ascii_strcasecmp("<sep>", handlers[i].name)) | |
240 audtool_report("%s%s:", i == 0 ? "" : "\n", handlers[i].desc); | |
241 else | |
242 audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc); | |
243 } | |
244 | |
245 audtool_report(""); | |
246 audtool_report("Handlers may be prefixed with `--' (GNU-style long-options) or not, your choice."); | |
247 audtool_report("Report bugs to http://bugzilla.atheme.org/"); | |
248 } | |
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 { | |
259 audtool_whine_args(argv[0], "<on/off>"); | |
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_skin(gint argc, gchar **argv) | |
274 { | |
275 gchar *skin = NULL; | |
276 skin = audacious_remote_get_skin(dbus_proxy); | |
277 audtool_report("%s", skin); | |
278 g_free(skin); | |
279 } | |
280 | |
281 void set_skin(gint argc, gchar **argv) | |
282 { | |
283 if (argc < 2) | |
284 { | |
285 audtool_whine_args(argv[0], "<skin>"); | |
286 exit(1); | |
287 } | |
288 | |
289 if(!argv[1] || !strcmp(argv[1], "")) | |
290 return; | |
291 | |
292 audacious_remote_set_skin(dbus_proxy, argv[1]); | |
293 } | |
294 | |
295 void get_version(gint argc, gchar **argv) | |
296 { | |
297 gchar *version = NULL; | |
298 version = audacious_remote_get_version(dbus_proxy); | |
299 if(version) | |
300 audtool_report("Audacious %s", version); | |
301 g_free(version); | |
302 } |