annotate src/audtool/audtool_handlers_general.c @ 2947:13591e28d89e trunk

cleanup
author Tomasz Mon <desowin@gmail.com>
date Sun, 01 Jul 2007 12:52:58 +0200
parents b51cc33881c2
children e48f2f4c116d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
1 /*
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
2 * Audtool2
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
4 *
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
6 * modification, are permitted provided that the following conditions are
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
7 * met:
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
8 *
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright notice,
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
10 * this list of conditions and the following disclaimer.
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
11 *
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
15 *
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
16 * 3. The name of the author may not be used to endorse or promote products
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
17 * derived from this software without specific prior written permission.
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
18 *
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
29 * POSSIBILITY OF SUCH DAMAGE.
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
30 */
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
31
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
32 #include <stdlib.h>
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
33 #include <string.h>
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
34 #include <glib.h>
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
35 #include <mowgli.h>
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
36 #include <locale.h>
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
37 #include "libaudclient/audctrl.h"
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
38 #include "audtool.h"
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
39
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
40 void get_volume(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
41 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
42 gint i;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
43
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
44 i = audacious_remote_get_main_volume(dbus_proxy);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
45
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
46 audtool_report("%d", i);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
47 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
48
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
49 void set_volume(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
50 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
51 gint i, current_volume;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
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
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
54 {
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
55 audtool_whine("invalid parameters for %s.", argv[0]);
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
56 audtool_whine("syntax: %s <level>", argv[0]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
57 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
58 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
59
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
60 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
61 switch (argv[1][0])
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
62 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
63 case '+':
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
64 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
65 i = current_volume + atoi(argv[1]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
66 break;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
67 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
68 i = atoi(argv[1]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
69 break;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
70 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
71
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
72 audacious_remote_set_main_volume(dbus_proxy, i);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
73 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
74
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
75 void mainwin_show(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
76 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
77 if (argc > 1)
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
78 {
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
79 if (!g_ascii_strcasecmp(argv[1], "on")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
80 audacious_remote_main_win_toggle(dbus_proxy, TRUE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
81 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
82 }
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
83 else if (!g_ascii_strcasecmp(argv[1], "off")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
84 audacious_remote_main_win_toggle(dbus_proxy, FALSE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
85 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
86 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
87 }
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
88 audtool_whine("invalid parameter for %s.", argv[0]);
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
89 audtool_whine("syntax: %s <on/off>", argv[0]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
90 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
91
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
92 void playlist_show(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
93 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
94 if (argc > 1)
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
95 {
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
96 if (!g_ascii_strcasecmp(argv[1], "on")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
97 audacious_remote_pl_win_toggle(dbus_proxy, TRUE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
98 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
99 }
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
100 else if (!g_ascii_strcasecmp(argv[1], "off")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
101 audacious_remote_pl_win_toggle(dbus_proxy, FALSE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
102 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
103 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
104 }
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
105 audtool_whine("invalid parameter for %s.", argv[0]);
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
106 audtool_whine("syntax: %s <on/off>", argv[0]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
107 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
108
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
109 void equalizer_show(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
110 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
111 if (argc > 1)
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
112 {
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
113 if (!g_ascii_strcasecmp(argv[1] ,"on")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
114 audacious_remote_eq_win_toggle(dbus_proxy, TRUE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
115 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
116 }
2940
b51cc33881c2 Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents: 2939
diff changeset
117 else if (!g_ascii_strcasecmp(argv[1] ,"off")) {
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
118 audacious_remote_eq_win_toggle(dbus_proxy, FALSE);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
119 return;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
120 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
121 }
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
122 audtool_whine("invalid parameter for %s.", argv[0]);
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
123 audtool_whine("syntax: %s <on/off>", argv[0]);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
124 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
125
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
126 void show_preferences_window(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
127 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
128 audacious_remote_show_prefs_box(dbus_proxy);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
129 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
130
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
131 void show_jtf_window(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
132 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
133 audacious_remote_show_jtf_box(dbus_proxy);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
134 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
135
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
136 void shutdown_audacious_server(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
137 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
138 audacious_remote_quit(dbus_proxy);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
139 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
140
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
141 void get_handlers_list(gint argc, gchar **argv)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
142 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
143 gint i;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
144
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
145 for (i = 0; handlers[i].name != NULL; i++)
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
146 {
2939
964413953abd Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents: 2935
diff changeset
147 if (!g_ascii_strcasecmp("<sep>", handlers[i].name))
2935
fc8a2ebb2e13 Fix display of help system.
William Pitcock <nenolod@atheme.org>
parents: 2932
diff changeset
148 audtool_report("%s%s:", i == 0 ? "" : "\n", handlers[i].desc);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
149 else
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
150 audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc);
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
151 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
152
2932
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
153 audtool_report("Handlers may be prefixed with `--' (GNU-style long-options) or not, your choice.");
fe27b67d8c37 Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2929
diff changeset
154 audtool_report("Report bugs to http://bugs-meta.atheme.org/");
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
155 }