update copyright to 2004
[platform/upstream/flac.git] / src / plugin_xmms / configure.c
1 /* libxmms-flac - XMMS FLAC input plugin
2  * Copyright (C) 2002,2003,2004  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
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <pthread.h>
29 #include <math.h>
30
31 #include <xmms/configfile.h>
32 #include <xmms/dirbrowser.h>
33 #include <xmms/titlestring.h>
34 #include <xmms/util.h>
35 #include <xmms/plugin.h>
36
37 #include "plugin_common/locale_hack.h"
38 #include "share/replaygain_synthesis.h" /* for NOISE_SHAPING_LOW */
39 #include "charset.h"
40 #include "configure.h"
41
42 /*
43  * Initialize Global Valueable
44  */
45 flac_config_t flac_cfg = {
46         /* title */
47         {
48                 FALSE, /* tag_override */
49                 NULL, /* tag_format */
50                 FALSE, /* convert_char_set */
51                 NULL, /* file_char_set */
52                 NULL /* user_char_set */
53         },
54         /* output */
55         {
56                 /* replaygain */
57                 {
58                         FALSE, /* enable */
59                         TRUE, /* album_mode */
60                         0, /* preamp */
61                         FALSE /* hard_limit */
62                 },
63                 /* resolution */
64                 {
65                         /* normal */
66                         {
67                                 TRUE /* dither_24_to_16 */
68                         },
69                         /* replaygain */
70                         {
71                                 TRUE, /* dither */
72                                 NOISE_SHAPING_LOW, /* noise_shaping */
73                                 16 /* bps_out */
74                         }
75                 }
76         }
77 };
78
79
80 static GtkWidget *flac_configurewin = NULL;
81 static GtkWidget *vbox, *notebook;
82
83 static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc;
84 static GtkWidget *convert_char_set, *fileCharacterSetEntry, *userCharacterSetEntry;
85 static GtkWidget *replaygain_enable, *replaygain_album_mode;
86 static GtkWidget *replaygain_preamp_hscale, *replaygain_preamp_label, *replaygain_hard_limit;
87 static GtkObject *replaygain_preamp;
88 static GtkWidget *resolution_normal_dither_24_to_16;
89 static GtkWidget *resolution_replaygain_dither;
90 static GtkWidget *resolution_replaygain_noise_shaping_frame;
91 static GtkWidget *resolution_replaygain_noise_shaping_radio_none;
92 static GtkWidget *resolution_replaygain_noise_shaping_radio_low;
93 static GtkWidget *resolution_replaygain_noise_shaping_radio_medium;
94 static GtkWidget *resolution_replaygain_noise_shaping_radio_high;
95 static GtkWidget *resolution_replaygain_bps_out_frame;
96 static GtkWidget *resolution_replaygain_bps_out_radio_16bps;
97 static GtkWidget *resolution_replaygain_bps_out_radio_24bps;
98
99 static gchar *gtk_entry_get_text_1 (GtkWidget *widget);
100 static void flac_configurewin_ok(GtkWidget * widget, gpointer data);
101 static void configure_destroy(GtkWidget * w, gpointer data);
102
103 static void flac_configurewin_ok(GtkWidget * widget, gpointer data)
104 {
105         ConfigFile *cfg;
106         gchar *filename;
107
108         (void)widget, (void)data; /* unused arguments */
109         g_free(flac_cfg.title.tag_format);
110         flac_cfg.title.tag_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_tag_entry)));
111         flac_cfg.title.file_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(fileCharacterSetEntry));
112         flac_cfg.title.user_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(userCharacterSetEntry));
113
114         filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL);
115         cfg = xmms_cfg_open_file(filename);
116         if (!cfg)
117                 cfg = xmms_cfg_new();
118         /* title */
119         xmms_cfg_write_boolean(cfg, "flac", "title.tag_override", flac_cfg.title.tag_override);
120         xmms_cfg_write_string(cfg, "flac", "title.tag_format", flac_cfg.title.tag_format);
121         xmms_cfg_write_boolean(cfg, "flac", "title.convert_char_set", flac_cfg.title.convert_char_set);
122         xmms_cfg_write_string(cfg, "flac", "title.file_char_set", flac_cfg.title.file_char_set);
123         xmms_cfg_write_string(cfg, "flac", "title.user_char_set", flac_cfg.title.user_char_set);
124         /* output */
125         xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.enable", flac_cfg.output.replaygain.enable);
126         xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.album_mode", flac_cfg.output.replaygain.album_mode);
127         xmms_cfg_write_int(cfg, "flac", "output.replaygain.preamp", flac_cfg.output.replaygain.preamp);
128         xmms_cfg_write_boolean(cfg, "flac", "output.replaygain.hard_limit", flac_cfg.output.replaygain.hard_limit);
129         xmms_cfg_write_boolean(cfg, "flac", "output.resolution.normal.dither_24_to_16", flac_cfg.output.resolution.normal.dither_24_to_16);
130         xmms_cfg_write_boolean(cfg, "flac", "output.resolution.replaygain.dither", flac_cfg.output.resolution.replaygain.dither);
131         xmms_cfg_write_int(cfg, "flac", "output.resolution.replaygain.noise_shaping", flac_cfg.output.resolution.replaygain.noise_shaping);
132         xmms_cfg_write_int(cfg, "flac", "output.resolution.replaygain.bps_out", flac_cfg.output.resolution.replaygain.bps_out);
133         xmms_cfg_write_file(cfg, filename);
134         xmms_cfg_free(cfg);
135         g_free(filename);
136         gtk_widget_destroy(flac_configurewin);
137 }
138
139 static void configure_destroy(GtkWidget *widget, gpointer data)
140 {
141         (void)widget, (void)data; /* unused arguments */
142 }
143
144 static void title_tag_override_cb(GtkWidget *widget, gpointer data)
145 {
146         (void)widget, (void)data; /* unused arguments */
147         flac_cfg.title.tag_override = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_tag_override));
148
149         gtk_widget_set_sensitive(title_tag_box, flac_cfg.title.tag_override);
150         gtk_widget_set_sensitive(title_desc, flac_cfg.title.tag_override);
151
152 }
153
154 static void convert_char_set_cb(GtkWidget *widget, gpointer data)
155 {
156         (void)widget, (void)data; /* unused arguments */
157         flac_cfg.title.convert_char_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(convert_char_set));
158
159         gtk_widget_set_sensitive(fileCharacterSetEntry, flac_cfg.title.convert_char_set);
160         gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.title.convert_char_set);
161 }
162
163 static void replaygain_enable_cb(GtkWidget *widget, gpointer data)
164 {
165         (void)widget, (void)data; /* unused arguments */
166         flac_cfg.output.replaygain.enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_enable));
167
168         gtk_widget_set_sensitive(replaygain_album_mode, flac_cfg.output.replaygain.enable);
169         gtk_widget_set_sensitive(replaygain_preamp_hscale, flac_cfg.output.replaygain.enable);
170         gtk_widget_set_sensitive(replaygain_hard_limit, flac_cfg.output.replaygain.enable);
171 }
172
173 static void replaygain_album_mode_cb(GtkWidget *widget, gpointer data)
174 {
175         (void)widget, (void)data; /* unused arguments */
176         flac_cfg.output.replaygain.album_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_album_mode));
177 }
178
179 static void replaygain_hard_limit_cb(GtkWidget *widget, gpointer data)
180 {
181         (void)widget, (void)data; /* unused arguments */
182         flac_cfg.output.replaygain.hard_limit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replaygain_hard_limit));
183 }
184
185 static void replaygain_preamp_cb(GtkWidget *widget, gpointer data)
186 {
187         GString *gstring = g_string_new("");
188         (void)widget, (void)data; /* unused arguments */
189         flac_cfg.output.replaygain.preamp = (int) floor(GTK_ADJUSTMENT(replaygain_preamp)->value + 0.5);
190
191         g_string_sprintf(gstring, "%i dB", flac_cfg.output.replaygain.preamp);
192         gtk_label_set_text(GTK_LABEL(replaygain_preamp_label), _(gstring->str));
193 }
194
195 static void resolution_normal_dither_24_to_16_cb(GtkWidget *widget, gpointer data)
196 {
197         (void)widget, (void)data; /* unused arguments */
198         flac_cfg.output.resolution.normal.dither_24_to_16 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_normal_dither_24_to_16));
199 }
200
201 static void resolution_replaygain_dither_cb(GtkWidget *widget, gpointer data)
202 {
203         (void)widget, (void)data; /* unused arguments */
204         flac_cfg.output.resolution.replaygain.dither = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_dither));
205
206         gtk_widget_set_sensitive(resolution_replaygain_noise_shaping_frame, flac_cfg.output.resolution.replaygain.dither);
207 }
208
209 static void resolution_replaygain_noise_shaping_cb(GtkWidget *widget, gpointer data)
210 {
211         (void)widget, (void)data; /* unused arguments */
212         flac_cfg.output.resolution.replaygain.noise_shaping =
213                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_none))? 0 :
214                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_low))? 1 :
215                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_medium))? 2 :
216                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_high))? 3 :
217                 0
218         ;
219 }
220
221 static void resolution_replaygain_bps_out_cb(GtkWidget *widget, gpointer data)
222 {
223         (void)widget, (void)data; /* unused arguments */
224         flac_cfg.output.resolution.replaygain.bps_out =
225                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_16bps))? 16 :
226                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_24bps))? 24 :
227                 16
228         ;
229 }
230
231
232 void FLAC_XMMS__configure(void)
233 {
234         GtkWidget *title_frame, *title_tag_vbox, *title_tag_label;
235         GtkWidget *replaygain_frame, *resolution_frame, *output_vbox, *resolution_normal_frame, *resolution_replaygain_frame;
236         GtkWidget *replaygain_vbox, *resolution_hbox, *resolution_normal_vbox, *resolution_replaygain_vbox;
237         GtkWidget *resolution_replaygain_noise_shaping_vbox;
238         GtkWidget *resolution_replaygain_bps_out_vbox;
239         GtkWidget *label, *hbox;
240         GtkWidget *bbox, *ok, *cancel;
241         GList *list;
242
243         if (flac_configurewin != NULL) {
244                 gdk_window_raise(flac_configurewin->window);
245                 return;
246         }
247         flac_configurewin = gtk_window_new(GTK_WINDOW_DIALOG);
248         gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &flac_configurewin);
249         gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(configure_destroy), &flac_configurewin);
250         gtk_window_set_title(GTK_WINDOW(flac_configurewin), _("Flac Configuration"));
251         gtk_window_set_policy(GTK_WINDOW(flac_configurewin), FALSE, FALSE, FALSE);
252         gtk_container_border_width(GTK_CONTAINER(flac_configurewin), 10);
253
254         vbox = gtk_vbox_new(FALSE, 10);
255         gtk_container_add(GTK_CONTAINER(flac_configurewin), vbox);
256
257         notebook = gtk_notebook_new();
258         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
259
260         /* Title config.. */
261
262         title_frame = gtk_frame_new(_("Tag Handling"));
263         gtk_container_border_width(GTK_CONTAINER(title_frame), 5);
264
265         title_tag_vbox = gtk_vbox_new(FALSE, 10);
266         gtk_container_border_width(GTK_CONTAINER(title_tag_vbox), 5);
267         gtk_container_add(GTK_CONTAINER(title_frame), title_tag_vbox);
268
269         /* Convert Char Set */
270
271         convert_char_set = gtk_check_button_new_with_label(_("Convert Character Set"));
272         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(convert_char_set), flac_cfg.title.convert_char_set);
273         gtk_signal_connect(GTK_OBJECT(convert_char_set), "clicked", convert_char_set_cb, NULL);
274         gtk_box_pack_start(GTK_BOX(title_tag_vbox), convert_char_set, FALSE, FALSE, 0);
275         /*  Combo boxes... */
276         hbox = gtk_hbox_new(FALSE,4);
277         gtk_container_add(GTK_CONTAINER(title_tag_vbox),hbox);
278         label = gtk_label_new(_("Convert character set from :"));
279         gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
280         fileCharacterSetEntry = gtk_combo_new();
281         gtk_box_pack_start(GTK_BOX(hbox),fileCharacterSetEntry,TRUE,TRUE,0);
282
283         label = gtk_label_new (_("to :"));
284         gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
285         userCharacterSetEntry = gtk_combo_new();
286         gtk_box_pack_start(GTK_BOX(hbox),userCharacterSetEntry,TRUE,TRUE,0);
287
288         gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(fileCharacterSetEntry)->entry),FALSE);
289         gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(userCharacterSetEntry)->entry),FALSE);
290         gtk_combo_set_value_in_list(GTK_COMBO(fileCharacterSetEntry),TRUE,FALSE);
291         gtk_combo_set_value_in_list(GTK_COMBO(userCharacterSetEntry),TRUE,FALSE);
292
293         list = Charset_Create_List();
294         gtk_combo_set_popdown_strings(GTK_COMBO(fileCharacterSetEntry),list);
295         gtk_combo_set_popdown_strings(GTK_COMBO(userCharacterSetEntry),list);
296         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(fileCharacterSetEntry)->entry),Charset_Get_Title_From_Name(flac_cfg.title.file_char_set));
297         gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(userCharacterSetEntry)->entry),Charset_Get_Title_From_Name(flac_cfg.title.user_char_set));
298         gtk_widget_set_sensitive(fileCharacterSetEntry, flac_cfg.title.convert_char_set);
299         gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.title.convert_char_set);
300
301         /* Override Tagging Format */
302
303         title_tag_override = gtk_check_button_new_with_label(_("Override generic titles"));
304         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_tag_override), flac_cfg.title.tag_override);
305         gtk_signal_connect(GTK_OBJECT(title_tag_override), "clicked", title_tag_override_cb, NULL);
306         gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_tag_override, FALSE, FALSE, 0);
307
308         title_tag_box = gtk_hbox_new(FALSE, 5);
309         gtk_widget_set_sensitive(title_tag_box, flac_cfg.title.tag_override);
310         gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_tag_box, FALSE, FALSE, 0);
311
312         title_tag_label = gtk_label_new(_("Title format:"));
313         gtk_box_pack_start(GTK_BOX(title_tag_box), title_tag_label, FALSE, FALSE, 0);
314
315         title_tag_entry = gtk_entry_new();
316         gtk_entry_set_text(GTK_ENTRY(title_tag_entry), flac_cfg.title.tag_format);
317         gtk_box_pack_start(GTK_BOX(title_tag_box), title_tag_entry, TRUE, TRUE, 0);
318
319         title_desc = xmms_titlestring_descriptions("pafFetnygc", 2);
320         gtk_widget_set_sensitive(title_desc, flac_cfg.title.tag_override);
321         gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_desc, FALSE, FALSE, 0);
322
323         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, gtk_label_new(_("Title")));
324
325         /* Output config.. */
326
327         output_vbox = gtk_vbox_new(FALSE, 10);
328         gtk_container_border_width(GTK_CONTAINER(output_vbox), 5);
329
330         /* replaygain */
331
332         replaygain_frame = gtk_frame_new(_("ReplayGain"));
333         gtk_container_border_width(GTK_CONTAINER(replaygain_frame), 5);
334         gtk_box_pack_start(GTK_BOX(output_vbox), replaygain_frame, TRUE, TRUE, 0);
335
336         replaygain_vbox = gtk_vbox_new(FALSE, 10);
337         gtk_container_border_width(GTK_CONTAINER(replaygain_vbox), 5);
338         gtk_container_add(GTK_CONTAINER(replaygain_frame), replaygain_vbox);
339
340         replaygain_enable = gtk_check_button_new_with_label(_("Enable ReplayGain processing"));
341         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_enable), flac_cfg.output.replaygain.enable);
342         gtk_signal_connect(GTK_OBJECT(replaygain_enable), "clicked", replaygain_enable_cb, NULL);
343         gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_enable, FALSE, FALSE, 0);
344
345         replaygain_album_mode = gtk_check_button_new_with_label(_("Album mode"));
346         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_album_mode), flac_cfg.output.replaygain.album_mode);
347         gtk_signal_connect(GTK_OBJECT(replaygain_album_mode), "clicked", replaygain_album_mode_cb, NULL);
348         gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_album_mode, FALSE, FALSE, 0);
349
350         hbox = gtk_hbox_new(FALSE,3);
351         gtk_container_add(GTK_CONTAINER(replaygain_vbox),hbox);
352         label = gtk_label_new(_("Preamp:"));
353         gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
354         replaygain_preamp = gtk_adjustment_new(flac_cfg.output.replaygain.preamp, -24.0, +24.0, 1.0, 6.0, 0.0);
355         gtk_signal_connect(GTK_OBJECT(replaygain_preamp), "value-changed", replaygain_preamp_cb, NULL);
356         replaygain_preamp_hscale = gtk_hscale_new(GTK_ADJUSTMENT(replaygain_preamp));
357         gtk_scale_set_draw_value(GTK_SCALE(replaygain_preamp_hscale), FALSE);
358         gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_hscale,TRUE,TRUE,0);
359         replaygain_preamp_label = gtk_label_new(_("0 dB"));
360         gtk_box_pack_start(GTK_BOX(hbox),replaygain_preamp_label,FALSE,FALSE,0);
361         gtk_adjustment_value_changed(GTK_ADJUSTMENT(replaygain_preamp));
362
363         replaygain_hard_limit = gtk_check_button_new_with_label(_("6dB hard limiting"));
364         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygain_hard_limit), flac_cfg.output.replaygain.hard_limit);
365         gtk_signal_connect(GTK_OBJECT(replaygain_hard_limit), "clicked", replaygain_hard_limit_cb, NULL);
366         gtk_box_pack_start(GTK_BOX(replaygain_vbox), replaygain_hard_limit, FALSE, FALSE, 0);
367
368         replaygain_enable_cb(replaygain_enable, NULL);
369
370         /* resolution */
371
372         resolution_frame = gtk_frame_new(_("Resolution"));
373         gtk_container_border_width(GTK_CONTAINER(resolution_frame), 5);
374         gtk_box_pack_start(GTK_BOX(output_vbox), resolution_frame, TRUE, TRUE, 0);
375
376         resolution_hbox = gtk_hbox_new(FALSE, 10);
377         gtk_container_border_width(GTK_CONTAINER(resolution_hbox), 5);
378         gtk_container_add(GTK_CONTAINER(resolution_frame), resolution_hbox);
379
380         resolution_normal_frame = gtk_frame_new(_("Without ReplayGain"));
381         gtk_container_border_width(GTK_CONTAINER(resolution_normal_frame), 5);
382         gtk_box_pack_start(GTK_BOX(resolution_hbox), resolution_normal_frame, TRUE, TRUE, 0);
383
384         resolution_normal_vbox = gtk_vbox_new(FALSE, 10);
385         gtk_container_border_width(GTK_CONTAINER(resolution_normal_vbox), 5);
386         gtk_container_add(GTK_CONTAINER(resolution_normal_frame), resolution_normal_vbox);
387
388         resolution_normal_dither_24_to_16 = gtk_check_button_new_with_label(_("Dither 24bps to 16bps"));
389         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_normal_dither_24_to_16), flac_cfg.output.resolution.normal.dither_24_to_16);
390         gtk_signal_connect(GTK_OBJECT(resolution_normal_dither_24_to_16), "clicked", resolution_normal_dither_24_to_16_cb, NULL);
391         gtk_box_pack_start(GTK_BOX(resolution_normal_vbox), resolution_normal_dither_24_to_16, FALSE, FALSE, 0);
392
393         resolution_replaygain_frame = gtk_frame_new(_("With ReplayGain"));
394         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_frame), 5);
395         gtk_box_pack_start(GTK_BOX(resolution_hbox), resolution_replaygain_frame, TRUE, TRUE, 0);
396
397         resolution_replaygain_vbox = gtk_vbox_new(FALSE, 10);
398         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_vbox), 5);
399         gtk_container_add(GTK_CONTAINER(resolution_replaygain_frame), resolution_replaygain_vbox);
400
401         resolution_replaygain_dither = gtk_check_button_new_with_label(_("Enable dithering"));
402         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_dither), flac_cfg.output.resolution.replaygain.dither);
403         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_dither), "clicked", resolution_replaygain_dither_cb, NULL);
404         gtk_box_pack_start(GTK_BOX(resolution_replaygain_vbox), resolution_replaygain_dither, FALSE, FALSE, 0);
405
406         hbox = gtk_hbox_new(FALSE, 10);
407         gtk_container_border_width(GTK_CONTAINER(hbox), 5);
408         gtk_box_pack_start(GTK_BOX(resolution_replaygain_vbox), hbox, TRUE, TRUE, 0);
409
410         resolution_replaygain_noise_shaping_frame = gtk_frame_new(_("Noise shaping"));
411         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_noise_shaping_frame), 5);
412         gtk_box_pack_start(GTK_BOX(hbox), resolution_replaygain_noise_shaping_frame, TRUE, TRUE, 0);
413
414         resolution_replaygain_noise_shaping_vbox = gtk_vbutton_box_new();
415         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), 5);
416         gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_frame), resolution_replaygain_noise_shaping_vbox);
417
418         resolution_replaygain_noise_shaping_radio_none = gtk_radio_button_new_with_label(NULL, _("none"));
419         if(flac_cfg.output.resolution.replaygain.noise_shaping == 0)
420                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_none), TRUE);
421         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_none), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
422         gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_none);
423
424         resolution_replaygain_noise_shaping_radio_low = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("low"));
425         if(flac_cfg.output.resolution.replaygain.noise_shaping == 1)
426                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_low), TRUE);
427         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_low), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
428         gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_low);
429
430         resolution_replaygain_noise_shaping_radio_medium = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("medium"));
431         if(flac_cfg.output.resolution.replaygain.noise_shaping == 2)
432                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_medium), TRUE);
433         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_medium), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
434         gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_medium);
435
436         resolution_replaygain_noise_shaping_radio_high = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(resolution_replaygain_noise_shaping_radio_none), _("high"));
437         if(flac_cfg.output.resolution.replaygain.noise_shaping == 3)
438                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_noise_shaping_radio_high), TRUE);
439         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_noise_shaping_radio_high), "clicked", resolution_replaygain_noise_shaping_cb, NULL);
440         gtk_container_add(GTK_CONTAINER(resolution_replaygain_noise_shaping_vbox), resolution_replaygain_noise_shaping_radio_high);
441
442         resolution_replaygain_bps_out_frame = gtk_frame_new(_("Dither to"));
443         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_bps_out_frame), 5);
444         gtk_box_pack_start(GTK_BOX(hbox), resolution_replaygain_bps_out_frame, FALSE, FALSE, 0);
445
446         resolution_replaygain_bps_out_vbox = gtk_vbutton_box_new();
447         gtk_container_border_width(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), 0);
448         gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_frame), resolution_replaygain_bps_out_vbox);
449
450         resolution_replaygain_bps_out_radio_16bps = gtk_radio_button_new_with_label(NULL, _("16 bps"));
451         if(flac_cfg.output.resolution.replaygain.bps_out == 16)
452                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_16bps), TRUE);
453         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_bps_out_radio_16bps), "clicked", resolution_replaygain_bps_out_cb, NULL);
454         gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), resolution_replaygain_bps_out_radio_16bps);
455
456         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"));
457         if(flac_cfg.output.resolution.replaygain.bps_out == 24)
458                 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(resolution_replaygain_bps_out_radio_24bps), TRUE);
459         gtk_signal_connect(GTK_OBJECT(resolution_replaygain_bps_out_radio_24bps), "clicked", resolution_replaygain_bps_out_cb, NULL);
460         gtk_container_add(GTK_CONTAINER(resolution_replaygain_bps_out_vbox), resolution_replaygain_bps_out_radio_24bps);
461
462         resolution_replaygain_dither_cb(resolution_replaygain_dither, NULL);
463
464         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), output_vbox, gtk_label_new(_("Output")));
465
466         /* Buttons */
467
468         bbox = gtk_hbutton_box_new();
469         gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
470         gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
471         gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
472
473         ok = gtk_button_new_with_label(_("Ok"));
474         gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(flac_configurewin_ok), NULL);
475         GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
476         gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
477         gtk_widget_grab_default(ok);
478
479         cancel = gtk_button_new_with_label(_("Cancel"));
480         gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(flac_configurewin));
481         GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
482         gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
483
484         gtk_widget_show_all(flac_configurewin);
485 }
486
487 void FLAC_XMMS__aboutbox()
488 {
489         static GtkWidget *about_window;
490
491         if (about_window)
492                 gdk_window_raise(about_window->window);
493
494         about_window = xmms_show_message(
495                 _("About Flac Plugin"),
496                 _("Flac Plugin by Josh Coalson\n"
497                   "contributions by\n"
498                   "......\n"
499                   "......\n"
500                   "and\n"
501                   "Daisuke Shimamura\n"
502                   "Visit http://flac.sourceforge.net/"),
503                 _("Ok"), FALSE, NULL, NULL);
504         gtk_signal_connect(GTK_OBJECT(about_window), "destroy",
505                            GTK_SIGNAL_FUNC(gtk_widget_destroyed),
506                            &about_window);
507 }
508
509 /*
510  * Get text of an Entry or a ComboBox
511  */
512 static gchar *gtk_entry_get_text_1 (GtkWidget *widget)
513 {
514         if (GTK_IS_COMBO(widget))
515         {
516                 return gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(widget)->entry));
517         }else if (GTK_IS_ENTRY(widget))
518         {
519                 return gtk_entry_get_text(GTK_ENTRY(widget));
520         }else
521         {
522                 return NULL;
523         }
524 }