1 /* libxmms-flac - XMMS FLAC input plugin
2  * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Daisuke Shimamura
3  *
4  * Based on mpg123 plugin
5  *          and prefs.c - 2000/05/06
6  *  EasyTAG - Tag editor for MP3 and OGG files
7  *  Copyright (C) 2000-2002  Jerome Couderc <j.couderc@ifrance.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27 
28 #include "plugin.h"
29 
30 #include <stdlib.h>
31 #include <string.h>
32 #include <glib.h>
33 #include <gtk/gtk.h>
34 #include <pthread.h>
35 #include <math.h>
36 
37 #include <xmms/configfile.h>
38 #include <xmms/dirbrowser.h>
39 #include <xmms/titlestring.h>
40 #include <xmms/util.h>
41 #include <xmms/plugin.h>
42 
43 #include "share/replaygain_synthesis.h" /* for NOISE_SHAPING_LOW */
44 #include "charset.h"
45 #include "configure.h"
46 #include "locale_hack.h"
47 
48 /*
49  * Initialize Global Variable
50  */
51 flac_config_t flac_cfg = {
52 	/* title */
53 	{
54 		FALSE, /* tag_override */
55 		NULL, /* tag_format */
56 		FALSE, /* convert_char_set */
57 		NULL /* user_char_set */
58 	},
59 	/* stream */
60 	{
61 		100 /* KB */, /* http_buffer_size */
62 		50, /* http_prebuffer */
63 		FALSE, /* use_proxy */
64 		NULL, /* proxy_host */
65 		0, /* proxy_port */
66 		FALSE, /* proxy_use_auth */
67 		NULL, /* proxy_user */
68 		NULL, /* proxy_pass */
69 		FALSE, /* save_http_stream */
70 		NULL, /* save_http_path */
71 		FALSE, /* cast_title_streaming */
72 		FALSE /* use_udp_channel */
73 	},
74 	/* output */
75 	{
76 		/* replaygain */
77 		{
78 			FALSE, /* enable */
79 			TRUE, /* album_mode */
80 			0, /* preamp */
81 			FALSE /* hard_limit */
82 		},
83 		/* resolution */
84 		{
85 			/* normal */
86 			{
87 				TRUE /* dither_24_to_16 */
88 			},
89 			/* replaygain */
90 			{
91 				TRUE, /* dither */
92 				NOISE_SHAPING_LOW, /* noise_shaping */
93 				16 /* bps_out */
94 			}
95 		}
96 	}
97 };
98 
99 
100 static GtkWidget *flac_configurewin = NULL;
101 static GtkWidget *vbox, *notebook;
102 
103 static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc;
104 static GtkWidget *convert_char_set, *fileCharacterSetEntry, *userCharacterSetEntry;
105 static GtkWidget *replaygain_enable, *replaygain_album_mode;
106 static GtkWidget *replaygain_preamp_hscale, *replaygain_preamp_label, *replaygain_hard_limit;
107 static GtkObject *replaygain_preamp;
108 static GtkWidget *resolution_normal_dither_24_to_16;
109 static GtkWidget *resolution_replaygain_dither;
110 static GtkWidget *resolution_replaygain_noise_shaping_frame;
111 static GtkWidget *resolution_replaygain_noise_shaping_radio_none;
112 static GtkWidget *resolution_replaygain_noise_shaping_radio_low;
113 static GtkWidget *resolution_replaygain_noise_shaping_radio_medium;
114 static GtkWidget *resolution_replaygain_noise_shaping_radio_high;
115 static GtkWidget *resolution_replaygain_bps_out_frame;
116 static GtkWidget *resolution_replaygain_bps_out_radio_16bps;
117 static GtkWidget *resolution_replaygain_bps_out_radio_24bps;
118 
119 static GtkObject *streaming_size_adj, *streaming_pre_adj;
120 static GtkWidget *streaming_proxy_use, *streaming_proxy_host_entry;
121 static GtkWidget *streaming_proxy_port_entry, *streaming_save_use, *streaming_save_entry;
122 static GtkWidget *streaming_proxy_auth_use;
123 static GtkWidget *streaming_proxy_auth_pass_entry, *streaming_proxy_auth_user_entry;
124 static GtkWidget *streaming_proxy_auth_user_label, *streaming_proxy_auth_pass_label;
125 #ifdef FLAC_ICECAST
126 static GtkWidget *streaming_cast_title, *streaming_udp_title;
127 #endif
128 static GtkWidget *streaming_proxy_hbox, *streaming_proxy_auth_hbox, *streaming_save_dirbrowser;
129 static GtkWidget *streaming_save_hbox;
130 
131 static gchar *gtk_entry_get_text_1 (GtkWidget *widget);
132 static void flac_configurewin_ok(GtkWidget * widget, gpointer data);
133 static void configure_destroy(GtkWidget * w, gpointer data);
134 
flac_configurewin_ok(GtkWidget * widget,gpointer data)135 static void flac_configurewin_ok(GtkWidget * widget, gpointer data)
136 {
137 	ConfigFile *cfg;
138 	gchar *filename;
139 
140 	(void)widget, (void)data; /* unused arguments */
141 	g_free(flac_cfg.title.tag_format);
142 	flac_cfg.title.tag_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_tag_entry)));
143 	flac_cfg.title.user_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(userCharacterSetEntry));
144 
145 	filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL);
146 	cfg = xmms_cfg_open_file(filename);
147 	if (!cfg)
148 		cfg = xmms_cfg_new();
149 	/* title */
150 	xmms_cfg_write_boolean(cfg, "flac", "title.tag_override", flac_cfg.title.tag_override);
151 	xmms_cfg_write_string(cfg, "flac", "title.tag_format", flac_cfg.title.tag_format);
152 	xmms_cfg_write_boolean(cfg, "flac", "title.convert_char_set", flac_cfg.title.convert_char_set);
153 	xmms_cfg_write_string(cfg, "flac", "title.user_char_set", flac_cfg.title.user_char_set);
154 	/* output */
155 	xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.enable", flac_cfg.output.replaygain.enable);
156 	xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.album_mode", flac_cfg.output.replaygain.album_mode);
157 	xmms_cfg_write_int(cfg, "flac", "output.replaygain.preamp", flac_cfg.output.replaygain.preamp);
158 	xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.hard_limit", flac_cfg.output.replaygain.hard_limit);
159 	xmms_cfg_write_boolean(cfg, "flac", "output.resolution.normal.dither_24_to_16", flac_cfg.output.resolution.normal.dither_24_to_16);
160 	xmms_cfg_write_boolean(cfg, "flac", "output.resolution.replaygain.dither", flac_cfg.output.resolution.replaygain.dither);
161 	xmms_cfg_write_int(cfg, "flac", "output.resolution.replaygain.noise_shaping", flac_cfg.output.resolution.replaygain.noise_shaping);
162 	xmms_cfg_write_int(cfg, "flac", "output.resolution.replaygain.bps_out", flac_cfg.output.resolution.replaygain.bps_out);
163 	/* streaming */
164 	flac_cfg.stream.http_buffer_size = (gint) GTK_ADJUSTMENT(streaming_size_adj)->value;
165 	flac_cfg.stream.http_prebuffer = (gint) GTK_ADJUSTMENT(streaming_pre_adj)->value;
166 
167 	flac_cfg.stream.use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
168 	if(flac_cfg.stream.proxy_host)
169 		g_free(flac_cfg.stream.proxy_host);
170 	flac_cfg.stream.proxy_host = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_host_entry)));
171 	flac_cfg.stream.proxy_port = atoi(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_port_entry)));
172 
173 	flac_cfg.stream.proxy_use_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
174 
175 	if(flac_cfg.stream.proxy_user)
176 		g_free(flac_cfg.stream.proxy_user);
177 	flac_cfg.stream.proxy_user = NULL;
178 	if(strlen(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_user_entry))) > 0)
179 		flac_cfg.stream.proxy_user = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_user_entry)));
180 
181 	if(flac_cfg.stream.proxy_pass)
182 		g_free(flac_cfg.stream.proxy_pass);
183 	flac_cfg.stream.proxy_pass = NULL;
184 	if(strlen(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_pass_entry))) > 0)
185 		flac_cfg.stream.proxy_pass = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_proxy_auth_pass_entry)));
186 
187 
188 	flac_cfg.stream.save_http_stream = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
189 	if (flac_cfg.stream.save_http_path)
190 		g_free(flac_cfg.stream.save_http_path);
191 	flac_cfg.stream.save_http_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(streaming_save_entry)));
192 
193 #ifdef FLAC_ICECAST
194 	flac_cfg.stream.cast_title_streaming = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_cast_title));
195 	flac_cfg.stream.use_udp_channel = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_udp_title));
196 #endif
197 
198 	xmms_cfg_write_int(cfg, "flac", "stream.http_buffer_size", flac_cfg.stream.http_buffer_size);
199 	xmms_cfg_write_int(cfg, "flac", "stream.http_prebuffer", flac_cfg.stream.http_prebuffer);
200 	xmms_cfg_write_boolean(cfg, "flac", "stream.use_proxy", flac_cfg.stream.use_proxy);
201 	xmms_cfg_write_string(cfg, "flac", "stream.proxy_host", flac_cfg.stream.proxy_host);
202 	xmms_cfg_write_int(cfg, "flac", "stream.proxy_port", flac_cfg.stream.proxy_port);
203 	xmms_cfg_write_boolean(cfg, "flac", "stream.proxy_use_auth", flac_cfg.stream.proxy_use_auth);
204 	if(flac_cfg.stream.proxy_user)
205 		xmms_cfg_write_string(cfg, "flac", "stream.proxy_user", flac_cfg.stream.proxy_user);
206 	else
207 		xmms_cfg_remove_key(cfg, "flac", "stream.proxy_user");
208 	if(flac_cfg.stream.proxy_pass)
209 		xmms_cfg_write_string(cfg, "flac", "stream.proxy_pass", flac_cfg.stream.proxy_pass);
210 	else
211 		xmms_cfg_remove_key(cfg, "flac", "stream.proxy_pass");
212 	xmms_cfg_write_boolean(cfg, "flac", "stream.save_http_stream", flac_cfg.stream.save_http_stream);
213 	xmms_cfg_write_string(cfg, "flac", "stream.save_http_path", flac_cfg.stream.save_http_path);
214 #ifdef FLAC_ICECAST
215 	xmms_cfg_write_boolean(cfg, "flac", "stream.cast_title_streaming", flac_cfg.stream.cast_title_streaming);
216 	xmms_cfg_write_boolean(cfg, "flac", "stream.use_udp_channel", flac_cfg.stream.use_udp_channel);
217 #endif
218 
219 	xmms_cfg_write_file(cfg, filename);
220 	xmms_cfg_free(cfg);
221 	g_free(filename);
222 	gtk_widget_destroy(flac_configurewin);
223 }
224 
configure_destroy(GtkWidget * widget,gpointer data)225 static void configure_destroy(GtkWidget *widget, gpointer data)
226 {
227 	(void)widget, (void)data; /* unused arguments */
228 }
229 
title_tag_override_cb(GtkWidget * widget,gpointer data)230 static void title_tag_override_cb(GtkWidget *widget, gpointer data)
231 {
232 	(void)widget, (void)data; /* unused arguments */
233 	flac_cfg.title.tag_override = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_tag_override));
234 
235 	gtk_widget_set_sensitive(title_tag_box, flac_cfg.title.tag_override);
236 	gtk_widget_set_sensitive(title_desc, flac_cfg.title.tag_override);
237 
238 }
239 
convert_char_set_cb(GtkWidget * widget,gpointer data)240 static void convert_char_set_cb(GtkWidget *widget, gpointer data)
241 {
242 	(void)widget, (void)data; /* unused arguments */
243 	flac_cfg.title.convert_char_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(convert_char_set));
244 
245 	gtk_widget_set_sensitive(fileCharacterSetEntry, FALSE);
246 	gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.title.convert_char_set);
247 }
248 
replaygain_enable_cb(GtkWidget * widget,gpointer data)249 static void replaygain_enable_cb(GtkWidget *widget, gpointer data)
250 {
251 	(void)widget, (void)data; /* unused arguments */
252 	flac_cfg.output.replaygain.enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_enable));
253 
254 	gtk_widget_set_sensitive(replaygain_album_mode, flac_cfg.output.replaygain.enable);
255 	gtk_widget_set_sensitive(replaygain_preamp_hscale, flac_cfg.output.replaygain.enable);
256 	gtk_widget_set_sensitive(replaygain_hard_limit, flac_cfg.output.replaygain.enable);
257 }
258 
replaygain_album_mode_cb(GtkWidget * widget,gpointer data)259 static void replaygain_album_mode_cb(GtkWidget *widget, gpointer data)
260 {
261 	(void)widget, (void)data; /* unused arguments */
262 	flac_cfg.output.replaygain.album_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_album_mode));
263 }
264 
replaygain_hard_limit_cb(GtkWidget * widget,gpointer data)265 static void replaygain_hard_limit_cb(GtkWidget *widget, gpointer data)
266 {
267 	(void)widget, (void)data; /* unused arguments */
268 	flac_cfg.output.replaygain.hard_limit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_hard_limit));
269 }
270 
replaygain_preamp_cb(GtkWidget * widget,gpointer data)271 static void replaygain_preamp_cb(GtkWidget *widget, gpointer data)
272 {
273 	GString *gstring = g_string_new("");
274 	(void)widget, (void)data; /* unused arguments */
275 	flac_cfg.output.replaygain.preamp = (int) floor(GTK_ADJUSTMENT(replaygain_preamp)->value + 0.5);
276 
277 	g_string_sprintf(gstring, "%i dB", flac_cfg.output.replaygain.preamp);
278 	gtk_label_set_text(GTK_LABEL(replaygain_preamp_label), _(gstring->str));
279 }
280 
resolution_normal_dither_24_to_16_cb(GtkWidget * widget,gpointer data)281 static void resolution_normal_dither_24_to_16_cb(GtkWidget *widget, gpointer data)
282 {
283 	(void)widget, (void)data; /* unused arguments */
284 	flac_cfg.output.resolution.normal.dither_24_to_16 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_normal_dither_24_to_16));
285 }
286 
resolution_replaygain_dither_cb(GtkWidget * widget,gpointer data)287 static void resolution_replaygain_dither_cb(GtkWidget *widget, gpointer data)
288 {
289 	(void)widget, (void)data; /* unused arguments */
290 	flac_cfg.output.resolution.replaygain.dither = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_dither));
291 
292 	gtk_widget_set_sensitive(resolution_replaygain_noise_shaping_frame, flac_cfg.output.resolution.replaygain.dither);
293 }
294 
resolution_replaygain_noise_shaping_cb(GtkWidget * widget,gpointer data)295 static void resolution_replaygain_noise_shaping_cb(GtkWidget *widget, gpointer data)
296 {
297 	(void)widget, (void)data; /* unused arguments */
298 	flac_cfg.output.resolution.replaygain.noise_shaping =
299 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_none))? 0 :
300 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_low))? 1 :
301 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_medium))? 2 :
302 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_high))? 3 :
303 		0
304 	;
305 }
306 
resolution_replaygain_bps_out_cb(GtkWidget * widget,gpointer data)307 static void resolution_replaygain_bps_out_cb(GtkWidget *widget, gpointer data)
308 {
309 	(void)widget, (void)data; /* unused arguments */
310 	flac_cfg.output.resolution.replaygain.bps_out =
311 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_16bps))? 16 :
312 		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_24bps))? 24 :
313 		16
314 	;
315 }
316 
proxy_use_cb(GtkWidget * w,gpointer data)317 static void proxy_use_cb(GtkWidget * w, gpointer data)
318 {
319 	gboolean use_proxy, use_proxy_auth;
320 	(void) w;
321 	(void) data;
322 
323 	use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
324 	use_proxy_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
325 
326 	gtk_widget_set_sensitive(streaming_proxy_hbox, use_proxy);
327 	gtk_widget_set_sensitive(streaming_proxy_auth_use, use_proxy);
328 	gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy && use_proxy_auth);
329 }
330 
proxy_auth_use_cb(GtkWidget * w,gpointer data)331 static void proxy_auth_use_cb(GtkWidget *w, gpointer data)
332 {
333 	gboolean use_proxy, use_proxy_auth;
334 	(void) w;
335 	(void) data;
336 
337 	use_proxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_use));
338 	use_proxy_auth = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use));
339 
340 	gtk_widget_set_sensitive(streaming_proxy_auth_hbox, use_proxy && use_proxy_auth);
341 }
342 
streaming_save_dirbrowser_cb(gchar * dir)343 static void streaming_save_dirbrowser_cb(gchar * dir)
344 {
345 	gtk_entry_set_text(GTK_ENTRY(streaming_save_entry), dir);
346 }
347 
streaming_save_browse_cb(GtkWidget * w,gpointer data)348 static void streaming_save_browse_cb(GtkWidget * w, gpointer data)
349 {
350 	(void) w;
351 	(void) data;
352 	if (!streaming_save_dirbrowser)
353 	{
354 		streaming_save_dirbrowser = xmms_create_dir_browser(_("Select the directory where you want to store the MPEG streams:"),
355 								    flac_cfg.stream.save_http_path, GTK_SELECTION_SINGLE, streaming_save_dirbrowser_cb);
356 		gtk_signal_connect(GTK_OBJECT(streaming_save_dirbrowser), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &streaming_save_dirbrowser);
357 		gtk_window_set_transient_for(GTK_WINDOW(streaming_save_dirbrowser), GTK_WINDOW(flac_configurewin));
358 		gtk_widget_show(streaming_save_dirbrowser);
359 	}
360 }
361 
streaming_save_use_cb(GtkWidget * w,gpointer data)362 static void streaming_save_use_cb(GtkWidget * w, gpointer data)
363 {
364 	gboolean save_stream;
365 	(void) w;
366 	(void) data;
367 
368 	save_stream = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(streaming_save_use));
369 
370 	gtk_widget_set_sensitive(streaming_save_hbox, save_stream);
371 }
372 
373 
FLAC_XMMS__configure(void)374 void FLAC_XMMS__configure(void)
375 {
376 	GtkWidget *title_frame, *title_tag_vbox, *title_tag_label;
377 	GtkWidget *replaygain_frame, *resolution_frame, *output_vbox, *resolution_normal_frame, *resolution_replaygain_frame;
378 	GtkWidget *replaygain_vbox, *resolution_hbox, *resolution_normal_vbox, *resolution_replaygain_vbox;
379 	GtkWidget *resolution_replaygain_noise_shaping_vbox;
380 	GtkWidget *resolution_replaygain_bps_out_vbox;
381 	GtkWidget *label, *hbox;
382 	GtkWidget *bbox, *ok, *cancel;
383 	GList *list;
384 
385 	GtkWidget *streaming_vbox;
386 	GtkWidget *streaming_buf_frame, *streaming_buf_hbox;
387 	GtkWidget *streaming_size_box, *streaming_size_label, *streaming_size_spin;
388 	GtkWidget *streaming_pre_box, *streaming_pre_label, *streaming_pre_spin;
389 	GtkWidget *streaming_proxy_frame, *streaming_proxy_vbox;
390 	GtkWidget *streaming_proxy_port_label, *streaming_proxy_host_label;
391 	GtkWidget *streaming_save_frame, *streaming_save_vbox;
392 	GtkWidget *streaming_save_label, *streaming_save_browse;
393 #ifdef FLAC_ICECAST
394 	GtkWidget *streaming_cast_frame, *streaming_cast_vbox;
395 #endif
396 	char *temp;
397 
398 	if (flac_configurewin != NULL) {
399 		gdk_window_raise(flac_configurewin->window);
400 		return;
401 	}
402 	flac_configurewin = gtk_window_new(GTK_WINDOW_DIALOG);
403 	gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &flac_configurewin);
404 	gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(configure_destroy), &flac_configurewin);
405 	gtk_window_set_title(GTK_WINDOW(flac_configurewin), _("Flac Configuration"));
406 	gtk_window_set_policy(GTK_WINDOW(flac_configurewin), FALSE, FALSE, FALSE);
407 	gtk_container_border_width(GTK_CONTAINER(flac_configurewin), 10);
408 
409 	vbox = gtk_vbox_new(FALSE, 10);
410 	gtk_container_add(GTK_CONTAINER(flac_configurewin), vbox);
411 
412 	notebook = gtk_notebook_new();
413 	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
414 
415 	/* Title config.. */
416 
417 	title_frame = gtk_frame_new(_("Tag Handling"));
418 	gtk_container_border_width(GTK_CONTAINER(title_frame), 5);
419 
420 	title_tag_vbox = gtk_vbox_new(FALSE, 10);
421 	gtk_container_border_width(GTK_CONTAINER(title_tag_vbox), 5);
422 	gtk_container_add(GTK_CONTAINER(title_frame), title_tag_vbox);
423 
424 	/* Convert Char Set */
425 
426 	convert_char_set = gtk_check_button_new_with_label(_("Convert Character Set"));
427 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(convert_char_set), flac_cfg.title.convert_char_set);
428 	gtk_signal_connect(GTK_OBJECT(convert_char_set), "clicked", convert_char_set_cb, NULL);
429 	gtk_box_pack_start(GTK_BOX(title_tag_vbox), convert_char_set, FALSE, FALSE, 0);
430 	/*  Combo boxes... */
431 	hbox = gtk_hbox_new(FALSE,4);
432 	gtk_container_add(GTK_CONTAINER(title_tag_vbox),hbox);
433 	label = gtk_label_new(_("Convert character set from :"));
434 	gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
435 	fileCharacterSetEntry = gtk_combo_new();
436 	gtk_box_pack_start(GTK_BOX(hbox),fileCharacterSetEntry,TRUE,TRUE,0);
437 
438 	label = gtk_label_new (_("to :"));
439 	gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
440 	userCharacterSetEntry = gtk_combo_new();
441 	gtk_box_pack_start(GTK_BOX(hbox),userCharacterSetEntry,TRUE,TRUE,0);
442 
443 	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(fileCharacterSetEntry)->entry),FALSE);
444 	gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(userCharacterSetEntry)->entry),FALSE);
445 	gtk_combo_set_value_in_list(GTK_COMBO(fileCharacterSetEntry),TRUE,FALSE);
446 	gtk_combo_set_value_in_list(GTK_COMBO(userCharacterSetEntry),TRUE,FALSE);
447 
448 	list = Charset_Create_List();
449 	gtk_combo_set_popdown_strings(GTK_COMBO(fileCharacterSetEntry),Charset_Create_List_UTF8_Only());
450 	gtk_combo_set_popdown_strings(GTK_COMBO(userCharacterSetEntry),list);
451 	gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(userCharacterSetEntry)->entry),Charset_Get_Title_From_Name(flac_cfg.title.user_char_set));
452 	gtk_widget_set_sensitive(fileCharacterSetEntry, FALSE);
453 	gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.title.convert_char_set);
454 
455 	/* Override Tagging Format */
456 
457 	title_tag_override = gtk_check_button_new_with_label(_("Override generic titles"));
458 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_tag_override), flac_cfg.title.tag_override);
459 	gtk_signal_connect(GTK_OBJECT(title_tag_override), "clicked", title_tag_override_cb, NULL);
460 	gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_tag_override, FALSE, FALSE, 0);
461 
462 	title_tag_box = gtk_hbox_new(FALSE, 5);
463 	gtk_widget_set_sensitive(title_tag_box, flac_cfg.title.tag_override);
464 	gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_tag_box, FALSE, FALSE, 0);
465 
466 	title_tag_label = gtk_label_new(_("Title format:"));
467 	gtk_box_pack_start(GTK_BOX(title_tag_box), title_tag_label, FALSE, FALSE, 0);
468 
469 	title_tag_entry = gtk_entry_new();
470 	gtk_entry_set_text(GTK_ENTRY(title_tag_entry), flac_cfg.title.tag_format);
471 	gtk_box_pack_start(GTK_BOX(title_tag_box), title_tag_entry, TRUE, TRUE, 0);
472 
473 	title_desc = xmms_titlestring_descriptions("pafFetnygc", 2);
474 	gtk_widget_set_sensitive(title_desc, flac_cfg.title.tag_override);
475 	gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_desc, FALSE, FALSE, 0);
476 
477 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, gtk_label_new(_("Title")));
478 
479 	/* Output config.. */
480 
481 	output_vbox = gtk_vbox_new(FALSE, 10);
482 	gtk_container_border_width(GTK_CONTAINER(output_vbox), 5);
483 
484 	/* replaygain */
485 
486 	replaygain_frame = gtk_frame_new(_("ReplayGain"));
487 	gtk_container_border_width(GTK_CONTAINER(replaygain_frame), 5);
488 	gtk_box_pack_start(GTK_BOX(output_vbox), replaygain_frame, TRUE, TRUE, 0);
489 
490 	replaygain_vbox = gtk_vbox_new(FALSE, 10);
491 	gtk_container_border_width(GTK_CONTAINER(replaygain_vbox), 5);
492 	gtk_container_add(GTK_CONTAINER(replaygain_frame), replaygain_vbox);
493 
494 	replaygain_enable = gtk_check_button_new_with_label(_("Enable ReplayGain processing"));
495 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_enable), flac_cfg.output.replaygain.enable);
496 	gtk_signal_connect(GTK_OBJECT(replaygain_enable), "clicked", replaygain_enable_cb, NULL);
497 	gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_enable, FALSE, FALSE, 0);
498 
499 	replaygain_album_mode = gtk_check_button_new_with_label(_("Album mode"));
500 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_album_mode), flac_cfg.output.replaygain.album_mode);
501 	gtk_signal_connect(GTK_OBJECT(replaygain_album_mode), "clicked", replaygain_album_mode_cb, NULL);
502 	gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_album_mode, FALSE, FALSE, 0);
503 
504 	hbox = gtk_hbox_new(FALSE,3);
505 	gtk_container_add(GTK_CONTAINER(replaygain_vbox),hbox);
506 	label = gtk_label_new(_("Preamp:"));
507 	gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
508 	replaygain_preamp = gtk_adjustment_new(flac_cfg.output.replaygain.preamp, -24.0, +24.0, 1.0, 6.0, 0.0);
509 	gtk_signal_connect(GTK_OBJECT(replaygain_preamp), "value-changed", replaygain_preamp_cb, NULL);
510 	replaygain_preamp_hscale = gtk_hscale_new(GTK_ADJUSTMENT(replaygain_preamp));
511 	gtk_scale_set_draw_value(GTK_SCALE(replaygain_preamp_hscale), FALSE);
512 	gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_hscale,TRUE,TRUE,0);
513 	replaygain_preamp_label = gtk_label_new(_("0 dB"));
514 	gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_label,FALSE,FALSE,0);
515 	gtk_adjustment_value_changed(GTK_ADJUSTMENT(replaygain_preamp));
516 
517 	replaygain_hard_limit = gtk_check_button_new_with_label(_("6dB hard limiting"));
518 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_hard_limit), flac_cfg.output.replaygain.hard_limit);
519 	gtk_signal_connect(GTK_OBJECT(replaygain_hard_limit), "clicked", replaygain_hard_limit_cb, NULL);
520 	gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_hard_limit, FALSE, FALSE, 0);
521 
522 	replaygain_enable_cb(replaygain_enable, NULL);
523 
524 	/* resolution */
525 
526 	resolution_frame = gtk_frame_new(_("Resolution"));
527 	gtk_container_border_width(GTK_CONTAINER(resolution_frame), 5);
528 	gtk_box_pack_start(GTK_BOX(output_vbox), resolution_frame, TRUE, TRUE, 0);
529 
530 	resolution_hbox = gtk_hbox_new(FALSE, 10);
531 	gtk_container_border_width(GTK_CONTAINER(resolution_hbox), 5);
532 	gtk_container_add(GTK_CONTAINER(resolution_frame), resolution_hbox);
533 
534 	resolution_normal_frame = gtk_frame_new(_("Without ReplayGain"));
535 	gtk_container_border_width(GTK_CONTAINER(resolution_normal_frame), 5);
536 	gtk_box_pack_start(GTK_BOX(resolution_hbox), resolution_normal_frame, TRUE, TRUE, 0);
537 
538 	resolution_normal_vbox = gtk_vbox_new(FALSE, 10);
539 	gtk_container_border_width(GTK_CONTAINER(resolution_normal_vbox), 5);
540 	gtk_container_add(GTK_CONTAINER(resolution_normal_frame), resolution_normal_vbox);
541 
542 	resolution_normal_dither_24_to_16 = gtk_check_button_new_with_label(_("Dither 24bps to 16bps"));
543 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_normal_dither_24_to_16), flac_cfg.output.resolution.normal.dither_24_to_16);
544 	gtk_signal_connect(GTK_OBJECT(resolution_normal_dither_24_to_16), "clicked", resolution_normal_dither_24_to_16_cb, NULL);
545 	gtk_box_pack_start(GTK_BOX(resolution_normal_vbox), resolution_normal_dither_24_to_16, FALSE, FALSE, 0);
546 
547 	resolution_replaygain_frame = gtk_frame_new(_("With ReplayGain"));
548 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_frame), 5);
549 	gtk_box_pack_start(GTK_BOX(resolution_hbox), resolution_replaygain_frame, TRUE, TRUE, 0);
550 
551 	resolution_replaygain_vbox = gtk_vbox_new(FALSE, 10);
552 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_vbox), 5);
553 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_frame), resolution_replaygain_vbox);
554 
555 	resolution_replaygain_dither = gtk_check_button_new_with_label(_("Enable dithering"));
556 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_dither), flac_cfg.output.resolution.replaygain.dither);
557 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_dither), "clicked", resolution_replaygain_dither_cb, NULL);
558 	gtk_box_pack_start(GTK_BOX(resolution_replaygain_vbox), resolution_replaygain_dither, FALSE, FALSE, 0);
559 
560 	hbox = gtk_hbox_new(FALSE, 10);
561 	gtk_container_border_width(GTK_CONTAINER(hbox), 5);
562 	gtk_box_pack_start(GTK_BOX(resolution_replaygain_vbox), hbox, TRUE, TRUE, 0);
563 
564 	resolution_replaygain_noise_shaping_frame = gtk_frame_new(_("Noise shaping"));
565 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_noise_shaping_frame), 5);
566 	gtk_box_pack_start(GTK_BOX(hbox), resolution_replaygain_noise_shaping_frame, TRUE, TRUE, 0);
567 
568 	resolution_replaygain_noise_shaping_vbox = gtk_vbutton_box_new();
569 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), 5);
570 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_frame), resolution_replaygain_noise_shaping_vbox);
571 
572 	resolution_replaygain_noise_shaping_radio_none = gtk_radio_button_new_with_label(NULL, _("none"));
573 	if(flac_cfg.output.resolution.replaygain.noise_shaping == 0)
574 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_none), TRUE);
575 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_none), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
576 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_none);
577 
578 	resolution_replaygain_noise_shaping_radio_low = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("low"));
579 	if(flac_cfg.output.resolution.replaygain.noise_shaping == 1)
580 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_low), TRUE);
581 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_low), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
582 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_low);
583 
584 	resolution_replaygain_noise_shaping_radio_medium = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("medium"));
585 	if(flac_cfg.output.resolution.replaygain.noise_shaping == 2)
586 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_medium), TRUE);
587 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_medium), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
588 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_medium);
589 
590 	resolution_replaygain_noise_shaping_radio_high = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("high"));
591 	if(flac_cfg.output.resolution.replaygain.noise_shaping == 3)
592 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_high), TRUE);
593 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_high), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
594 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_high);
595 
596 	resolution_replaygain_bps_out_frame = gtk_frame_new(_("Dither to"));
597 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_bps_out_frame), 5);
598 	gtk_box_pack_start(GTK_BOX(hbox), resolution_replaygain_bps_out_frame, FALSE, FALSE, 0);
599 
600 	resolution_replaygain_bps_out_vbox = gtk_vbutton_box_new();
601 	gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), 0);
602 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_frame), resolution_replaygain_bps_out_vbox);
603 
604 	resolution_replaygain_bps_out_radio_16bps = gtk_radio_button_new_with_label(NULL, _("16 bps"));
605 	if(flac_cfg.output.resolution.replaygain.bps_out == 16)
606 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_16bps), TRUE);
607 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_bps_out_radio_16bps), "clicked", resolution_replaygain_bps_out_cb, NULL);
608 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), resolution_replaygain_bps_out_radio_16bps);
609 
610 	resolution_replaygain_bps_out_radio_24bps = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_bps_out_radio_16bps), _("24 bps"));
611 	if(flac_cfg.output.resolution.replaygain.bps_out == 24)
612 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_24bps), TRUE);
613 	gtk_signal_connect(GTK_OBJECT(resolution_replaygain_bps_out_radio_24bps), "clicked", resolution_replaygain_bps_out_cb, NULL);
614 	gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), resolution_replaygain_bps_out_radio_24bps);
615 
616 	resolution_replaygain_dither_cb(resolution_replaygain_dither, NULL);
617 
618 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), output_vbox, gtk_label_new(_("Output")));
619 
620 	/* Streaming */
621 
622 	streaming_vbox = gtk_vbox_new(FALSE, 0);
623 
624 	streaming_buf_frame = gtk_frame_new(_("Buffering:"));
625 	gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_frame), 5);
626 	gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_buf_frame, FALSE, FALSE, 0);
627 
628 	streaming_buf_hbox = gtk_hbox_new(TRUE, 5);
629 	gtk_container_set_border_width(GTK_CONTAINER(streaming_buf_hbox), 5);
630 	gtk_container_add(GTK_CONTAINER(streaming_buf_frame), streaming_buf_hbox);
631 
632 	streaming_size_box = gtk_hbox_new(FALSE, 5);
633 	/*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_size_box,0,1,0,1); */
634 	gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_size_box, TRUE, TRUE, 0);
635 	streaming_size_label = gtk_label_new(_("Buffer size (kb):"));
636 	gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_label, FALSE, FALSE, 0);
637 	streaming_size_adj = gtk_adjustment_new(flac_cfg.stream.http_buffer_size, 4, 4096, 4, 4, 4);
638 	streaming_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(streaming_size_adj), 8, 0);
639 	gtk_widget_set_usize(streaming_size_spin, 60, -1);
640 	gtk_box_pack_start(GTK_BOX(streaming_size_box), streaming_size_spin, FALSE, FALSE, 0);
641 
642 	streaming_pre_box = gtk_hbox_new(FALSE, 5);
643 	/*gtk_table_attach_defaults(GTK_TABLE(streaming_buf_table),streaming_pre_box,1,2,0,1); */
644 	gtk_box_pack_start(GTK_BOX(streaming_buf_hbox), streaming_pre_box, TRUE, TRUE, 0);
645 	streaming_pre_label = gtk_label_new(_("Pre-buffer (percent):"));
646 	gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_label, FALSE, FALSE, 0);
647 	streaming_pre_adj = gtk_adjustment_new(flac_cfg.stream.http_prebuffer, 0, 90, 1, 1, 1);
648 	streaming_pre_spin = gtk_spin_button_new(GTK_ADJUSTMENT(streaming_pre_adj), 1, 0);
649 	gtk_widget_set_usize(streaming_pre_spin, 60, -1);
650 	gtk_box_pack_start(GTK_BOX(streaming_pre_box), streaming_pre_spin, FALSE, FALSE, 0);
651 
652  	/*
653  	 * Proxy config.
654  	 */
655 	streaming_proxy_frame = gtk_frame_new(_("Proxy:"));
656 	gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_frame), 5);
657 	gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_proxy_frame, FALSE, FALSE, 0);
658 
659 	streaming_proxy_vbox = gtk_vbox_new(FALSE, 5);
660 	gtk_container_set_border_width(GTK_CONTAINER(streaming_proxy_vbox), 5);
661 	gtk_container_add(GTK_CONTAINER(streaming_proxy_frame), streaming_proxy_vbox);
662 
663 	streaming_proxy_use = gtk_check_button_new_with_label(_("Use proxy"));
664 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_proxy_use), flac_cfg.stream.use_proxy);
665 	gtk_signal_connect(GTK_OBJECT(streaming_proxy_use), "clicked", GTK_SIGNAL_FUNC(proxy_use_cb), NULL);
666 	gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_use, FALSE, FALSE, 0);
667 
668 	streaming_proxy_hbox = gtk_hbox_new(FALSE, 5);
669 	gtk_widget_set_sensitive(streaming_proxy_hbox, flac_cfg.stream.use_proxy);
670 	gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_hbox, FALSE, FALSE, 0);
671 
672 	streaming_proxy_host_label = gtk_label_new(_("Host:"));
673 	gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_host_label, FALSE, FALSE, 0);
674 
675 	streaming_proxy_host_entry = gtk_entry_new();
676 	gtk_entry_set_text(GTK_ENTRY(streaming_proxy_host_entry), flac_cfg.stream.proxy_host? flac_cfg.stream.proxy_host : "");
677 	gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_host_entry, TRUE, TRUE, 0);
678 
679 	streaming_proxy_port_label = gtk_label_new(_("Port:"));
680 	gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_port_label, FALSE, FALSE, 0);
681 
682 	streaming_proxy_port_entry = gtk_entry_new();
683 	gtk_widget_set_usize(streaming_proxy_port_entry, 50, -1);
684 	temp = g_strdup_printf("%d", flac_cfg.stream.proxy_port);
685 	gtk_entry_set_text(GTK_ENTRY(streaming_proxy_port_entry), temp);
686 	g_free(temp);
687 	gtk_box_pack_start(GTK_BOX(streaming_proxy_hbox), streaming_proxy_port_entry, FALSE, FALSE, 0);
688 
689 	streaming_proxy_auth_use = gtk_check_button_new_with_label(_("Use authentication"));
690 	gtk_widget_set_sensitive(streaming_proxy_auth_use, flac_cfg.stream.use_proxy);
691 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_proxy_auth_use), flac_cfg.stream.proxy_use_auth);
692 	gtk_signal_connect(GTK_OBJECT(streaming_proxy_auth_use), "clicked", GTK_SIGNAL_FUNC(proxy_auth_use_cb), NULL);
693 	gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_auth_use, FALSE, FALSE, 0);
694 
695 	streaming_proxy_auth_hbox = gtk_hbox_new(FALSE, 5);
696 	gtk_widget_set_sensitive(streaming_proxy_auth_hbox, flac_cfg.stream.use_proxy && flac_cfg.stream.proxy_use_auth);
697 	gtk_box_pack_start(GTK_BOX(streaming_proxy_vbox), streaming_proxy_auth_hbox, FALSE, FALSE, 0);
698 
699 	streaming_proxy_auth_user_label = gtk_label_new(_("Username:"));
700 	gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_user_label, FALSE, FALSE, 0);
701 
702 	streaming_proxy_auth_user_entry = gtk_entry_new();
703 	if(flac_cfg.stream.proxy_user)
704 		gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_user_entry), flac_cfg.stream.proxy_user);
705 	gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_user_entry, TRUE, TRUE, 0);
706 
707 	streaming_proxy_auth_pass_label = gtk_label_new(_("Password:"));
708 	gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_pass_label, FALSE, FALSE, 0);
709 
710 	streaming_proxy_auth_pass_entry = gtk_entry_new();
711 	if(flac_cfg.stream.proxy_pass)
712 		gtk_entry_set_text(GTK_ENTRY(streaming_proxy_auth_pass_entry), flac_cfg.stream.proxy_pass);
713 	gtk_entry_set_visibility(GTK_ENTRY(streaming_proxy_auth_pass_entry), FALSE);
714 	gtk_box_pack_start(GTK_BOX(streaming_proxy_auth_hbox), streaming_proxy_auth_pass_entry, TRUE, TRUE, 0);
715 
716 
717 	/*
718 	 * Save to disk config.
719 	 */
720 	streaming_save_frame = gtk_frame_new(_("Save stream to disk:"));
721 	gtk_container_set_border_width(GTK_CONTAINER(streaming_save_frame), 5);
722 	gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_save_frame, FALSE, FALSE, 0);
723 
724 	streaming_save_vbox = gtk_vbox_new(FALSE, 5);
725 	gtk_container_set_border_width(GTK_CONTAINER(streaming_save_vbox), 5);
726 	gtk_container_add(GTK_CONTAINER(streaming_save_frame), streaming_save_vbox);
727 
728 	streaming_save_use = gtk_check_button_new_with_label(_("Save stream to disk"));
729 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_save_use), flac_cfg.stream.save_http_stream);
730 	gtk_signal_connect(GTK_OBJECT(streaming_save_use), "clicked", GTK_SIGNAL_FUNC(streaming_save_use_cb), NULL);
731 	gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_use, FALSE, FALSE, 0);
732 
733 	streaming_save_hbox = gtk_hbox_new(FALSE, 5);
734 	gtk_widget_set_sensitive(streaming_save_hbox, flac_cfg.stream.save_http_stream);
735 	gtk_box_pack_start(GTK_BOX(streaming_save_vbox), streaming_save_hbox, FALSE, FALSE, 0);
736 
737 	streaming_save_label = gtk_label_new(_("Path:"));
738 	gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_label, FALSE, FALSE, 0);
739 
740 	streaming_save_entry = gtk_entry_new();
741 	gtk_entry_set_text(GTK_ENTRY(streaming_save_entry), flac_cfg.stream.save_http_path? flac_cfg.stream.save_http_path : "");
742 	gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_entry, TRUE, TRUE, 0);
743 
744 	streaming_save_browse = gtk_button_new_with_label(_("Browse"));
745 	gtk_signal_connect(GTK_OBJECT(streaming_save_browse), "clicked", GTK_SIGNAL_FUNC(streaming_save_browse_cb), NULL);
746 	gtk_box_pack_start(GTK_BOX(streaming_save_hbox), streaming_save_browse, FALSE, FALSE, 0);
747 
748 #ifdef FLAC_ICECAST
749 	streaming_cast_frame = gtk_frame_new(_("SHOUT/Icecast:"));
750 	gtk_container_set_border_width(GTK_CONTAINER(streaming_cast_frame), 5);
751 	gtk_box_pack_start(GTK_BOX(streaming_vbox), streaming_cast_frame, FALSE, FALSE, 0);
752 
753 	streaming_cast_vbox = gtk_vbox_new(5, FALSE);
754 	gtk_container_add(GTK_CONTAINER(streaming_cast_frame), streaming_cast_vbox);
755 
756 	streaming_cast_title = gtk_check_button_new_with_label(_("Enable SHOUT/Icecast title streaming"));
757 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_cast_title), flac_cfg.stream.cast_title_streaming);
758 	gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_cast_title, FALSE, FALSE, 0);
759 
760 	streaming_udp_title = gtk_check_button_new_with_label(_("Enable Icecast Metadata UDP Channel"));
761 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(streaming_udp_title), flac_cfg.stream.use_udp_channel);
762 	gtk_box_pack_start(GTK_BOX(streaming_cast_vbox), streaming_udp_title, FALSE, FALSE, 0);
763 #endif
764 
765 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), streaming_vbox, gtk_label_new(_("Streaming")));
766 
767 	/* Buttons */
768 
769 	bbox = gtk_hbutton_box_new();
770 	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
771 	gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
772 	gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
773 
774 	ok = gtk_button_new_with_label(_("Ok"));
775 	gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(flac_configurewin_ok), NULL);
776 	GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
777 	gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
778 	gtk_widget_grab_default(ok);
779 
780 	cancel = gtk_button_new_with_label(_("Cancel"));
781 	gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(flac_configurewin));
782 	GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
783 	gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
784 
785 	gtk_widget_show_all(flac_configurewin);
786 }
787 
FLAC_XMMS__aboutbox(void)788 void FLAC_XMMS__aboutbox(void)
789 {
790 	static GtkWidget *about_window;
791 
792 	if (about_window)
793 		gdk_window_raise(about_window->window);
794 
795 	about_window = xmms_show_message(
796 		_("About Flac Plugin"),
797 		_("Flac Plugin by Josh Coalson\n"
798 		  "contributions by\n"
799 		  "......\n"
800 		  "......\n"
801 		  "and\n"
802 		  "Daisuke Shimamura\n"
803 		  "Visit http://xiph.org/flac/"),
804 		_("Ok"), FALSE, NULL, NULL);
805 	gtk_signal_connect(GTK_OBJECT(about_window), "destroy",
806 			   GTK_SIGNAL_FUNC(gtk_widget_destroyed),
807 			   &about_window);
808 }
809 
810 /*
811  * Get text of an Entry or a ComboBox
812  */
gtk_entry_get_text_1(GtkWidget * widget)813 static gchar *gtk_entry_get_text_1 (GtkWidget *widget)
814 {
815 	if (GTK_IS_COMBO(widget))
816 	{
817 		return gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(widget)->entry));
818 	}else if (GTK_IS_ENTRY(widget))
819 	{
820 		return gtk_entry_get_text(GTK_ENTRY(widget));
821 	}else
822 	{
823 		return NULL;
824 	}
825 }
826