61
|
1
|
|
2 #include "mpg123.h"
|
|
3
|
|
4 #include <glib.h>
|
|
5 #include <glib/gi18n.h>
|
|
6 #include <gtk/gtk.h>
|
|
7 #include <stdlib.h>
|
|
8 #include <string.h>
|
|
9 #include <math.h>
|
|
10
|
|
11 #include <libaudacious/configdb.h>
|
|
12 #include <libaudacious/dirbrowser.h>
|
|
13 #include <libaudacious/titlestring.h>
|
|
14
|
|
15
|
|
16 static GtkWidget *mpg123_configurewin = NULL;
|
|
17 static GtkWidget *vbox, *notebook;
|
|
18 static GtkWidget *decode_vbox, *decode_hbox1;
|
|
19 static GtkWidget *decode_res_frame, *decode_res_vbox, *decode_res_16,
|
|
20 *decode_res_8;
|
|
21 static GtkWidget *decode_ch_frame, *decode_ch_vbox, *decode_ch_stereo,
|
|
22 *decode_ch_mono;
|
|
23 static GtkWidget *decode_freq_frame, *decode_freq_vbox, *decode_freq_1to1,
|
|
24 *decode_freq_1to2, *decode_freq_1to4;
|
|
25 static GtkWidget *option_frame, *option_vbox, *detect_by_content,
|
|
26 *detect_by_extension, *detect_by_both;
|
|
27
|
|
28 static GtkObject *streaming_size_adj, *streaming_pre_adj;
|
|
29 static GtkWidget *streaming_proxy_use, *streaming_proxy_host_entry;
|
|
30 static GtkWidget *streaming_proxy_port_entry, *streaming_save_use,
|
|
31 *streaming_save_entry;
|
|
32 static GtkWidget *streaming_proxy_auth_use;
|
|
33 static GtkWidget *streaming_proxy_auth_pass_entry,
|
|
34 *streaming_proxy_auth_user_entry;
|
|
35 static GtkWidget *streaming_proxy_auth_user_label,
|
|
36 *streaming_proxy_auth_pass_label;
|
|
37 static GtkWidget *streaming_cast_title, *streaming_udp_title;
|
|
38 static GtkWidget *streaming_proxy_hbox, *streaming_proxy_auth_hbox,
|
|
39 *streaming_save_dirbrowser;
|
|
40 static GtkWidget *streaming_save_hbox, *title_id3_box, *title_tag_desc;
|
|
41 static GtkWidget *title_override, *title_id3_entry, *title_id3v2_disable;
|
|
42
|
|
43 /* Encoding patch */
|
|
44 static GtkWidget *title_encoding_hbox, *title_encoding_enabled, *title_encoding, *title_encoding_label;
|
|
45 /* Encoding patch */
|
|
46
|
|
47 MPG123Config mpg123_cfg;
|
|
48
|
|
49 static void
|
|
50 mpg123_configurewin_ok(GtkWidget * widget, gpointer data)
|
|
51 {
|
|
52 ConfigDb *db;
|
|
53
|
|
54 if (GTK_TOGGLE_BUTTON(decode_res_16)->active)
|
|
55 mpg123_cfg.resolution = 16;
|
|
56 else if (GTK_TOGGLE_BUTTON(decode_res_8)->active)
|
|
57 mpg123_cfg.resolution = 8;
|
|
58
|
|
59 if (GTK_TOGGLE_BUTTON(decode_ch_stereo)->active)
|
|
60 mpg123_cfg.channels = 2;
|
|
61 else if (GTK_TOGGLE_BUTTON(decode_ch_mono)->active)
|
|
62 mpg123_cfg.channels = 1;
|
|
63
|
|
64 if (GTK_TOGGLE_BUTTON(decode_freq_1to1)->active)
|
|
65 mpg123_cfg.downsample = 0;
|
|
66 else if (GTK_TOGGLE_BUTTON(decode_freq_1to2)->active)
|
|
67 mpg123_cfg.downsample = 1;
|
|
68 if (GTK_TOGGLE_BUTTON(decode_freq_1to4)->active)
|
|
69 mpg123_cfg.downsample = 2;
|
|
70
|
|
71 if (GTK_TOGGLE_BUTTON(detect_by_content)->active)
|
|
72 mpg123_cfg.detect_by = DETECT_CONTENT;
|
|
73 else if (GTK_TOGGLE_BUTTON(detect_by_extension)->active)
|
|
74 mpg123_cfg.detect_by = DETECT_EXTENSION;
|
|
75 else if (GTK_TOGGLE_BUTTON(detect_by_both)->active)
|
|
76 mpg123_cfg.detect_by = DETECT_BOTH;
|
|
77 else
|
|
78 mpg123_cfg.detect_by = DETECT_EXTENSION;
|
|
79
|
|
80 mpg123_cfg.http_buffer_size =
|
|
81 (gint) GTK_ADJUSTMENT(streaming_size_adj)->value;
|
|
82 mpg123_cfg.http_prebuffer =
|
|
83 (gint) GTK_ADJUSTMENT(streaming_pre_adj)->value;
|
|
84
|
|
85 mpg123_cfg.use_proxy =
|
|
86 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
|
|
87 g_free(mpg123_cfg.proxy_host);
|
|
88 mpg123_cfg.proxy_host =
|
|
89 g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_host_entry)));
|
|
90 mpg123_cfg.proxy_port =
|
|
91 atoi(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_port_entry)));
|
|
92
|
|
93 mpg123_cfg.proxy_use_auth =
|
|
94 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
|
|
95 (streaming_proxy_auth_use));
|
|
96
|
|
97 if (mpg123_cfg.proxy_user)
|
|
98 g_free(mpg123_cfg.proxy_user);
|
|
99 mpg123_cfg.proxy_user = NULL;
|
|
100 if (strlen
|
|
101 (gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_user_entry))) > 0)
|
|
102 mpg123_cfg.proxy_user =
|
|
103 g_strdup(gtk_entry_get_text
|
|
104 (GTK_ENTRY(streaming_proxy_auth_user_entry)));
|
|
105
|
|
106 if (mpg123_cfg.proxy_pass)
|
|
107 g_free(mpg123_cfg.proxy_pass);
|
|
108 mpg123_cfg.proxy_pass = NULL;
|
|
109 if (strlen
|
|
110 (gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_pass_entry))) > 0)
|
|
111 mpg123_cfg.proxy_pass =
|
|
112 g_strdup(gtk_entry_get_text
|
|
113 (GTK_ENTRY(streaming_proxy_auth_pass_entry)));
|
|
114
|
|
115
|
|
116 mpg123_cfg.save_http_stream =
|
|
117 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
|
|
118 if (mpg123_cfg.save_http_path)
|
|
119 g_free(mpg123_cfg.save_http_path);
|
|
120 mpg123_cfg.save_http_path =
|
|
121 g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_save_entry)));
|
|
122
|
|
123 mpg123_cfg.use_udp_channel =
|
|
124 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_udp_title));
|
|
125
|
|
126 mpg123_cfg.title_override =
|
|
127 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_override));
|
|
128 mpg123_cfg.disable_id3v2 =
|
|
129 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_id3v2_disable));
|
|
130 g_free(mpg123_cfg.id3_format);
|
|
131 mpg123_cfg.id3_format =
|
|
132 g_strdup(gtk_entry_get_text(GTK_ENTRY(title_id3_entry)));
|
|
133
|
|
134 mpg123_cfg.title_encoding_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_encoding_enabled));
|
|
135 mpg123_cfg.title_encoding = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_encoding)));
|
|
136 if (mpg123_cfg.title_encoding_enabled)
|
|
137 mpg123_id3_encoding_list = g_strsplit_set(mpg123_cfg.title_encoding, ENCODING_SEPARATOR, 0);
|
|
138 db = bmp_cfg_db_open();
|
|
139 bmp_cfg_db_set_int(db, "MPG123", "resolution", mpg123_cfg.resolution);
|
|
140 bmp_cfg_db_set_int(db, "MPG123", "channels", mpg123_cfg.channels);
|
|
141 bmp_cfg_db_set_int(db, "MPG123", "downsample", mpg123_cfg.downsample);
|
|
142 bmp_cfg_db_set_int(db, "MPG123", "http_buffer_size",
|
|
143 mpg123_cfg.http_buffer_size);
|
|
144 bmp_cfg_db_set_int(db, "MPG123", "http_prebuffer",
|
|
145 mpg123_cfg.http_prebuffer);
|
|
146 bmp_cfg_db_set_bool(db, "MPG123", "use_proxy", mpg123_cfg.use_proxy);
|
|
147 bmp_cfg_db_set_string(db, "MPG123", "proxy_host", mpg123_cfg.proxy_host);
|
|
148 bmp_cfg_db_set_int(db, "MPG123", "proxy_port", mpg123_cfg.proxy_port);
|
|
149 bmp_cfg_db_set_bool(db, "MPG123", "proxy_use_auth",
|
|
150 mpg123_cfg.proxy_use_auth);
|
|
151 if (mpg123_cfg.proxy_user)
|
|
152 bmp_cfg_db_set_string(db, "MPG123", "proxy_user",
|
|
153 mpg123_cfg.proxy_user);
|
|
154 else
|
|
155 bmp_cfg_db_unset_key(db, "MPG123", "proxy_user");
|
|
156 if (mpg123_cfg.proxy_pass)
|
|
157 bmp_cfg_db_set_string(db, "MPG123", "proxy_pass",
|
|
158 mpg123_cfg.proxy_pass);
|
|
159 else
|
|
160 bmp_cfg_db_unset_key(db, "MPG123", "proxy_pass");
|
|
161 bmp_cfg_db_set_bool(db, "MPG123", "save_http_stream",
|
|
162 mpg123_cfg.save_http_stream);
|
|
163 bmp_cfg_db_set_string(db, "MPG123", "save_http_path",
|
|
164 mpg123_cfg.save_http_path);
|
|
165 bmp_cfg_db_set_bool(db, "MPG123", "use_udp_channel",
|
|
166 mpg123_cfg.use_udp_channel);
|
|
167 bmp_cfg_db_set_bool(db, "MPG123", "title_override",
|
|
168 mpg123_cfg.title_override);
|
|
169 bmp_cfg_db_set_bool(db, "MPG123", "disable_id3v2",
|
|
170 mpg123_cfg.disable_id3v2);
|
|
171 bmp_cfg_db_set_string(db, "MPG123", "id3_format", mpg123_cfg.id3_format);
|
|
172 bmp_cfg_db_set_int(db, "MPG123", "detect_by", mpg123_cfg.detect_by);
|
|
173
|
|
174 /* Encoding patch */
|
|
175 bmp_cfg_db_set_bool(db, "MPG123", "title_encoding_enabled", mpg123_cfg.title_encoding_enabled);
|
|
176 bmp_cfg_db_set_string(db, "MPG123", "title_encoding", mpg123_cfg.title_encoding);
|
|
177 /* Encoding patch */
|
|
178
|
|
179 bmp_cfg_db_close(db);
|
|
180 gtk_widget_destroy(mpg123_configurewin);
|
|
181 }
|
|
182
|
|
183 static void
|
|
184 proxy_use_cb(GtkWidget * w, gpointer data)
|
|
185 {
|
|
186 gboolean use_proxy, use_proxy_auth;
|
|
187
|
|
188 use_proxy =
|
|
189 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
|
|
190 use_proxy_auth =
|
|
191 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
|
|
192 (streaming_proxy_auth_use));
|
|
193
|
|
194 gtk_widget_set_sensitive(streaming_proxy_hbox, use_proxy);
|
|
195 gtk_widget_set_sensitive(streaming_proxy_auth_use, use_proxy);
|
|
196 gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy
|
|
197 && use_proxy_auth);
|
|
198 }
|
|
199
|
|
200 static void
|
|
201 proxy_auth_use_cb(GtkWidget * w, gpointer data)
|
|
202 {
|
|
203 gboolean use_proxy, use_proxy_auth;
|
|
204
|
|
205 use_proxy =
|
|
206 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
|
|
207 use_proxy_auth =
|
|
208 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
|
|
209 (streaming_proxy_auth_use));
|
|
210
|
|
211 gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy
|
|
212 && use_proxy_auth);
|
|
213 }
|
|
214
|
|
215 static void
|
|
216 streaming_save_dirbrowser_cb(gchar * dir)
|
|
217 {
|
|
218 gtk_entry_set_text(GTK_ENTRY(streaming_save_entry), dir);
|
|
219 }
|
|
220
|
|
221 static void
|
|
222 streaming_save_browse_cb(GtkWidget * w, gpointer data)
|
|
223 {
|
|
224 if (!streaming_save_dirbrowser) {
|
|
225 streaming_save_dirbrowser =
|
|
226 xmms_create_dir_browser(_
|
|
227 ("Select the directory where you want to store the MPEG streams:"),
|
|
228 mpg123_cfg.save_http_path,
|
|
229 GTK_SELECTION_SINGLE,
|
|
230 streaming_save_dirbrowser_cb);
|
|
231 g_signal_connect(G_OBJECT(streaming_save_dirbrowser), "destroy",
|
|
232 G_CALLBACK(gtk_widget_destroyed),
|
|
233 &streaming_save_dirbrowser);
|
|
234 gtk_window_set_transient_for(GTK_WINDOW(streaming_save_dirbrowser),
|
|
235 GTK_WINDOW(mpg123_configurewin));
|
|
236 gtk_widget_show(streaming_save_dirbrowser);
|
|
237 }
|
|
238 }
|
|
239
|
|
240 static void
|
|
241 streaming_save_use_cb(GtkWidget * w, gpointer data)
|
|
242 {
|
|
243 gboolean save_stream;
|
|
244
|
|
245 save_stream =
|
|
246 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
|
|
247
|
|
248 gtk_widget_set_sensitive(streaming_save_hbox, save_stream);
|
|
249 }
|
|
250
|
|
251 static void
|
|
252 title_override_cb(GtkWidget * w, gpointer data)
|
|
253 {
|
|
254 gboolean override;
|
|
255 override =
|
|
256 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_override));
|
|
257 gtk_widget_set_sensitive(title_id3_box, override);
|
|
258 gtk_widget_set_sensitive(title_tag_desc, override);
|
|
259 }
|
|
260
|
|
261 /* Encoding patch */
|
|
262 static void
|
|
263 title_encoding_enabled_cb(GtkWidget * w, gpointer data)
|
|
264 {
|
|
265 gboolean encoding_enabled;
|
|
266 encoding_enabled =
|
|
267 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_encoding_enabled));
|
|
268 gtk_widget_set_sensitive(title_encoding_hbox, encoding_enabled);
|
|
269 }
|
|
270 /* Encoding patch */
|
|
271
|
|
272 static void
|
|
273 configure_destroy(GtkWidget * w, gpointer data)
|
|
274 {
|
|
275 if (streaming_save_dirbrowser)
|
|
276 gtk_widget_destroy(streaming_save_dirbrowser);
|
|
277 }
|
|
278
|
|
279 void
|
|
280 mpg123_configure(void)
|
|
281 {
|
|
282 GtkWidget *streaming_vbox;
|
|
283 GtkWidget *streaming_buf_frame, *streaming_buf_hbox;
|
|
284 GtkWidget *streaming_size_box, *streaming_size_label,
|
|
285 *streaming_size_spin;
|
|
286 GtkWidget *streaming_pre_box, *streaming_pre_label, *streaming_pre_spin;
|
|
287 GtkWidget *streaming_proxy_frame, *streaming_proxy_vbox;
|
|
288 GtkWidget *streaming_proxy_port_label, *streaming_proxy_host_label;
|
|
289 GtkWidget *streaming_save_frame, *streaming_save_vbox;
|
|
290 GtkWidget *streaming_save_label, *streaming_save_browse;
|
|
291 GtkWidget *streaming_cast_frame, *streaming_cast_vbox;
|
|
292 GtkWidget *title_frame, *title_id3_vbox, *title_id3_label;
|
|
293 GtkWidget *bbox, *ok, *cancel;
|
|
294
|
|
295 char *temp;
|
|
296
|
|
297 if (mpg123_configurewin != NULL) {
|
|
298 gtk_window_present(GTK_WINDOW(mpg123_configurewin));
|
|
299 return;
|
|
300 }
|
|
301 mpg123_configurewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
302 gtk_window_set_type_hint(GTK_WINDOW(mpg123_configurewin),
|
|
303 GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
304 gtk_window_set_position(GTK_WINDOW(mpg123_configurewin),
|
|
305 GTK_WIN_POS_CENTER);
|
|
306 g_signal_connect(G_OBJECT(mpg123_configurewin), "destroy",
|
|
307 G_CALLBACK(gtk_widget_destroyed), &mpg123_configurewin);
|
|
308 g_signal_connect(G_OBJECT(mpg123_configurewin), "destroy",
|
|
309 G_CALLBACK(configure_destroy), &mpg123_configurewin);
|
|
310 gtk_window_set_title(GTK_WINDOW(mpg123_configurewin),
|
|
311 _("MPEG Audio Plugin Configuration"));
|
|
312 gtk_window_set_resizable(GTK_WINDOW(mpg123_configurewin), FALSE);
|
|
313 /* gtk_window_set_position(GTK_WINDOW(mpg123_configurewin), GTK_WIN_POS_MOUSE); */
|
|
314 gtk_container_border_width(GTK_CONTAINER(mpg123_configurewin), 10);
|
|
315
|
|
316 vbox = gtk_vbox_new(FALSE, 10);
|
|
317 gtk_container_add(GTK_CONTAINER(mpg123_configurewin), vbox);
|
|
318
|
|
319 notebook = gtk_notebook_new();
|
|
320 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
|
|
321
|
|
322 decode_vbox = gtk_vbox_new(FALSE, 5);
|
|
323 gtk_container_set_border_width(GTK_CONTAINER(decode_vbox), 5);
|
|
324
|
|
325 decode_hbox1 = gtk_hbox_new(TRUE, 5);
|
|
326 gtk_box_pack_start(GTK_BOX(decode_vbox), decode_hbox1, FALSE, FALSE, 0);
|
|
327
|
|
328 decode_res_frame = gtk_frame_new(_("Resolution:"));
|
|
329 gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_res_frame, TRUE, TRUE,
|
|
330 0);
|
|
331
|
|
332 decode_res_vbox = gtk_vbox_new(FALSE, 5);
|
|
333 gtk_container_set_border_width(GTK_CONTAINER(decode_res_vbox), 5);
|
|
334 gtk_container_add(GTK_CONTAINER(decode_res_frame), decode_res_vbox);
|
|
335
|
|
336 decode_res_16 = gtk_radio_button_new_with_label(NULL, _("16 bit"));
|
|
337 if (mpg123_cfg.resolution == 16)
|
|
338 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_16), TRUE);
|
|
339 gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_16, FALSE,
|
|
340 FALSE, 0);
|
|
341
|
|
342 decode_res_8 =
|
|
343 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
344 (GTK_RADIO_BUTTON(decode_res_16)),
|
|
345 _("8 bit"));
|
|
346 if (mpg123_cfg.resolution == 8)
|
|
347 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_res_8), TRUE);
|
|
348
|
|
349 gtk_box_pack_start(GTK_BOX(decode_res_vbox), decode_res_8, FALSE,
|
|
350 FALSE, 0);
|
|
351
|
|
352 decode_ch_frame = gtk_frame_new(_("Channels:"));
|
|
353 gtk_box_pack_start(GTK_BOX(decode_hbox1), decode_ch_frame, TRUE, TRUE, 0);
|
|
354
|
|
355 decode_ch_vbox = gtk_vbox_new(FALSE, 5);
|
|
356 gtk_container_set_border_width(GTK_CONTAINER(decode_ch_vbox), 5);
|
|
357 gtk_container_add(GTK_CONTAINER(decode_ch_frame), decode_ch_vbox);
|
|
358
|
|
359 decode_ch_stereo =
|
|
360 gtk_radio_button_new_with_label(NULL, _("Stereo (if available)"));
|
|
361 if (mpg123_cfg.channels == 2)
|
|
362 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_stereo),
|
|
363 TRUE);
|
|
364
|
|
365 gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_stereo, FALSE,
|
|
366 FALSE, 0);
|
|
367
|
|
368 decode_ch_mono =
|
|
369 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
370 (GTK_RADIO_BUTTON
|
|
371 (decode_ch_stereo)), _("Mono"));
|
|
372 if (mpg123_cfg.channels == 1)
|
|
373 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_ch_mono), TRUE);
|
|
374
|
|
375 gtk_box_pack_start(GTK_BOX(decode_ch_vbox), decode_ch_mono, FALSE,
|
|
376 FALSE, 0);
|
|
377
|
|
378 decode_freq_frame = gtk_frame_new(_("Down sample:"));
|
|
379 gtk_box_pack_start(GTK_BOX(decode_vbox), decode_freq_frame, FALSE,
|
|
380 FALSE, 0);
|
|
381
|
|
382 decode_freq_vbox = gtk_vbox_new(FALSE, 5);
|
|
383 gtk_container_set_border_width(GTK_CONTAINER(decode_freq_vbox), 5);
|
|
384 gtk_container_add(GTK_CONTAINER(decode_freq_frame), decode_freq_vbox);
|
|
385
|
|
386 decode_freq_1to1 =
|
|
387 gtk_radio_button_new_with_label(NULL, _("1:1 (44 kHz)"));
|
|
388 if (mpg123_cfg.downsample == 0)
|
|
389 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to1),
|
|
390 TRUE);
|
|
391 gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to1, FALSE,
|
|
392 FALSE, 0);
|
|
393
|
|
394 decode_freq_1to2 =
|
|
395 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
396 (GTK_RADIO_BUTTON
|
|
397 (decode_freq_1to1)),
|
|
398 _("1:2 (22 kHz)"));
|
|
399 if (mpg123_cfg.downsample == 1)
|
|
400 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to2),
|
|
401 TRUE);
|
|
402 gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to2, FALSE,
|
|
403 FALSE, 0);
|
|
404
|
|
405 decode_freq_1to4 =
|
|
406 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
407 (GTK_RADIO_BUTTON
|
|
408 (decode_freq_1to1)),
|
|
409 _("1:4 (11 kHz)"));
|
|
410 if (mpg123_cfg.downsample == 2)
|
|
411 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_freq_1to4),
|
|
412 TRUE);
|
|
413
|
|
414 gtk_box_pack_start(GTK_BOX(decode_freq_vbox), decode_freq_1to4, FALSE,
|
|
415 FALSE, 0);
|
|
416
|
|
417 option_frame = gtk_frame_new(_("Options"));
|
|
418 gtk_box_pack_start(GTK_BOX(decode_vbox), option_frame, FALSE, FALSE, 0);
|
|
419
|
|
420 option_vbox = gtk_vbox_new(FALSE, 5);
|
|
421 gtk_container_set_border_width(GTK_CONTAINER(option_vbox), 5);
|
|
422 gtk_container_add(GTK_CONTAINER(option_frame), option_vbox);
|
|
423
|
|
424 detect_by_content = gtk_radio_button_new_with_label(NULL, _("Content"));
|
|
425
|
|
426 detect_by_extension =
|
|
427 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
428 (GTK_RADIO_BUTTON
|
|
429 (detect_by_content)),
|
|
430 _("Extension"));
|
|
431
|
|
432 detect_by_both =
|
|
433 gtk_radio_button_new_with_label(gtk_radio_button_group
|
|
434 (GTK_RADIO_BUTTON
|
|
435 (detect_by_content)),
|
|
436 _("Extension and content"));
|
|
437
|
|
438 switch (mpg123_cfg.detect_by) {
|
|
439 case DETECT_CONTENT:
|
|
440 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(detect_by_content),
|
|
441 TRUE);
|
|
442 break;
|
|
443 case DETECT_BOTH:
|
|
444 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(detect_by_both), TRUE);
|
|
445 break;
|
|
446 case DETECT_EXTENSION:
|
|
447 default:
|
|
448 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
|
|
449 (detect_by_extension), TRUE);
|
|
450 break;
|
|
451 }
|
|
452
|
|
453 gtk_box_pack_start(GTK_BOX(option_vbox), detect_by_content, FALSE,
|
|
454 FALSE, 0);
|
|
455 gtk_box_pack_start(GTK_BOX(option_vbox), detect_by_extension, FALSE,
|
|
456 FALSE, 0);
|
|
457 gtk_box_pack_start(GTK_BOX(option_vbox), detect_by_both, FALSE, FALSE, 0);
|
|
458
|
|
459 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), decode_vbox,
|
|
460 gtk_label_new(_("Decoder")));
|
|
461
|
|
462 streaming_vbox = gtk_vbox_new(FALSE, 0);
|
|
463
|
|
464 streaming_buf_frame = gtk_frame_new(_("Buffering:"));
|
|
465 gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_frame), 5);
|
|
466 gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_buf_frame, FALSE,
|
|
467 FALSE, 0);
|
|
468
|
|
469 streaming_buf_hbox = gtk_hbox_new(TRUE, 5);
|
|
470 gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_hbox), 5);
|
|
471 gtk_container_add(GTK_CONTAINER(streaming_buf_frame), streaming_buf_hbox);
|
|
472
|
|
473 streaming_size_box = gtk_hbox_new(FALSE, 5);
|
|
474 /*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_size_box,0,1,0,1); */
|
|
475 gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_size_box,
|
|
476 TRUE, TRUE, 0);
|
|
477 streaming_size_label = gtk_label_new(_("Buffer size (kb):"));
|
|
478 gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_label,
|
|
479 FALSE, FALSE, 0);
|
|
480 streaming_size_adj =
|
|
481 gtk_adjustment_new(mpg123_cfg.http_buffer_size, 4, 4096, 4, 4, 4);
|
|
482 streaming_size_spin =
|
|
483 gtk_spin_button_new(GTK_ADJUSTMENT(streaming_size_adj), 8, 0);
|
|
484 gtk_widget_set_usize(streaming_size_spin, 60, -1);
|
|
485 gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_spin,
|
|
486 FALSE, FALSE, 0);
|
|
487
|
|
488 streaming_pre_box = gtk_hbox_new(FALSE, 5);
|
|
489 /*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_pre_box,1,2,0,1); */
|
|
490 gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_pre_box,
|
|
491 TRUE, TRUE, 0);
|
|
492 streaming_pre_label = gtk_label_new(_("Pre-buffer (percent):"));
|
|
493 gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_label,
|
|
494 FALSE, FALSE, 0);
|
|
495 streaming_pre_adj =
|
|
496 gtk_adjustment_new(mpg123_cfg.http_prebuffer, 0, 90, 1, 1, 1);
|
|
497 streaming_pre_spin =
|
|
498 gtk_spin_button_new(GTK_ADJUSTMENT(streaming_pre_adj), 1, 0);
|
|
499 gtk_widget_set_usize(streaming_pre_spin, 60, -1);
|
|
500 gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_spin,
|
|
501 FALSE, FALSE, 0);
|
|
502
|
|
503 /*
|
|
504 * Proxy config.
|
|
505 */
|
|
506 streaming_proxy_frame = gtk_frame_new(_("Proxy:"));
|
|
507 gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_frame), 5);
|
|
508 gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_proxy_frame,
|
|
509 FALSE, FALSE, 0);
|
|
510
|
|
511 streaming_proxy_vbox = gtk_vbox_new(FALSE, 5);
|
|
512 gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_vbox), 5);
|
|
513 gtk_container_add(GTK_CONTAINER(streaming_proxy_frame),
|
|
514 streaming_proxy_vbox);
|
|
515
|
|
516 streaming_proxy_use = gtk_check_button_new_with_label(_("Use proxy"));
|
|
517 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_proxy_use),
|
|
518 mpg123_cfg.use_proxy);
|
|
519 g_signal_connect(G_OBJECT(streaming_proxy_use), "clicked",
|
|
520 G_CALLBACK(proxy_use_cb), NULL);
|
|
521 gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_use,
|
|
522 FALSE, FALSE, 0);
|
|
523
|
|
524 streaming_proxy_hbox = gtk_hbox_new(FALSE, 5);
|
|
525 gtk_widget_set_sensitive(streaming_proxy_hbox, mpg123_cfg.use_proxy);
|
|
526 gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_hbox,
|
|
527 FALSE, FALSE, 0);
|
|
528
|
|
529 streaming_proxy_host_label = gtk_label_new(_("Host:"));
|
|
530 gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox),
|
|
531 streaming_proxy_host_label, FALSE, FALSE, 0);
|
|
532
|
|
533 streaming_proxy_host_entry = gtk_entry_new();
|
|
534 gtk_entry_set_text(GTK_ENTRY(streaming_proxy_host_entry),
|
|
535 mpg123_cfg.proxy_host);
|
|
536 gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox),
|
|
537 streaming_proxy_host_entry, TRUE, TRUE, 0);
|
|
538
|
|
539 streaming_proxy_port_label = gtk_label_new(_("Port:"));
|
|
540 gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox),
|
|
541 streaming_proxy_port_label, FALSE, FALSE, 0);
|
|
542
|
|
543 streaming_proxy_port_entry = gtk_entry_new();
|
|
544 gtk_widget_set_usize(streaming_proxy_port_entry, 50, -1);
|
|
545 temp = g_strdup_printf("%d", mpg123_cfg.proxy_port);
|
|
546 gtk_entry_set_text(GTK_ENTRY(streaming_proxy_port_entry), temp);
|
|
547 g_free(temp);
|
|
548 gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox),
|
|
549 streaming_proxy_port_entry, FALSE, FALSE, 0);
|
|
550
|
|
551 streaming_proxy_auth_use =
|
|
552 gtk_check_button_new_with_label(_("Use authentication"));
|
|
553 gtk_widget_set_sensitive(streaming_proxy_auth_use, mpg123_cfg.use_proxy);
|
|
554 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
|
|
555 (streaming_proxy_auth_use),
|
|
556 mpg123_cfg.proxy_use_auth);
|
|
557 g_signal_connect(G_OBJECT(streaming_proxy_auth_use), "clicked",
|
|
558 G_CALLBACK(proxy_auth_use_cb), NULL);
|
|
559 gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox),
|
|
560 streaming_proxy_auth_use, FALSE, FALSE, 0);
|
|
561
|
|
562 streaming_proxy_auth_hbox = gtk_hbox_new(FALSE, 5);
|
|
563 gtk_widget_set_sensitive(streaming_proxy_auth_hbox,
|
|
564 mpg123_cfg.use_proxy
|
|
565 && mpg123_cfg.proxy_use_auth);
|
|
566 gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox),
|
|
567 streaming_proxy_auth_hbox, FALSE, FALSE, 0);
|
|
568
|
|
569 streaming_proxy_auth_user_label = gtk_label_new(_("Username:"));
|
|
570 gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox),
|
|
571 streaming_proxy_auth_user_label, FALSE, FALSE, 0);
|
|
572
|
|
573 streaming_proxy_auth_user_entry = gtk_entry_new();
|
|
574 if (mpg123_cfg.proxy_user)
|
|
575 gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_user_entry),
|
|
576 mpg123_cfg.proxy_user);
|
|
577 gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox),
|
|
578 streaming_proxy_auth_user_entry, TRUE, TRUE, 0);
|
|
579
|
|
580 streaming_proxy_auth_pass_label = gtk_label_new(_("Password:"));
|
|
581 gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox),
|
|
582 streaming_proxy_auth_pass_label, FALSE, FALSE, 0);
|
|
583
|
|
584 streaming_proxy_auth_pass_entry = gtk_entry_new();
|
|
585 if (mpg123_cfg.proxy_pass)
|
|
586 gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_pass_entry),
|
|
587 mpg123_cfg.proxy_pass);
|
|
588 gtk_entry_set_visibility(GTK_ENTRY(streaming_proxy_auth_pass_entry),
|
|
589 FALSE);
|
|
590 gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox),
|
|
591 streaming_proxy_auth_pass_entry, TRUE, TRUE, 0);
|
|
592
|
|
593
|
|
594 /*
|
|
595 * Save to disk config.
|
|
596 */
|
|
597 streaming_save_frame = gtk_frame_new(_("Save stream to disk:"));
|
|
598 gtk_container_set_border_width(GTK_CONTAINER(streaming_save_frame), 5);
|
|
599 gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_save_frame,
|
|
600 FALSE, FALSE, 0);
|
|
601
|
|
602 streaming_save_vbox = gtk_vbox_new(FALSE, 5);
|
|
603 gtk_container_set_border_width(GTK_CONTAINER(streaming_save_vbox), 5);
|
|
604 gtk_container_add(GTK_CONTAINER(streaming_save_frame),
|
|
605 streaming_save_vbox);
|
|
606
|
|
607 streaming_save_use =
|
|
608 gtk_check_button_new_with_label(_("Save stream to disk"));
|
|
609 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_save_use),
|
|
610 mpg123_cfg.save_http_stream);
|
|
611 g_signal_connect(G_OBJECT(streaming_save_use), "clicked",
|
|
612 G_CALLBACK(streaming_save_use_cb), NULL);
|
|
613 gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_use,
|
|
614 FALSE, FALSE, 0);
|
|
615
|
|
616 streaming_save_hbox = gtk_hbox_new(FALSE, 5);
|
|
617 gtk_widget_set_sensitive(streaming_save_hbox,
|
|
618 mpg123_cfg.save_http_stream);
|
|
619 gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_hbox,
|
|
620 FALSE, FALSE, 0);
|
|
621
|
|
622 streaming_save_label = gtk_label_new(_("Path:"));
|
|
623 gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_label,
|
|
624 FALSE, FALSE, 0);
|
|
625
|
|
626 streaming_save_entry = gtk_entry_new();
|
|
627 gtk_entry_set_text(GTK_ENTRY(streaming_save_entry),
|
|
628 mpg123_cfg.save_http_path);
|
|
629 gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_entry,
|
|
630 TRUE, TRUE, 0);
|
|
631
|
|
632 streaming_save_browse = gtk_button_new_with_label(_("Browse"));
|
|
633 g_signal_connect(G_OBJECT(streaming_save_browse), "clicked",
|
|
634 G_CALLBACK(streaming_save_browse_cb), NULL);
|
|
635 gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_browse,
|
|
636 FALSE, FALSE, 0);
|
|
637
|
|
638 streaming_cast_frame = gtk_frame_new(_("SHOUT/Icecast:"));
|
|
639 gtk_container_set_border_width(GTK_CONTAINER(streaming_cast_frame), 5);
|
|
640 gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_cast_frame,
|
|
641 FALSE, FALSE, 0);
|
|
642
|
|
643 streaming_cast_vbox = gtk_vbox_new(5, FALSE);
|
|
644 gtk_container_add(GTK_CONTAINER(streaming_cast_frame),
|
|
645 streaming_cast_vbox);
|
|
646
|
|
647 gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_cast_title,
|
|
648 FALSE, FALSE, 0);
|
|
649
|
|
650 streaming_udp_title =
|
|
651 gtk_check_button_new_with_label(_
|
|
652 ("Enable Icecast Metadata UDP Channel"));
|
|
653 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_udp_title),
|
|
654 mpg123_cfg.use_udp_channel);
|
|
655 gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_udp_title,
|
|
656 FALSE, FALSE, 0);
|
|
657
|
|
658 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), streaming_vbox,
|
|
659 gtk_label_new(_("Streaming")));
|
|
660
|
|
661 title_frame = gtk_frame_new(_("ID3 Tags:"));
|
|
662 gtk_container_border_width(GTK_CONTAINER(title_frame), 5);
|
|
663
|
|
664 title_id3_vbox = gtk_vbox_new(FALSE, 10);
|
|
665 gtk_container_border_width(GTK_CONTAINER(title_id3_vbox), 5);
|
|
666 gtk_container_add(GTK_CONTAINER(title_frame), title_id3_vbox);
|
|
667
|
|
668 title_id3v2_disable =
|
|
669 gtk_check_button_new_with_label(_("Disable ID3V2 tags"));
|
|
670 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_id3v2_disable),
|
|
671 mpg123_cfg.disable_id3v2);
|
|
672 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3v2_disable, FALSE,
|
|
673 FALSE, 0);
|
|
674
|
|
675
|
|
676 /* Encoding patch */
|
|
677 title_encoding_enabled =
|
|
678 gtk_check_button_new_with_label(_("Convert non-UTF8 ID3 tags to UTF8"));
|
|
679 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_encoding_enabled),
|
|
680 mpg123_cfg.title_encoding_enabled);
|
|
681 g_signal_connect(G_OBJECT(title_encoding_enabled), "clicked",
|
|
682 G_CALLBACK(title_encoding_enabled_cb), NULL);
|
|
683 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_encoding_enabled, FALSE,
|
|
684 FALSE, 0);
|
|
685
|
|
686 title_encoding_hbox = gtk_hbox_new(FALSE, 5);
|
|
687 gtk_widget_set_sensitive(title_encoding_hbox, mpg123_cfg.title_encoding_enabled);
|
|
688 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_encoding_hbox, FALSE,
|
|
689 FALSE, 0);
|
|
690
|
|
691 title_encoding_label = gtk_label_new(_("ID3 encoding:"));
|
|
692 gtk_box_pack_start(GTK_BOX(title_encoding_hbox), title_encoding_label, FALSE,
|
|
693 FALSE, 0);
|
|
694
|
|
695 title_encoding = gtk_entry_new();
|
|
696 gtk_entry_set_text(GTK_ENTRY(title_encoding), mpg123_cfg.title_encoding);
|
|
697 gtk_box_pack_start(GTK_BOX(title_encoding_hbox), title_encoding, TRUE, TRUE,
|
|
698 0);
|
|
699 /* Encoding patch */
|
|
700
|
|
701
|
|
702 title_override =
|
|
703 gtk_check_button_new_with_label(_("Override generic titles"));
|
|
704 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_override),
|
|
705 mpg123_cfg.title_override);
|
|
706 g_signal_connect(G_OBJECT(title_override), "clicked",
|
|
707 G_CALLBACK(title_override_cb), NULL);
|
|
708 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_override, FALSE,
|
|
709 FALSE, 0);
|
|
710
|
|
711 title_id3_box = gtk_hbox_new(FALSE, 5);
|
|
712 gtk_widget_set_sensitive(title_id3_box, mpg123_cfg.title_override);
|
|
713 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_id3_box, FALSE,
|
|
714 FALSE, 0);
|
|
715
|
|
716 title_id3_label = gtk_label_new(_("ID3 format:"));
|
|
717 gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_label, FALSE,
|
|
718 FALSE, 0);
|
|
719
|
|
720 title_id3_entry = gtk_entry_new();
|
|
721 gtk_entry_set_text(GTK_ENTRY(title_id3_entry), mpg123_cfg.id3_format);
|
|
722 gtk_box_pack_start(GTK_BOX(title_id3_box), title_id3_entry, TRUE, TRUE,
|
|
723 0);
|
|
724
|
|
725 title_tag_desc = xmms_titlestring_descriptions("pafFetnygc", 2);
|
|
726 gtk_widget_set_sensitive(title_tag_desc, mpg123_cfg.title_override);
|
|
727 gtk_box_pack_start(GTK_BOX(title_id3_vbox), title_tag_desc, FALSE,
|
|
728 FALSE, 0);
|
|
729 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame,
|
|
730 gtk_label_new(_("Title")));
|
|
731
|
|
732 bbox = gtk_hbutton_box_new();
|
|
733 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
734 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
|
|
735 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
736
|
|
737 cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
|
738 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
|
|
739 G_CALLBACK(gtk_widget_destroy),
|
|
740 GTK_OBJECT(mpg123_configurewin));
|
|
741 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
|
|
742 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
|
|
743
|
|
744
|
|
745 ok = gtk_button_new_from_stock(GTK_STOCK_OK);
|
|
746 g_signal_connect(G_OBJECT(ok), "clicked",
|
|
747 G_CALLBACK(mpg123_configurewin_ok), NULL);
|
|
748 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
|
|
749 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
|
|
750 gtk_widget_grab_default(ok);
|
|
751
|
|
752 gtk_widget_show_all(mpg123_configurewin);
|
|
753 }
|