comparison Plugins/Input/mpg123/configure.c @ 61:fa848bd484d8 trunk

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