annotate src/audtool/audtool_handlers_general.c @ 2929:b0ca7bddaec9 trunk

Split out playqueue functions.
author William Pitcock <nenolod@atheme.org>
date Fri, 29 Jun 2007 08:17:02 -0500
parents ede9a8b8deff
children fe27b67d8c37
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
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
46 g_print("%d\n", i);
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 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
55 g_print("%s: invalid parameters for set-volume.\n", argv[0]);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
56 g_print("%s: syntax: %s set-volume <level>\n", argv[0], argv[0]);
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 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
79 if (!strncmp(argv[1],"on",2)) {
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 }
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
83 else if (!strncmp(argv[1],"off",3)) {
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 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
88 g_print("%s: invalid parameter for mainwin-show.\n",argv[0]);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
89 g_print("%s: syntax: %s mainwin-show <on/off>\n",argv[0],argv[0]);
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 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
96 if (!strncmp(argv[1],"on",2)) {
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 }
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
100 else if (!strncmp(argv[1],"off",3)) {
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 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
105 g_print("%s: invalid parameter for playlist-show.\n",argv[0]);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
106 g_print("%s: syntax: %s playlist-show <on/off>\n",argv[0],argv[0]);
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 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
113 if (!strncmp(argv[1],"on",2)) {
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 }
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
117 else if (!strncmp(argv[1],"off",3)) {
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 }
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
122 g_print("%s: invalid parameter for equalizer-show.\n",argv[0]);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
123 g_print("%s: syntax: %s equalizer-show <on/off>\n",argv[0],argv[0]);
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 {
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
147 if (!g_strcasecmp("<sep>", handlers[i].name))
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
148 g_print("%s%s:\n", i == 0 ? "" : "\n", handlers[i].desc);
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
149 else
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
150 g_print(" %-34s - %s\n", handlers[i].name, handlers[i].desc);
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
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
153 g_print("\nHandlers may be prefixed with `--' (GNU-style long-options) or not, your choice.\n");
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
154 g_print("Report bugs to http://bugs-meta.atheme.org/\n");
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents:
diff changeset
155 }