Mercurial > audlegacy
comparison src/audtool/audtool_handlers_playqueue.c @ 2933:7be518cc8e60 trunk
Transition to audtool_report()/audtool_whine().
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 29 Jun 2007 08:33:09 -0500 |
parents | b0ca7bddaec9 |
children | e48f2f4c116d |
comparison
equal
deleted
inserted
replaced
2932:fe27b67d8c37 | 2933:7be518cc8e60 |
---|---|
41 { | 41 { |
42 gint i; | 42 gint i; |
43 | 43 |
44 if (argc < 2) | 44 if (argc < 2) |
45 { | 45 { |
46 g_print("%s: invalid parameters for playqueue-add.\n", argv[0]); | 46 audtool_whine("invalid parameters for %s.", argv[0]); |
47 g_print("%s: syntax: %s playqueue-add <position>\n", argv[0], argv[0]); | 47 audtool_whine("syntax: %s <position>", argv[0]); |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 i = atoi(argv[1]); | 51 i = atoi(argv[1]); |
52 | 52 |
53 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) | 53 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
54 { | 54 { |
55 g_print("%s: invalid playlist position %d\n", argv[0], i); | 55 audtool_whine("invalid playlist position %d", i); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))) | 59 if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))) |
60 audacious_remote_playqueue_add(dbus_proxy, i - 1); | 60 audacious_remote_playqueue_add(dbus_proxy, i - 1); |
64 { | 64 { |
65 gint i; | 65 gint i; |
66 | 66 |
67 if (argc < 2) | 67 if (argc < 2) |
68 { | 68 { |
69 g_print("%s: invalid parameters for playqueue-remove.\n", argv[0]); | 69 audtool_whine("invalid parameters for %s.", argv[0]); |
70 g_print("%s: syntax: %s playqueue-remove <position>\n", argv[0], argv[0]); | 70 audtool_whine("syntax: %s <position>", argv[0]); |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 i = atoi(argv[1]); | 74 i = atoi(argv[1]); |
75 | 75 |
76 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) | 76 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
77 { | 77 { |
78 g_print("%s: invalid playlist position %d\n", argv[0], i); | 78 audtool_whine("invalid playlist position %d", i); |
79 return; | 79 return; |
80 } | 80 } |
81 | 81 |
82 if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) | 82 if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) |
83 audacious_remote_playqueue_remove(dbus_proxy, i - 1); | 83 audacious_remote_playqueue_remove(dbus_proxy, i - 1); |
87 { | 87 { |
88 gint i; | 88 gint i; |
89 | 89 |
90 if (argc < 2) | 90 if (argc < 2) |
91 { | 91 { |
92 g_print("%s: invalid parameters for playqueue-is-queued.\n", argv[0]); | 92 audtool_whine("invalid parameters for playqueue-is-queued.", argv[0]); |
93 g_print("%s: syntax: %s playqueue-is-queued <position>\n", argv[0], argv[0]); | 93 audtool_whine("syntax: %s playqueue-is-queued <position>", argv[0]); |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 i = atoi(argv[1]); | 97 i = atoi(argv[1]); |
98 | 98 |
99 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) | 99 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
100 { | 100 { |
101 g_print("%s: invalid playlist position %d\n", argv[0], i); | 101 audtool_whine("invalid playlist position %d", i); |
102 return; | 102 return; |
103 } | 103 } |
104 | 104 |
105 exit(!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))); | 105 exit(!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))); |
106 } | 106 } |
109 { | 109 { |
110 gint i, pos; | 110 gint i, pos; |
111 | 111 |
112 if (argc < 2) | 112 if (argc < 2) |
113 { | 113 { |
114 g_print("%s: invalid parameters for playqueue-get-position.\n", argv[0]); | 114 audtool_whine("invalid parameters for %s.", argv[0]); |
115 g_print("%s: syntax: %s playqueue-get-position <position>\n", argv[0], argv[0]); | 115 audtool_whine("syntax: %s <position>", argv[0]); |
116 return; | 116 return; |
117 } | 117 } |
118 | 118 |
119 i = atoi(argv[1]); | 119 i = atoi(argv[1]); |
120 | 120 |
121 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) | 121 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
122 { | 122 { |
123 g_print("%s: invalid playlist position %d\n", argv[0], i); | 123 audtool_whine("invalid playlist position %d", i); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 pos = audacious_remote_get_playqueue_position(dbus_proxy, i - 1) + 1; | 127 pos = audacious_remote_get_playqueue_position(dbus_proxy, i - 1) + 1; |
128 | 128 |
129 if (pos < 1) | 129 if (pos < 1) |
130 return; | 130 return; |
131 | 131 |
132 g_print("%d\n", pos); | 132 audtool_report("%d", pos); |
133 } | 133 } |
134 | 134 |
135 void playqueue_get_qposition(gint argc, gchar **argv) | 135 void playqueue_get_qposition(gint argc, gchar **argv) |
136 { | 136 { |
137 gint i, pos; | 137 gint i, pos; |
138 | 138 |
139 if (argc < 2) | 139 if (argc < 2) |
140 { | 140 { |
141 g_print("%s: invalid parameters for playqueue-get-qposition.\n", argv[0]); | 141 audtool_whine("invalid parameters for %s.", argv[0]); |
142 g_print("%s: syntax: %s playqueue-get-qposition <position>\n", argv[0], argv[0]); | 142 audtool_whine("syntax: %s <position>", argv[0]); |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 i = atoi(argv[1]); | 146 i = atoi(argv[1]); |
147 | 147 |
148 if (i < 1 || i > audacious_remote_get_playqueue_length(dbus_proxy)) | 148 if (i < 1 || i > audacious_remote_get_playqueue_length(dbus_proxy)) |
149 { | 149 { |
150 g_print("%s: invalid playlist position %d\n", argv[0], i); | 150 audtool_whine("invalid playlist position %d", i); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1; | 154 pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1; |
155 | 155 |
156 if (pos < 1) | 156 if (pos < 1) |
157 return; | 157 return; |
158 | 158 |
159 g_print("%d\n", pos); | 159 audtool_report("%d", pos); |
160 } | 160 } |
161 | 161 |
162 void playqueue_display(gint argc, gchar **argv) | 162 void playqueue_display(gint argc, gchar **argv) |
163 { | 163 { |
164 gint i, ii, position, frames, length, total; | 164 gint i, ii, position, frames, length, total; |
166 gchar *fmt = NULL, *p; | 166 gchar *fmt = NULL, *p; |
167 gint column; | 167 gint column; |
168 | 168 |
169 i = audacious_remote_get_playqueue_length(dbus_proxy); | 169 i = audacious_remote_get_playqueue_length(dbus_proxy); |
170 | 170 |
171 g_print("%d queued tracks.\n", i); | 171 audtool_report("%d queued tracks.", i); |
172 | 172 |
173 total = 0; | 173 total = 0; |
174 | 174 |
175 for (ii = 0; ii < i; ii++) | 175 for (ii = 0; ii < i; ii++) |
176 { | 176 { |
199 } | 199 } |
200 p = g_utf8_next_char(p); | 200 p = g_utf8_next_char(p); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d\n", column); | 204 fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d", column); |
205 g_print(fmt, ii + 1, position + 1, songname, length / 60, length % 60); | 205 audtool_report(fmt, ii + 1, position + 1, songname, length / 60, length % 60); |
206 g_free(fmt); | 206 g_free(fmt); |
207 } | 207 } |
208 | 208 |
209 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | 209 audtool_report("Total length: %d:%.2d", total / 60, total % 60); |
210 } | 210 } |
211 | 211 |
212 void playqueue_length(gint argc, gchar **argv) | 212 void playqueue_length(gint argc, gchar **argv) |
213 { | 213 { |
214 gint i; | 214 gint i; |
215 | 215 |
216 i = audacious_remote_get_playqueue_length(dbus_proxy); | 216 i = audacious_remote_get_playqueue_length(dbus_proxy); |
217 | 217 |
218 g_print("%d\n", i); | 218 audtool_report("%d", i); |
219 } | 219 } |
220 | 220 |
221 void playqueue_clear(gint argc, gchar **argv) | 221 void playqueue_clear(gint argc, gchar **argv) |
222 { | 222 { |
223 audacious_remote_playqueue_clear(dbus_proxy); | 223 audacious_remote_playqueue_clear(dbus_proxy); |