mp3splt-gtk

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

preferences_tab.c
Go to the documentation of this file.
1 /**********************************************************
2 *
3 * mp3splt-gtk -- utility based on mp3splt,
4 * for mp3/ogg splitting without decoding
5 *
6 * Copyright: (C) 2005-2012 Alexandru Munteanu
7 * Contact: io_fx@yahoo.fr
8 *
9 * http://mp3splt.sourceforge.net/
10 *
11 *********************************************************/
12
13 /**********************************************************
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * along with this program; if not, write to the Free Software
26 * You should have received a copy of the GNU General Public License
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 * USA.
29 *
30 *********************************************************/
31
32 /*!********************************************************
33 * \file
34 * The preferences tab
35 *
36 * this file contains the code for the preferences tab where
37 * the preferences can be chosen.
38 ********************************************************/
39
40 #include <gtk/gtk.h>
41 #include <glib/gi18n.h>
42 #include <glib.h>
43 #include <glib/gstdio.h>
44 #include <string.h>
45
46 #include <libmp3splt/mp3splt.h>
47
48 #include "preferences_tab.h"
49 #include "player.h"
50 #include "util.h"
51 #include "player_tab.h"
52 #include "utilities.h"
53 #include "main_win.h"
54 #include "preferences_manager.h"
55 #include "widgets_helper.h"
56 #include "combo_helper.h"
57 #include "radio_helper.h"
58 #include "options_manager.h"
59 #include "ui_manager.h"
60 #include "widgets_helper.h"
61
67 GString *outputdirname = NULL;
68
70 GtkWidget *directory_entry = NULL;
71
73 GtkWidget *output_entry = NULL;
74 GtkWidget *output_label = NULL;
75
77 GtkWidget *player_combo_box = NULL;
78 GtkWidget *player_refresh_rate_spinner = NULL;
79
81 GList *player_pref_list = NULL;
82 GList *text_options_list = NULL;
83 //selected player
84 gint selected_player = PLAYER_GSTREAMER;
85
87 GtkWidget *radio_button = NULL;
88
90 GtkWidget *radio_output = NULL;
91
93 GtkWidget *tags_radio = NULL;
94 GtkWidget *tags_version_radio = NULL;
95
96 //split options
98 GtkWidget *frame_mode = NULL;
100 GtkWidget *adjust_mode = NULL;
101 // when ticked, name for split tag derived from filename
102 GtkWidget *names_from_filename = NULL;
103
104 GtkWidget *create_dirs_from_output_files = NULL;
105
109 GtkWidget *spinner_adjust_gap = NULL;
110 GtkWidget *gap_label = NULL;
111 GtkWidget *spinner_adjust_offset = NULL;
112 GtkWidget *offset_label = NULL;
113 GtkWidget *spinner_adjust_threshold = NULL;
114 GtkWidget *threshold_label = NULL;
116
120 GtkWidget *replace_underscore_by_space_check_box = NULL;
121 GtkComboBox *artist_text_properties_combo = NULL;
122 GtkComboBox *album_text_properties_combo = NULL;
123 GtkComboBox *title_text_properties_combo = NULL;
124 GtkComboBox *comment_text_properties_combo = NULL;
125 GtkComboBox *genre_combo = NULL;
126 GtkWidget *comment_tag_entry = NULL;
127 GtkWidget *regex_entry = NULL;
128 GtkWidget *test_regex_fname_entry = NULL;
129 GtkWidget *sample_result_label = NULL;
130
131 GtkWidget *extract_tags_box = NULL;
133
134 extern gint timeout_value;
135 extern GtkWidget *player_box;
136 extern GtkWidget *playlist_box;
137 extern GtkWidget *queue_files_button;
138 extern splt_state *the_state;
139 extern gint selected_split_mode;
140 extern gint split_file_mode;
141 extern GtkWidget *spinner_time;
142 extern GtkWidget *spinner_equal_tracks;
143
144 extern gint file_browsed;
145
146 static GtkWidget *create_extract_tags_from_filename_options_box();
147 static GtkWidget *create_test_regex_table();
148
149 extern void clear_current_description(void);
150 extern void copy_filename_to_current_description(const gchar *fname);
151
152 extern ui_state *ui;
153
158 GString *get_checked_language()
159 {
160 GSList *radio_button_list;
161 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_button));
162 GtkWidget *our_button;
163
164 //0 = german, 1 = french, 2 = english
165 our_button = (GtkWidget *)g_slist_nth_data(radio_button_list, 0);
166 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(our_button)))
167 {
168 return g_string_new("de_DE");
169 }
170 else
171 {
172 our_button = (GtkWidget *)g_slist_nth_data(radio_button_list, 1);
173 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(our_button)))
174 {
175 return g_string_new("fr_FR");
176 }
177 }
178
179 return g_string_new("en");
180 }
181
183 gboolean get_checked_output_radio_box()
184 {
185 //get the radio buttons
186 GSList *radio_button_list;
187 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_output));
188 //we check which bubble is checked
189 GtkToggleButton *test;
190 gint i, selected = 0;
191 //O = default output mode
192 //1 = custom output mode
193 for(i = 0; i<2;i++)
194 {
195 test = (GtkToggleButton *)g_slist_nth_data(radio_button_list,i);
196 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(test)))
197 {
198 selected = i;
199 }
200 }
201
202 return selected;
203 }
204
206 gint get_checked_tags_version_radio_box()
207 {
208 //get the radio buttons
209 GSList *radio_button_list;
210 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(tags_version_radio));
211
212 //we check which bubble is checked
213 GtkToggleButton *test;
214 gint i, selected = 0;
215 //O = The same version as the original file
216 //1 = ID3v1
217 //2 = ID3v2
218 //3 = ID3v1 & ID3v2
219 for(i = 0; i<4;i++)
220 {
221 test = (GtkToggleButton *)g_slist_nth_data(radio_button_list,i);
222 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(test)))
223 {
224 selected = i;
225 }
226 }
227
228 return selected;
229 }
230
232 void outputdirectory_set(gchar *dirname)
233 {
234 if(dirname!=NULL)
235 {
236 // Free the old string before allocating memory for the new one
237 if(outputdirname!=NULL)g_string_free(outputdirname,TRUE);
238 outputdirname=g_string_new(dirname);
239
240 // Update the text in the gui field displaying the output
241 // directory - if this field is already there and thus can
242 // be updated.
243 if(directory_entry!=NULL)
244 gtk_entry_set_text(GTK_ENTRY(directory_entry), dirname);
245 }
246 }
247
254 gchar* outputdirectory_get()
255 {
256 if(outputdirname!=NULL)
257 return(outputdirname->str);
258 else
259 return NULL;
260 }
261
262 void save_preferences(GtkWidget *widget, gpointer data)
263 {
264 gchar *filename = get_preferences_filename();
265
266 GKeyFile *my_key_file = g_key_file_new();
267 g_key_file_load_from_file(my_key_file, filename, G_KEY_FILE_KEEP_COMMENTS, NULL);
268
269 //save_path
270 g_key_file_set_string(my_key_file, "split", "save_path",
271 outputdirectory_get());
272
273 //player
274 g_key_file_set_integer(my_key_file, "player", "default_player", selected_player);
275 g_key_file_set_integer(my_key_file, "player", "refresh_rate",
276 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(player_refresh_rate_spinner)));
277
278 #ifdef __WIN32__
279 //language
280 GString *selected_lang;
281 selected_lang = (GString *)get_checked_language();
282 g_key_file_set_string(my_key_file, "general", "language", selected_lang->str);
283 g_string_free(selected_lang, TRUE);
284 selected_lang = NULL;
285 #endif
286
287 //frame mode
288 g_key_file_set_boolean(my_key_file, "split", "frame_mode",
289 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(frame_mode)));
290
291 //adjust mode
292 g_key_file_set_boolean(my_key_file, "split", "adjust_mode",
293 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adjust_mode)));
294
295 //adjust threshold
296 g_key_file_set_integer(my_key_file, "split", "adjust_threshold",
297 gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_adjust_threshold)) * 100);
298 //adjust offset
299 g_key_file_set_integer(my_key_file, "split", "adjust_offset",
300 gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_adjust_offset)) * 100);
301 //adjust gap
302 g_key_file_set_integer(my_key_file, "split", "adjust_gap",
303 gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinner_adjust_gap)));
304
305 g_key_file_set_boolean(my_key_file, "output", "splitpoint_names_from_filename",
306 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(names_from_filename)));
307
308 //output format
309 g_key_file_set_string(my_key_file, "output", "output_format",
310 gtk_entry_get_text(GTK_ENTRY(output_entry)));
311 //default output format
312 g_key_file_set_boolean(my_key_file, "output", "default_output_format",
313 get_checked_output_radio_box());
314 g_key_file_set_boolean(my_key_file, "output", "create_dirs_if_needed",
315 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(create_dirs_from_output_files)));
316
317 //tags
318 g_key_file_set_integer(my_key_file, "split", "tags", rh_get_active_value(tags_radio));
319
320 //replace underscores by space
321 g_key_file_set_boolean(my_key_file, "split", "replace_underscore_by_space",
322 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(replace_underscore_by_space_check_box)));
323
324 //artist text properties
325 g_key_file_set_integer(my_key_file, "split", "artist_text_properties",
326 ch_get_active_value(artist_text_properties_combo));
327 //album text properties
328 g_key_file_set_integer(my_key_file, "split", "album_text_properties",
329 ch_get_active_value(album_text_properties_combo));
330 //title text properties
331 g_key_file_set_integer(my_key_file, "split", "title_text_properties",
332 ch_get_active_value(title_text_properties_combo));
333 //comment text properties
334 g_key_file_set_integer(my_key_file, "split", "comment_text_properties",
335 ch_get_active_value(comment_text_properties_combo));
336
337 //genre
338 gchar *genre_value = ch_get_active_str_value(genre_combo);
339 if (genre_value != NULL)
340 {
341 g_key_file_set_string(my_key_file, "split", "genre", genre_value);
342 }
343
344 const gchar *comment = gtk_entry_get_text(GTK_ENTRY(comment_tag_entry));
345 if (comment != NULL)
346 {
347 g_key_file_set_string(my_key_file, "split", "default_comment_tag", comment);
348 }
349
350 const gchar *regex_text = gtk_entry_get_text(GTK_ENTRY(regex_entry));
351 if (regex_text != NULL)
352 {
353 g_key_file_set_string(my_key_file, "split", "tags_from_filename_regex", regex_text);
354 }
355
356 const gchar *test_regex_fname = gtk_entry_get_text(GTK_ENTRY(test_regex_fname_entry));
357 if (test_regex_fname_entry != NULL)
358 {
359 g_key_file_set_string(my_key_file, "split", "test_regex_fname", test_regex_fname);
360 }
361
362 //tags version
363 g_key_file_set_integer(my_key_file, "split", "tags_version",
364 get_checked_tags_version_radio_box());
365
366 //type of split: split mode
367 g_key_file_set_integer(my_key_file, "split", "split_mode",
368 selected_split_mode);
369 //time value
370 g_key_file_set_integer(my_key_file, "split", "split_mode_time_value",
371 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner_time)));
372 //type of split: file mode
373 g_key_file_set_integer(my_key_file, "split", "file_mode",
374 split_file_mode);
375 //equal time tracks value
376 g_key_file_set_integer(my_key_file, "split", "split_mode_equal_time_tracks",
377 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner_equal_tracks)));
378
379 const ui_main_window *main_win = ui_get_main_window_infos(ui);
380 g_key_file_set_integer(my_key_file, "gui", "root_x_position",
381 main_win->root_x_pos);
382 g_key_file_set_integer(my_key_file, "gui", "root_y_position",
383 main_win->root_y_pos);
384 g_key_file_set_integer(my_key_file, "gui", "width",
385 main_win->width);
386 g_key_file_set_integer(my_key_file, "gui", "height",
387 main_win->height);
388
389 const char *browser_directory = ui_get_browser_directory(ui);
390 if (browser_directory != NULL)
391 {
392 g_key_file_set_string(my_key_file, "gui", "browser_directory", browser_directory);
393 }
394
395 gchar *key_data = g_key_file_to_data(my_key_file, NULL, NULL);
396
397 //we write to the preference file
398 FILE *preferences_file;
399 preferences_file = (FILE *)g_fopen(filename,"w");
400 g_fprintf(preferences_file,"%s", key_data);
401 fclose(preferences_file);
402 preferences_file = NULL;
403
404 //we free memory
405 g_free(key_data);
406 g_key_file_free(my_key_file);
407
408 if (filename)
409 {
410 g_free(filename);
411 filename = NULL;
412 }
413 }
414
416 GtkWidget *create_scrolled_window()
417 {
418 GtkWidget *scrolled_window;
419 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
420 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_NONE);
421 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
422 GTK_POLICY_AUTOMATIC,
423 GTK_POLICY_AUTOMATIC);
424 return scrolled_window;
425 }
426
428 void output_radio_box_event(GtkToggleButton *radio_b, gpointer data)
429 {
430 GtkWidget *output_label = (GtkWidget *)data;
431
432 gint selected = get_checked_output_radio_box();
433
434 //custom output mode
435 if (selected == 0)
436 {
437 gtk_widget_set_sensitive(GTK_WIDGET(output_entry), TRUE);
438 gtk_widget_set_sensitive(GTK_WIDGET(output_label), TRUE);
439 mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES,
440 SPLT_OUTPUT_FORMAT);
441 }
442 else
443 {
444 gtk_widget_set_sensitive(GTK_WIDGET(output_entry), FALSE);
445 gtk_widget_set_sensitive(GTK_WIDGET(output_label), FALSE);
446 mp3splt_set_int_option(the_state, SPLT_OPT_OUTPUT_FILENAMES,
447 SPLT_OUTPUT_DEFAULT);
448 }
449
450 save_preferences(NULL, NULL);
451 }
452
454 GtkWidget *create_language_box()
455 {
456 GtkWidget *radio_vbox = gtk_vbox_new (FALSE, 0);
457
458 radio_button = gtk_radio_button_new_with_label(NULL, "English");
459 g_signal_connect(GTK_TOGGLE_BUTTON(radio_button), "toggled",
460 G_CALLBACK(save_preferences), NULL);
461 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
462
463 radio_button = gtk_radio_button_new_with_label_from_widget
464 (GTK_RADIO_BUTTON(radio_button), "Français");
465 g_signal_connect(GTK_TOGGLE_BUTTON(radio_button), "toggled",
466 G_CALLBACK(save_preferences), NULL);
467 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
468
469 radio_button = gtk_radio_button_new_with_label_from_widget
470 (GTK_RADIO_BUTTON(radio_button), "Deutsch");
471 g_signal_connect(GTK_TOGGLE_BUTTON (radio_button), "toggled",
472 G_CALLBACK(save_preferences), NULL);
473 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
474
475 return wh_set_title_and_get_vbox(radio_vbox,
476 _("<b>Choose language (requires restart)</b>"));
477 }
478
480 GtkWidget *create_pref_language_page()
481 {
482 GtkWidget *language_hbox = gtk_hbox_new(FALSE, 0);;
483
484 //vertical box inside the scrolled window
485 GtkWidget *language_inside_hbox = gtk_hbox_new(FALSE, 0);;
486
487 //scrolled window
488 GtkWidget *scrolled_window;
489 scrolled_window = create_scrolled_window();
490 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
491 GTK_WIDGET(language_inside_hbox));
492 gtk_box_pack_start(GTK_BOX(language_hbox), scrolled_window, TRUE, TRUE, 0);
493
494 //vertical box inside the horizontal box from the scrolled window
495 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
496 gtk_box_pack_start(GTK_BOX(language_inside_hbox), vbox, TRUE, TRUE, 10);
497
498 GtkWidget *lang_box = create_language_box();
499 gtk_box_pack_start(GTK_BOX(vbox), lang_box, FALSE, FALSE, 10);
500
501 return language_hbox;
502 }
503
505 void browse_dir_button_event(GtkWidget *widget, gpointer data)
506 {
507 // file chooser
508 GtkWidget *dir_chooser;
509
510 //creates and shows the dialog
511 dir_chooser = gtk_file_chooser_dialog_new(_("Choose split directory"),
512 NULL,
513 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
514 GTK_STOCK_CANCEL,
515 GTK_RESPONSE_CANCEL,
516 GTK_STOCK_OPEN,
517 GTK_RESPONSE_ACCEPT,
518 NULL);
519
520 wh_set_browser_directory_handler(ui, dir_chooser);
521
522 if (gtk_dialog_run(GTK_DIALOG(dir_chooser)) == GTK_RESPONSE_ACCEPT)
523 {
524 gchar *filename =
525 gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dir_chooser));
526
527 outputdirectory_set(filename);
528
529 g_free (filename);
530 filename = NULL;
531
532 save_preferences(NULL, NULL);
533 }
534
535 //destroys dialog
536 gtk_widget_destroy(dir_chooser);
537 }
538
540 void disable_adjust_spinners()
541 {
542 gtk_widget_set_sensitive(spinner_adjust_threshold, FALSE);
543 gtk_widget_set_sensitive(spinner_adjust_offset, FALSE);
544 gtk_widget_set_sensitive(spinner_adjust_gap, FALSE);
545 gtk_widget_set_sensitive(threshold_label, FALSE);
546 gtk_widget_set_sensitive(offset_label, FALSE);
547 gtk_widget_set_sensitive(gap_label, FALSE);
548 }
549
551 void enable_adjust_spinners()
552 {
553 gtk_widget_set_sensitive(spinner_adjust_threshold, TRUE);
554 gtk_widget_set_sensitive(spinner_adjust_offset, TRUE);
555 gtk_widget_set_sensitive(spinner_adjust_gap, TRUE);
556 gtk_widget_set_sensitive(threshold_label, TRUE);
557 gtk_widget_set_sensitive(offset_label, TRUE);
558 gtk_widget_set_sensitive(gap_label, TRUE);
559 }
560
562 void adjust_event(GtkToggleButton *adjust_mode, gpointer user_data)
563 {
564 //if it is toggled
565 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adjust_mode)))
566 {
567 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(frame_mode)))
568 {
569 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frame_mode),TRUE);
570 }
571 enable_adjust_spinners();
572 }
573 else
574 {
575 //disable spinners
576 disable_adjust_spinners();
577 }
578
579 save_preferences(NULL, NULL);
580 }
581
583 void frame_event(GtkToggleButton *frame_mode, gpointer user_data)
584 {
585 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(frame_mode)))
586 {
587 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adjust_mode)))
588 {
589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adjust_mode),FALSE);
590 }
591 }
592
593 save_preferences(NULL, NULL);
594 }
595
596 void splitpoints_from_filename_event(GtkToggleButton *frame_mode, gpointer user_data)
597 {
598 gint splitpoints_from_filename = FALSE;
599
600 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(names_from_filename)))
601 {
602 splitpoints_from_filename = FALSE;
603 }
604 else
605 {
606 splitpoints_from_filename = TRUE;
607 }
608
609 if (splitpoints_from_filename == TRUE && file_browsed == TRUE)
610 {
611 copy_filename_to_current_description(inputfilename_get());
612 }
613 else
614 {
615 clear_current_description();
616 }
617
618 save_preferences(NULL, NULL);
619 }
620
622 void set_default_prefs_event(GtkWidget *widget, gpointer data)
623 {
624 //set frame mode inactive
625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frame_mode), FALSE);
626 //set adjust mode inactive
627 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(adjust_mode), FALSE);
628 //set adjust mode preferences
629 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_adjust_threshold),
630 SPLT_DEFAULT_PARAM_THRESHOLD);
631 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_adjust_offset),
632 SPLT_DEFAULT_PARAM_OFFSET);
633 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_adjust_gap),
634 SPLT_DEFAULT_PARAM_GAP);
635 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(names_from_filename), FALSE);
636
637 save_preferences(NULL, NULL);
638 }
639
641 void song_dir_button_event(GtkWidget *widget, gpointer data)
642 {
643 outputdirectory_set("");
644 save_preferences(NULL, NULL);
645 }
646
648 GtkWidget *create_directory_box()
649 {
650 GtkWidget *dir_hbox = gtk_hbox_new(FALSE, 0);
651
652 //directory entry
653 directory_entry = gtk_entry_new();
654 gtk_editable_set_editable(GTK_EDITABLE(directory_entry), FALSE);
655 gtk_box_pack_start(GTK_BOX(dir_hbox), directory_entry, TRUE, TRUE, 0);
656 // Put the right text into the text box containing the output directory
657 // name if this name was provided on command line
658 if(outputdirectory_get()!=NULL)
659 gtk_entry_set_text(GTK_ENTRY(directory_entry), outputdirectory_get());
660
661 //browse dir button
662 GtkWidget *browse_dir_button = (GtkWidget *)
663 create_cool_button(GTK_STOCK_DIRECTORY,_("Br_owse dir"), FALSE);
664 g_signal_connect(G_OBJECT(browse_dir_button), "clicked",
665 G_CALLBACK(browse_dir_button_event), NULL);
666 gtk_box_pack_start(GTK_BOX(dir_hbox), browse_dir_button, FALSE, FALSE, 8);
667
668 //to set the directory for split files to the current song
669 //directory
670 GtkWidget *song_dir_button = (GtkWidget *)
671 create_cool_button(GTK_STOCK_CLEAR, _("_Song dir"), FALSE);
672 g_signal_connect(G_OBJECT(song_dir_button), "clicked",
673 G_CALLBACK(song_dir_button_event), NULL);
674 gtk_box_pack_start(GTK_BOX(dir_hbox), song_dir_button, FALSE, FALSE, 0);
675
676 return wh_set_title_and_get_vbox(dir_hbox, _("<b>Directory for split files</b>"));
677 }
678
680 GtkWidget *create_split_options_box()
681 {
682 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
683
684 //names from filename
685 names_from_filename = gtk_check_button_new_with_mnemonic(_("_Splitpoint name from filename (testing)"));
686 gtk_box_pack_start(GTK_BOX(vbox), names_from_filename, FALSE, FALSE, 0);
687 g_signal_connect(G_OBJECT(names_from_filename), "toggled",
688 G_CALLBACK(splitpoints_from_filename_event), NULL);
689
690 create_dirs_from_output_files =
691 gtk_check_button_new_with_mnemonic(_("_Create directories from filenames "));
692 gtk_box_pack_start(GTK_BOX(vbox), create_dirs_from_output_files, FALSE, FALSE, 0);
693 g_signal_connect(G_OBJECT(create_dirs_from_output_files), "toggled",
694 G_CALLBACK(save_preferences), NULL);
695
696 //frame mode option
697 frame_mode = gtk_check_button_new_with_mnemonic(_("F_rame mode (useful"
698 " for mp3 VBR) (mp3 only)"));
699 gtk_box_pack_start(GTK_BOX(vbox), frame_mode, FALSE, FALSE, 0);
700 g_signal_connect(G_OBJECT(frame_mode), "toggled",
701 G_CALLBACK(frame_event), NULL);
702
703 //auto adjust option
704 adjust_mode = gtk_check_button_new_with_mnemonic(_("_Auto-adjust mode (uses"
705 " silence detection to auto-adjust splitpoints)"));
706 gtk_box_pack_start(GTK_BOX(vbox), adjust_mode, FALSE, FALSE, 0);
707 g_signal_connect(G_OBJECT(adjust_mode), "toggled",
708 G_CALLBACK(adjust_event), NULL);
709
710 //parameters for the adjust option
711 GtkWidget *horiz_fake = gtk_hbox_new(FALSE,0);
712 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
713
714 GtkWidget *param_vbox = gtk_vbox_new(FALSE,0);
715 gtk_box_pack_start(GTK_BOX(horiz_fake), param_vbox, FALSE, FALSE, 25);
716
717 //threshold level
718 horiz_fake = gtk_hbox_new(FALSE,0);
719 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
720
721 threshold_label = gtk_label_new(_("Threshold level (dB):"));
722 gtk_box_pack_start(GTK_BOX(horiz_fake), threshold_label, FALSE, FALSE, 0);
723
724 GtkAdjustment *adj = (GtkAdjustment *) gtk_adjustment_new(0.0, -96.0, 0.0,
725 0.5, 10.0, 0.0);
726 spinner_adjust_threshold = gtk_spin_button_new (adj, 0.5, 2);
727 g_signal_connect(G_OBJECT(spinner_adjust_threshold), "value_changed",
728 G_CALLBACK(save_preferences), NULL);
729 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_threshold,
730 FALSE, FALSE, 6);
731
732 //offset level
733 horiz_fake = gtk_hbox_new(FALSE,0);
734 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
735
736 offset_label = gtk_label_new(_("Cutpoint offset (0 is the begin of silence "
737 "and 1 the end):"));
738 gtk_box_pack_start(GTK_BOX(horiz_fake), offset_label, FALSE, FALSE, 0);
739
740 //adjustement for the offset spinner
741 adj = (GtkAdjustment *)gtk_adjustment_new(0.0, -2, 2, 0.05, 10.0, 0.0);
742 //the offset spinner
743 spinner_adjust_offset = gtk_spin_button_new (adj, 0.05, 2);
744 g_signal_connect(G_OBJECT(spinner_adjust_offset), "value_changed",
745 G_CALLBACK(save_preferences), NULL);
746 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_offset,
747 FALSE, FALSE, 6);
748
749 //gap level (seconds)
750 horiz_fake = gtk_hbox_new(FALSE,0);
751 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
752
753 gap_label = gtk_label_new(_("Gap level (seconds around splitpoint to "
754 "search for silence):"));
755 gtk_box_pack_start(GTK_BOX(horiz_fake), gap_label, FALSE, FALSE, 0);
756
757 adj = (GtkAdjustment *) gtk_adjustment_new(0.0, 0, 2000, 1.0, 10.0, 0.0);
758 spinner_adjust_gap = gtk_spin_button_new (adj, 1, 0);
759 g_signal_connect(G_OBJECT(spinner_adjust_gap), "value_changed",
760 G_CALLBACK(save_preferences), NULL);
761 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_gap, FALSE, FALSE, 6);
762
763 disable_adjust_spinners();
764
765 //set default preferences button
766 //horizontal box fake for the gap level
767 horiz_fake = gtk_hbox_new(FALSE,0);
768 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
769
770 GtkWidget *set_default_prefs_button =
771 (GtkWidget *)create_cool_button(GTK_STOCK_PREFERENCES,
772 _("Set _default split" " options"),FALSE);
773 g_signal_connect(G_OBJECT(set_default_prefs_button), "clicked",
774 G_CALLBACK(set_default_prefs_event), NULL);
775 gtk_box_pack_start (GTK_BOX (horiz_fake), set_default_prefs_button,
776 FALSE, FALSE, 5);
777
778 return wh_set_title_and_get_vbox(vbox, _("<b>Split options</b>"));
779 }
780
782 GtkWidget *create_pref_splitpoints_page()
783 {
784 GtkWidget *general_hbox = gtk_hbox_new(FALSE,0);
785 GtkWidget *inside_hbox = gtk_hbox_new(FALSE,0);
786
787 GtkWidget *scrolled_window = create_scrolled_window();
788 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
789 GTK_WIDGET(inside_hbox));
790 gtk_box_pack_start(GTK_BOX(general_hbox), scrolled_window, TRUE, TRUE, 0);
791
792 //vertical box inside the horizontal box from the scrolled window
793 GtkWidget *inside_vbox = gtk_vbox_new(FALSE, 0);
794 gtk_box_pack_start(GTK_BOX(inside_hbox), inside_vbox, TRUE, TRUE, 5);
795
796 GtkWidget *dir_box = create_directory_box();
797 gtk_box_pack_start(GTK_BOX(inside_vbox), dir_box, FALSE, FALSE, 2);
798
799 GtkWidget *split_options_box = create_split_options_box();
800 gtk_box_pack_start(GTK_BOX(inside_vbox), split_options_box, FALSE, FALSE, 1);
801
802 return general_hbox;
803 }
804
806 void player_combo_box_event(GtkComboBox *widget, gpointer data)
807 {
808 disconnect_button_event(NULL, NULL);
809
810 selected_player = ch_get_active_value(widget);
811
812 if (selected_player == PLAYER_GSTREAMER)
813 {
814 hide_connect_button();
815 gtk_widget_show(playlist_box);
816 }
817 else
818 {
819 show_connect_button();
820 close_playlist_popup_window_event(NULL, NULL);
821 gtk_widget_hide(playlist_box);
822 }
823
824 gtk_widget_show(player_box);
825 gtk_widget_show(queue_files_button);
826
827 save_preferences(NULL, NULL);
828 }
829
830 void update_timeout_value(GtkWidget *refresh_rate_spinner, gpointer data)
831 {
832 timeout_value =
833 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(player_refresh_rate_spinner));
834
835 restart_player_timer();
836 save_preferences(NULL, NULL);
837 }
838
840 GtkWidget *create_player_options_box()
841 {
842 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
843
844 GtkWidget *horiz_fake = gtk_hbox_new(FALSE, 0);
845
846 GtkWidget *label = gtk_label_new(_("Player:"));
847 gtk_box_pack_start(GTK_BOX(horiz_fake), label, FALSE, FALSE, 0);
848
849 player_combo_box = GTK_WIDGET(ch_new_combo());
850
851 #ifndef NO_AUDACIOUS
852 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box), "Audacious", PLAYER_AUDACIOUS);
853 #endif
854 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box), "SnackAmp", PLAYER_SNACKAMP);
855 #ifndef NO_GSTREAMER
856 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box), "GStreamer", PLAYER_GSTREAMER);
857 #endif
858
859 g_signal_connect(G_OBJECT(player_combo_box), "changed",
860 G_CALLBACK(player_combo_box_event), NULL);
861
862 gtk_box_pack_start(GTK_BOX(horiz_fake), player_combo_box, FALSE, FALSE, 5);
863 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
864
865 //Player Splitpoints view refresh rate
866 horiz_fake = gtk_hbox_new(FALSE,0);
867
868 label = gtk_label_new(_("Refresh player every "));
869 gtk_box_pack_start(GTK_BOX(horiz_fake), label, FALSE, FALSE, 0);
870
871 GtkAdjustment *adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
872 20, 1000, 10.0, 100.0, 0.0);
873 player_refresh_rate_spinner = gtk_spin_button_new(adj, 0, 0);
874 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(player_refresh_rate_spinner), TRUE);
875 g_signal_connect(G_OBJECT(player_refresh_rate_spinner), "value_changed",
876 G_CALLBACK(update_timeout_value), NULL);
877
878 gtk_box_pack_start(GTK_BOX(horiz_fake), player_refresh_rate_spinner, FALSE, FALSE, 5);
879 gtk_box_pack_start(GTK_BOX(horiz_fake), gtk_label_new(_("milliseconds.")), FALSE, FALSE, 3);
880 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
881
882 horiz_fake = gtk_hbox_new(FALSE,0);
883 gtk_box_pack_start(GTK_BOX(horiz_fake),
884 gtk_label_new(_("Higher refresh rate decreases CPU usage - default is 200.")),
885 FALSE, FALSE, 0);
886 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
887
888 return wh_set_title_and_get_vbox(vbox, _("<b>Player options</b>"));
889 }
890
892 GtkWidget *create_pref_player_page()
893 {
894 GtkWidget *player_hbox = gtk_hbox_new(FALSE, 0);;
895
896 GtkWidget *inside_hbox = gtk_hbox_new(FALSE, 0);;
897
898 GtkWidget *scrolled_window = create_scrolled_window();
899 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
900 GTK_WIDGET(inside_hbox));
901 gtk_box_pack_start(GTK_BOX(player_hbox), scrolled_window, TRUE, TRUE, 0);
902
903 //vertical box inside the horizontal box from the scrolled window
904 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
905 gtk_box_pack_start(GTK_BOX(inside_hbox), vbox, TRUE, TRUE, 5);
906
907 //choose player combo box
908 GtkWidget *player_options_box = create_player_options_box();
909 gtk_box_pack_start(GTK_BOX(vbox), player_options_box, FALSE, FALSE, 3);
910
911 return player_hbox;
912 }
913
915 gboolean output_entry_event(GtkWidget *widget, GdkEventKey *event,
916 gpointer user_data)
917 {
918 //we check if the output format is correct
919 const char *data = gtk_entry_get_text(GTK_ENTRY(output_entry));
920 gint error = SPLT_OUTPUT_FORMAT_OK;
921 mp3splt_set_oformat(the_state, data, &error);
922 remove_status_message();
923 print_status_bar_confirmation(error);
924
925 save_preferences(NULL, NULL);
926
927 return FALSE;
928 }
929
931 GtkWidget *create_output_filename_box()
932 {
933 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
934
935 //default/custom radio buttons
936 radio_output = gtk_radio_button_new_with_label(NULL, _("Default format"));
937 gtk_box_pack_start(GTK_BOX(vbox), radio_output, FALSE, FALSE, 0);
938
939 radio_output = gtk_radio_button_new_with_label_from_widget
940 (GTK_RADIO_BUTTON(radio_output), _("Custom format"));
941 gtk_box_pack_start(GTK_BOX(vbox), radio_output, FALSE, FALSE, 0);
942
943 //output entry
944 GtkWidget *horiz_fake = gtk_hbox_new(FALSE,0);
945 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
946
947 output_entry = gtk_entry_new();
948 gtk_editable_set_editable(GTK_EDITABLE(output_entry), TRUE);
949 g_signal_connect(G_OBJECT(output_entry), "key_release_event",
950 G_CALLBACK(output_entry_event), NULL);
951 gtk_entry_set_max_length(GTK_ENTRY(output_entry),244);
952 gtk_box_pack_start(GTK_BOX(horiz_fake), output_entry, TRUE, TRUE, 0);
953
954 //output label
955 horiz_fake = gtk_hbox_new(FALSE,0);
956 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
957 output_label = gtk_label_new(_(" @f - file name\n"
958 " @a - artist name\n"
959 " @p - performer of each song (does not"
960 " always exist)\n"
961 " @b - album title\n"
962 " @t - song title\n"
963 " @g - genre\n"
964 " @n - track number"));
965 gtk_box_pack_start(GTK_BOX(horiz_fake), output_label, FALSE, FALSE, 0);
966
967 g_signal_connect(GTK_TOGGLE_BUTTON(radio_output),
968 "toggled", G_CALLBACK(output_radio_box_event), output_label);
969
970 return wh_set_title_and_get_vbox(vbox, _("<b>Output filename format</b>"));
971 }
972
974 GtkWidget *create_pref_output_page()
975 {
976 GtkWidget *output_hbox = gtk_hbox_new(FALSE, 0);;
977 GtkWidget *output_inside_hbox = gtk_hbox_new(FALSE, 0);;
978
979 GtkWidget *scrolled_window = create_scrolled_window();
980 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
981 GTK_WIDGET(output_inside_hbox));
982 gtk_box_pack_start(GTK_BOX(output_hbox), scrolled_window, TRUE, TRUE, 0);
983
984 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
985 gtk_box_pack_start(GTK_BOX(output_inside_hbox), vbox, TRUE, TRUE, 5);
986
987 GtkWidget *output_fname_box = create_output_filename_box();
988 gtk_box_pack_start(GTK_BOX(vbox), output_fname_box, FALSE, FALSE, 2);
989
990 return output_hbox;
991 }
992
993 void change_tags_options(GtkToggleButton *button, gpointer data)
994 {
995 if (extract_tags_box != NULL)
996 {
997 if (rh_get_active_value(tags_radio) == TAGS_FROM_FILENAME)
998 {
999 gtk_widget_set_sensitive(extract_tags_box, SPLT_TRUE);
1000 }
1001 else
1002 {
1003 gtk_widget_set_sensitive(extract_tags_box, SPLT_FALSE);
1004 }
1005 }
1006
1007 save_preferences(NULL, NULL);
1008 }
1009
1011 GtkWidget *create_tags_options_box()
1012 {
1013 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
1014
1015 tags_radio = rh_append_radio_to_vbox(tags_radio, _("Original file tags"),
1016 ORIGINAL_FILE_TAGS, change_tags_options, vbox);
1017
1018 tags_radio = rh_append_radio_to_vbox(tags_radio, _("Default tags (cddb or cue tags)"),
1019 DEFAULT_TAGS, change_tags_options, vbox);
1020
1021 tags_radio = rh_append_radio_to_vbox(tags_radio, _("No tags"),
1022 NO_TAGS, change_tags_options, vbox);
1023
1024 tags_radio = rh_append_radio_to_vbox(tags_radio, _("Extract tags from filename"),
1025 TAGS_FROM_FILENAME, change_tags_options, vbox);
1026
1027 extract_tags_box = create_extract_tags_from_filename_options_box();
1028 gtk_widget_set_sensitive(extract_tags_box, SPLT_FALSE);
1029 gtk_box_pack_start(GTK_BOX(vbox), extract_tags_box, FALSE, FALSE, 2);
1030
1031 return wh_set_title_and_get_vbox(vbox, _("<b>Split files tags</b>"));
1032 }
1033
1034 static GtkComboBox *create_genre_combo()
1035 {
1036 GtkComboBox *combo = ch_new_combo();
1037
1038 int i = 0;
1039 for (i = 0;i < SPLT_ID3V1_NUMBER_OF_GENRES;i++)
1040 {
1041 ch_append_to_combo(combo, splt_id3v1_genres[i], 0);
1042 }
1043
1044 g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(save_preferences), NULL);
1045
1046 return combo;
1047 }
1048
1049 static GtkComboBox *create_text_preferences_combo()
1050 {
1051 GtkComboBox *combo = ch_new_combo();
1052
1053 ch_append_to_combo(combo, _("No change"), SPLT_NO_CONVERSION);
1054 ch_append_to_combo(combo, _("lowercase"), SPLT_TO_LOWERCASE);
1055 ch_append_to_combo(combo, _("UPPERCASE"), SPLT_TO_UPPERCASE);
1056 ch_append_to_combo(combo, _("First uppercase"), SPLT_TO_FIRST_UPPERCASE);
1057 ch_append_to_combo(combo, _("Word Uppercase"), SPLT_TO_WORD_FIRST_UPPERCASE);
1058
1059 g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(save_preferences), NULL);
1060
1061 return combo;
1062 }
1063
1064 void test_regex_event(GtkWidget *widget, gpointer data)
1065 {
1066 put_tags_from_filename_regex_options();
1067 const gchar *test_regex_filename = gtk_entry_get_text(GTK_ENTRY(test_regex_fname_entry));
1068 mp3splt_set_filename_to_split(the_state, test_regex_filename);
1069
1070 gint error = SPLT_OK;
1071 splt_tags *tags = mp3splt_parse_filename_regex(the_state, &error);
1072 print_status_bar_confirmation(error);
1073
1074 if (error >= 0)
1075 {
1076 GString *regex_result = g_string_new(NULL);
1077
1078 g_string_append(regex_result, _("<artist>: "));
1079 if (tags->artist)
1080 {
1081 g_string_append(regex_result, tags->artist);
1082 }
1083 g_string_append(regex_result, "\n");
1084
1085 g_string_append(regex_result, _("<album>: "));
1086 if (tags->album)
1087 {
1088 g_string_append(regex_result, tags->album);
1089 }
1090 g_string_append(regex_result, "\n");
1091
1092
1093 g_string_append(regex_result, _("<title>: "));
1094 if (tags->title)
1095 {
1096 g_string_append(regex_result, tags->title);
1097 }
1098 g_string_append(regex_result, "\n");
1099
1100 g_string_append(regex_result, _("<genre>: "));
1101 if (tags->genre)
1102 {
1103 g_string_append(regex_result, tags->genre);
1104 }
1105 g_string_append(regex_result, "\n");
1106
1107 g_string_append(regex_result, _("<comment>: "));
1108 if (tags->comment)
1109 {
1110 g_string_append(regex_result, tags->comment);
1111 }
1112 g_string_append(regex_result, "\n");
1113
1114 g_string_append(regex_result, _("<year>: "));
1115 if (tags->year)
1116 {
1117 g_string_append(regex_result, tags->year);
1118 }
1119 g_string_append(regex_result, "\n");
1120
1121 g_string_append(regex_result, _("<track>: "));
1122 if (tags->track >= 0)
1123 {
1124 g_string_append_printf(regex_result, "%d", tags->track);
1125 }
1126
1127 gchar *regex_result_text = g_string_free(regex_result, FALSE);
1128 if (regex_result_text)
1129 {
1130 gtk_label_set_text(GTK_LABEL(sample_result_label), regex_result_text);
1131 g_free(regex_result_text);
1132 }
1133 }
1134 else
1135 {
1136 gtk_label_set_text(GTK_LABEL(sample_result_label), "");
1137 }
1138
1139 mp3splt_free_one_tag(tags);
1140 }
1141
1142 static GtkWidget *create_extract_tags_from_filename_options_box()
1143 {
1144 GtkWidget *table = wh_new_table();
1145
1146 regex_entry = wh_new_entry(save_preferences);
1147 wh_add_in_table_with_label_expand(table, _("Regular expression:"), regex_entry);
1148
1149 GtkWidget *regex_label = gtk_label_new(_(
1150 "Above enter PERL-like regular expression using named subgroups.\nFollowing names are recognized:\n"
1151 " (?<artist>) - artist name\n"
1152 " (?<album>) - album title\n"
1153 " (?<title>) - track title\n"
1154 " (?<tracknum>) - current track number\n"
1155 //" (?<tracks>) - total number of tracks\n"
1156 " (?<year>) - year of emission\n"
1157 " (?<genre>) - genre\n"
1158 " (?<comment>) - comment"));
1159 gtk_misc_set_alignment(GTK_MISC(regex_label), 0.0, 0.5);
1160 wh_add_in_table(table, wh_put_in_new_hbox_with_margin_level(regex_label, 2));
1161
1162 text_options_list =
1163 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_NO_CONVERSION));
1164 text_options_list =
1165 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_LOWERCASE));
1166 text_options_list =
1167 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_UPPERCASE));
1168 text_options_list =
1169 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_FIRST_UPPERCASE));
1170 text_options_list =
1171 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_WORD_FIRST_UPPERCASE));
1172
1173 replace_underscore_by_space_check_box =
1174 gtk_check_button_new_with_mnemonic(_("_Replace underscores by spaces"));
1175 g_signal_connect(G_OBJECT(replace_underscore_by_space_check_box), "toggled",
1176 G_CALLBACK(save_preferences), NULL);
1177
1178 wh_add_in_table(table, replace_underscore_by_space_check_box);
1179
1180 artist_text_properties_combo = create_text_preferences_combo();
1181 wh_add_in_table_with_label(table,
1182 _("Artist text properties:"), GTK_WIDGET(artist_text_properties_combo));
1183
1184 album_text_properties_combo = create_text_preferences_combo();
1185 wh_add_in_table_with_label(table,
1186 _("Album text properties:"), GTK_WIDGET(album_text_properties_combo));
1187
1188 title_text_properties_combo = create_text_preferences_combo();
1189 wh_add_in_table_with_label(table,
1190 _("Title text properties:"), GTK_WIDGET(title_text_properties_combo));
1191
1192 comment_text_properties_combo = create_text_preferences_combo();
1193 wh_add_in_table_with_label(table,
1194 _("Comment text properties:"), GTK_WIDGET(comment_text_properties_combo));
1195
1196 genre_combo = create_genre_combo();
1197 wh_add_in_table_with_label(table, _("Genre tag:"), GTK_WIDGET(genre_combo));
1198
1199 comment_tag_entry = wh_new_entry(save_preferences);
1200 wh_add_in_table_with_label_expand(table, _("Comment tag:"), comment_tag_entry);
1201
1202 GtkWidget *test_regex_expander = gtk_expander_new(_("Regular expression test"));
1203 gtk_container_add(GTK_CONTAINER(test_regex_expander), create_test_regex_table());
1204 wh_add_in_table(table, test_regex_expander);
1205
1206 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1207 }
1208
1209 static GtkWidget *create_test_regex_table()
1210 {
1211 GtkWidget *table = wh_new_table();
1212
1213 GtkWidget *sample_test_hbox = gtk_hbox_new(FALSE, 0);
1214 test_regex_fname_entry = wh_new_entry(save_preferences);
1215 gtk_box_pack_start(GTK_BOX(sample_test_hbox), test_regex_fname_entry, TRUE, TRUE, 0);
1216
1217 GtkWidget *test_regex_button = wh_new_button(_("_Test"));
1218 gtk_box_pack_start(GTK_BOX(sample_test_hbox), test_regex_button, FALSE, FALSE, 5);
1219 g_signal_connect(G_OBJECT(test_regex_button), "clicked",
1220 G_CALLBACK(test_regex_event), NULL);
1221
1222 wh_add_in_table_with_label_expand(table, _("Sample filename:"), sample_test_hbox);
1223
1224 sample_result_label = gtk_label_new("");
1225 gtk_misc_set_alignment(GTK_MISC(sample_result_label), 0.0, 0.5);
1226 wh_add_in_table_with_label_expand(table, _("Sample result:"), sample_result_label);
1227
1228 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1229 }
1230
1232 GtkWidget *create_tags_version_box()
1233 {
1234 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
1235
1236 tags_version_radio =
1237 gtk_radio_button_new_with_label(NULL, _("ID3v1 & ID3v2 tags"));
1238 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1239 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio), "toggled",
1240 G_CALLBACK(save_preferences), NULL);
1241
1242 tags_version_radio =
1243 gtk_radio_button_new_with_label_from_widget
1244 (GTK_RADIO_BUTTON(tags_version_radio), _("ID3v2 tags"));
1245 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1246 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio), "toggled",
1247 G_CALLBACK(save_preferences), NULL);
1248
1249 tags_version_radio = gtk_radio_button_new_with_label_from_widget
1250 (GTK_RADIO_BUTTON(tags_version_radio), _("ID3v1 tags"));
1251 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio), "toggled",
1252 G_CALLBACK(save_preferences), NULL);
1253 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1254
1255 tags_version_radio = gtk_radio_button_new_with_label_from_widget
1256 (GTK_RADIO_BUTTON (tags_version_radio),_("Same tags version as the input file"));
1257 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio), "toggled",
1258 G_CALLBACK(save_preferences), NULL);
1259 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1260
1261 return wh_set_title_and_get_vbox(vbox, _("<b>Tags version (mp3 only)</b>"));
1262 }
1263
1265 GtkWidget *create_pref_tags_page()
1266 {
1267 GtkWidget *outside_vbox = gtk_vbox_new(FALSE, 0);;
1268 GtkWidget *inside_hbox = gtk_hbox_new(FALSE, 0);
1269
1270 GtkWidget *scrolled_window = create_scrolled_window();
1271 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1272 GTK_WIDGET(inside_hbox));
1273 gtk_box_pack_start(GTK_BOX(outside_vbox), scrolled_window, TRUE, TRUE, 0);
1274
1275 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
1276 gtk_box_pack_start(GTK_BOX(inside_hbox), vbox, TRUE, TRUE, 5);
1277
1278 GtkWidget *tags_version_box = create_tags_version_box();
1279 gtk_box_pack_start(GTK_BOX(vbox), tags_version_box, FALSE, FALSE, 2);
1280
1281 GtkWidget *tags_opts_box = create_tags_options_box();
1282 gtk_box_pack_start(GTK_BOX(vbox), tags_opts_box, FALSE, FALSE, 1);
1283
1284 return outside_vbox;
1285 }
1286
1288 GtkWidget *create_choose_preferences()
1289 {
1290 //our preferences vbox
1291 GtkWidget *pref_vbox = gtk_vbox_new(FALSE, 0);
1292
1293 GtkWidget *notebook = gtk_notebook_new();
1294 gtk_box_pack_start(GTK_BOX(pref_vbox), notebook, TRUE, TRUE, 0);
1295
1296 gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook));
1297 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
1298 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
1299 gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
1300
1301 /* split preferences */
1302 GtkWidget *splitpoints_prefs = (GtkWidget *)create_pref_splitpoints_page();
1303 GtkWidget *notebook_label = gtk_label_new(_("Split"));
1304 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), splitpoints_prefs,
1305 (GtkWidget *)notebook_label);
1306
1307 /* tags preferences */
1308 GtkWidget *tags_prefs = (GtkWidget *)create_pref_tags_page();
1309 notebook_label = gtk_label_new(_("Tags"));
1310 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tags_prefs,
1311 (GtkWidget *)notebook_label);
1312
1313 /* output preferences */
1314 GtkWidget *output_prefs = (GtkWidget *)create_pref_output_page();
1315 notebook_label = gtk_label_new(_("Output"));
1316 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), output_prefs,
1317 (GtkWidget *)notebook_label);
1318
1319 /* player preferences */
1320 GtkWidget *player_prefs = (GtkWidget *)create_pref_player_page();
1321 notebook_label = gtk_label_new(_("Player"));
1322 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), player_prefs,
1323 (GtkWidget *)notebook_label);
1324
1325 /* language preferences page */
1326 #ifdef __WIN32__
1327 GtkWidget *language_prefs = (GtkWidget *)create_pref_language_page();
1328 notebook_label = gtk_label_new(_("Language"));
1329 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), language_prefs,
1330 (GtkWidget *)notebook_label);
1331 #endif
1332
1333 return pref_vbox;
1334 }