41 #include <glib/gi18n.h>
43 #include <glib/gstdio.h>
48 #include "preferences_tab.h"
51 #include "player_tab.h"
52 #include "utilities.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"
74 GtkWidget *output_label = NULL;
78 GtkWidget *player_refresh_rate_spinner = NULL;
82 GList *text_options_list = NULL;
84 gint selected_player = PLAYER_GSTREAMER;
94 GtkWidget *tags_version_radio = NULL;
102 GtkWidget *names_from_filename = NULL;
104 GtkWidget *create_dirs_from_output_files = 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;
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;
131 GtkWidget *extract_tags_box = NULL;
134 extern gint timeout_value;
135 extern GtkWidget *player_box;
136 extern GtkWidget *playlist_box;
139 extern gint selected_split_mode;
140 extern gint split_file_mode;
141 extern GtkWidget *spinner_time;
142 extern GtkWidget *spinner_equal_tracks;
146 static GtkWidget *create_extract_tags_from_filename_options_box();
147 static GtkWidget *create_test_regex_table();
149 extern void clear_current_description(
void);
150 extern void copy_filename_to_current_description(
const gchar *fname);
160 GSList *radio_button_list;
161 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(
radio_button));
162 GtkWidget *our_button;
165 our_button = (GtkWidget *)g_slist_nth_data(radio_button_list, 0);
166 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(our_button)))
168 return g_string_new(
"de_DE");
172 our_button = (GtkWidget *)g_slist_nth_data(radio_button_list, 1);
173 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(our_button)))
175 return g_string_new(
"fr_FR");
179 return g_string_new(
"en");
186 GSList *radio_button_list;
187 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(
radio_output));
189 GtkToggleButton *test;
190 gint i, selected = 0;
195 test = (GtkToggleButton *)g_slist_nth_data(radio_button_list,i);
196 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(test)))
209 GSList *radio_button_list;
210 radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(tags_version_radio));
213 GtkToggleButton *test;
214 gint i, selected = 0;
221 test = (GtkToggleButton *)g_slist_nth_data(radio_button_list,i);
222 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(test)))
262 void save_preferences(GtkWidget *widget, gpointer data)
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);
270 g_key_file_set_string(my_key_file,
"split",
"save_path",
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)));
280 GString *selected_lang;
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;
288 g_key_file_set_boolean(my_key_file,
"split",
"frame_mode",
289 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
frame_mode)));
292 g_key_file_set_boolean(my_key_file,
"split",
"adjust_mode",
293 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
adjust_mode)));
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);
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);
302 g_key_file_set_integer(my_key_file,
"split",
"adjust_gap",
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)));
309 g_key_file_set_string(my_key_file,
"output",
"output_format",
312 g_key_file_set_boolean(my_key_file,
"output",
"default_output_format",
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)));
318 g_key_file_set_integer(my_key_file,
"split",
"tags", rh_get_active_value(
tags_radio));
321 g_key_file_set_boolean(my_key_file,
"split",
"replace_underscore_by_space",
325 g_key_file_set_integer(my_key_file,
"split",
"artist_text_properties",
326 ch_get_active_value(artist_text_properties_combo));
328 g_key_file_set_integer(my_key_file,
"split",
"album_text_properties",
329 ch_get_active_value(album_text_properties_combo));
331 g_key_file_set_integer(my_key_file,
"split",
"title_text_properties",
332 ch_get_active_value(title_text_properties_combo));
334 g_key_file_set_integer(my_key_file,
"split",
"comment_text_properties",
335 ch_get_active_value(comment_text_properties_combo));
338 gchar *genre_value = ch_get_active_str_value(genre_combo);
339 if (genre_value != NULL)
341 g_key_file_set_string(my_key_file,
"split",
"genre", genre_value);
344 const gchar *comment = gtk_entry_get_text(GTK_ENTRY(comment_tag_entry));
347 g_key_file_set_string(my_key_file,
"split",
"default_comment_tag", comment);
350 const gchar *regex_text = gtk_entry_get_text(GTK_ENTRY(regex_entry));
351 if (regex_text != NULL)
353 g_key_file_set_string(my_key_file,
"split",
"tags_from_filename_regex", regex_text);
356 const gchar *test_regex_fname = gtk_entry_get_text(GTK_ENTRY(test_regex_fname_entry));
357 if (test_regex_fname_entry != NULL)
359 g_key_file_set_string(my_key_file,
"split",
"test_regex_fname", test_regex_fname);
363 g_key_file_set_integer(my_key_file,
"split",
"tags_version",
367 g_key_file_set_integer(my_key_file,
"split",
"split_mode",
368 selected_split_mode);
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)));
373 g_key_file_set_integer(my_key_file,
"split",
"file_mode",
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)));
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",
386 g_key_file_set_integer(my_key_file,
"gui",
"height",
389 const char *browser_directory = ui_get_browser_directory(ui);
390 if (browser_directory != NULL)
392 g_key_file_set_string(my_key_file,
"gui",
"browser_directory", browser_directory);
395 gchar *key_data = g_key_file_to_data(my_key_file, NULL, NULL);
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;
406 g_key_file_free(my_key_file);
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;
430 GtkWidget *output_label = (GtkWidget *)data;
437 gtk_widget_set_sensitive(GTK_WIDGET(
output_entry), TRUE);
438 gtk_widget_set_sensitive(GTK_WIDGET(output_label), TRUE);
444 gtk_widget_set_sensitive(GTK_WIDGET(
output_entry), FALSE);
445 gtk_widget_set_sensitive(GTK_WIDGET(output_label), FALSE);
450 save_preferences(NULL, NULL);
456 GtkWidget *radio_vbox = gtk_vbox_new (FALSE, 0);
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);
463 radio_button = gtk_radio_button_new_with_label_from_widget
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);
469 radio_button = gtk_radio_button_new_with_label_from_widget
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);
476 _(
"<b>Choose language (requires restart)</b>"));
482 GtkWidget *language_hbox = gtk_hbox_new(FALSE, 0);;
485 GtkWidget *language_inside_hbox = gtk_hbox_new(FALSE, 0);;
488 GtkWidget *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);
495 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
496 gtk_box_pack_start(GTK_BOX(language_inside_hbox), vbox, TRUE, TRUE, 10);
499 gtk_box_pack_start(GTK_BOX(vbox), lang_box, FALSE, FALSE, 10);
501 return language_hbox;
508 GtkWidget *dir_chooser;
511 dir_chooser = gtk_file_chooser_dialog_new(_(
"Choose split directory"),
513 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
520 wh_set_browser_directory_handler(ui, dir_chooser);
522 if (gtk_dialog_run(GTK_DIALOG(dir_chooser)) == GTK_RESPONSE_ACCEPT)
525 gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dir_chooser));
532 save_preferences(NULL, NULL);
536 gtk_widget_destroy(dir_chooser);
542 gtk_widget_set_sensitive(spinner_adjust_threshold, FALSE);
543 gtk_widget_set_sensitive(spinner_adjust_offset, 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);
553 gtk_widget_set_sensitive(spinner_adjust_threshold, TRUE);
554 gtk_widget_set_sensitive(spinner_adjust_offset, 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);
565 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adjust_mode)))
567 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
frame_mode)))
569 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
frame_mode),TRUE);
579 save_preferences(NULL, NULL);
585 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(frame_mode)))
587 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
adjust_mode)))
589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
adjust_mode),FALSE);
593 save_preferences(NULL, NULL);
596 void splitpoints_from_filename_event(GtkToggleButton *
frame_mode, gpointer user_data)
598 gint splitpoints_from_filename = FALSE;
600 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(names_from_filename)))
602 splitpoints_from_filename = FALSE;
606 splitpoints_from_filename = TRUE;
609 if (splitpoints_from_filename == TRUE &&
file_browsed == TRUE)
615 clear_current_description();
618 save_preferences(NULL, NULL);
625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frame_mode), FALSE);
627 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
adjust_mode), FALSE);
629 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_adjust_threshold),
631 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_adjust_offset),
635 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(names_from_filename), FALSE);
637 save_preferences(NULL, NULL);
644 save_preferences(NULL, NULL);
650 GtkWidget *dir_hbox = gtk_hbox_new(FALSE, 0);
662 GtkWidget *browse_dir_button = (GtkWidget *)
664 g_signal_connect(G_OBJECT(browse_dir_button),
"clicked",
666 gtk_box_pack_start(GTK_BOX(dir_hbox), browse_dir_button, FALSE, FALSE, 8);
670 GtkWidget *song_dir_button = (GtkWidget *)
672 g_signal_connect(G_OBJECT(song_dir_button),
"clicked",
674 gtk_box_pack_start(GTK_BOX(dir_hbox), song_dir_button, FALSE, FALSE, 0);
682 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
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);
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);
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",
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);
711 GtkWidget *horiz_fake = gtk_hbox_new(FALSE,0);
712 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
714 GtkWidget *param_vbox = gtk_vbox_new(FALSE,0);
715 gtk_box_pack_start(GTK_BOX(horiz_fake), param_vbox, FALSE, FALSE, 25);
718 horiz_fake = gtk_hbox_new(FALSE,0);
719 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
721 threshold_label = gtk_label_new(_(
"Threshold level (dB):"));
722 gtk_box_pack_start(GTK_BOX(horiz_fake), threshold_label, FALSE, FALSE, 0);
724 GtkAdjustment *adj = (GtkAdjustment *) gtk_adjustment_new(0.0, -96.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,
733 horiz_fake = gtk_hbox_new(FALSE,0);
734 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
736 offset_label = gtk_label_new(_(
"Cutpoint offset (0 is the begin of silence "
738 gtk_box_pack_start(GTK_BOX(horiz_fake), offset_label, FALSE, FALSE, 0);
741 adj = (GtkAdjustment *)gtk_adjustment_new(0.0, -2, 2, 0.05, 10.0, 0.0);
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,
750 horiz_fake = gtk_hbox_new(FALSE,0);
751 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
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);
757 adj = (GtkAdjustment *) gtk_adjustment_new(0.0, 0, 2000, 1.0, 10.0, 0.0);
760 G_CALLBACK(save_preferences), NULL);
767 horiz_fake = gtk_hbox_new(FALSE,0);
768 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
770 GtkWidget *set_default_prefs_button =
772 _(
"Set _default split" " options"),FALSE);
773 g_signal_connect(G_OBJECT(set_default_prefs_button),
"clicked",
775 gtk_box_pack_start (GTK_BOX (horiz_fake), set_default_prefs_button,
784 GtkWidget *general_hbox = gtk_hbox_new(FALSE,0);
785 GtkWidget *inside_hbox = gtk_hbox_new(FALSE,0);
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);
793 GtkWidget *inside_vbox = gtk_vbox_new(FALSE, 0);
794 gtk_box_pack_start(GTK_BOX(inside_hbox), inside_vbox, TRUE, TRUE, 5);
797 gtk_box_pack_start(GTK_BOX(inside_vbox), dir_box, FALSE, FALSE, 2);
800 gtk_box_pack_start(GTK_BOX(inside_vbox), split_options_box, FALSE, FALSE, 1);
810 selected_player = ch_get_active_value(widget);
812 if (selected_player == PLAYER_GSTREAMER)
815 gtk_widget_show(playlist_box);
821 gtk_widget_hide(playlist_box);
824 gtk_widget_show(player_box);
827 save_preferences(NULL, NULL);
830 void update_timeout_value(GtkWidget *refresh_rate_spinner, gpointer data)
833 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(player_refresh_rate_spinner));
835 restart_player_timer();
836 save_preferences(NULL, NULL);
842 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
844 GtkWidget *horiz_fake = gtk_hbox_new(FALSE, 0);
846 GtkWidget *label = gtk_label_new(_(
"Player:"));
847 gtk_box_pack_start(GTK_BOX(horiz_fake), label, FALSE, FALSE, 0);
852 ch_append_to_combo(GTK_COMBO_BOX(
player_combo_box),
"Audacious", PLAYER_AUDACIOUS);
854 ch_append_to_combo(GTK_COMBO_BOX(
player_combo_box),
"SnackAmp", PLAYER_SNACKAMP);
856 ch_append_to_combo(GTK_COMBO_BOX(
player_combo_box),
"GStreamer", PLAYER_GSTREAMER);
863 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
866 horiz_fake = gtk_hbox_new(FALSE,0);
868 label = gtk_label_new(_(
"Refresh player every "));
869 gtk_box_pack_start(GTK_BOX(horiz_fake), label, FALSE, FALSE, 0);
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);
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);
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.")),
886 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
894 GtkWidget *player_hbox = gtk_hbox_new(FALSE, 0);;
896 GtkWidget *inside_hbox = gtk_hbox_new(FALSE, 0);;
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);
904 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
905 gtk_box_pack_start(GTK_BOX(inside_hbox), vbox, TRUE, TRUE, 5);
909 gtk_box_pack_start(GTK_BOX(vbox), player_options_box, FALSE, FALSE, 3);
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);
925 save_preferences(NULL, NULL);
933 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
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);
939 radio_output = gtk_radio_button_new_with_label_from_widget
941 gtk_box_pack_start(GTK_BOX(vbox),
radio_output, FALSE, FALSE, 0);
944 GtkWidget *horiz_fake = gtk_hbox_new(FALSE,0);
945 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
948 gtk_editable_set_editable(GTK_EDITABLE(
output_entry), TRUE);
949 g_signal_connect(G_OBJECT(
output_entry),
"key_release_event",
952 gtk_box_pack_start(GTK_BOX(horiz_fake),
output_entry, TRUE, TRUE, 0);
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"
961 " @b - album title\n"
964 " @n - track number"));
965 gtk_box_pack_start(GTK_BOX(horiz_fake), output_label, FALSE, FALSE, 0);
976 GtkWidget *output_hbox = gtk_hbox_new(FALSE, 0);;
977 GtkWidget *output_inside_hbox = gtk_hbox_new(FALSE, 0);;
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);
984 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
985 gtk_box_pack_start(GTK_BOX(output_inside_hbox), vbox, TRUE, TRUE, 5);
988 gtk_box_pack_start(GTK_BOX(vbox), output_fname_box, FALSE, FALSE, 2);
993 void change_tags_options(GtkToggleButton *button, gpointer data)
995 if (extract_tags_box != NULL)
997 if (rh_get_active_value(
tags_radio) == TAGS_FROM_FILENAME)
999 gtk_widget_set_sensitive(extract_tags_box,
SPLT_TRUE);
1003 gtk_widget_set_sensitive(extract_tags_box,
SPLT_FALSE);
1007 save_preferences(NULL, NULL);
1013 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
1016 ORIGINAL_FILE_TAGS, change_tags_options, vbox);
1019 DEFAULT_TAGS, change_tags_options, vbox);
1022 NO_TAGS, change_tags_options, vbox);
1025 TAGS_FROM_FILENAME, change_tags_options, vbox);
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);
1034 static GtkComboBox *create_genre_combo()
1036 GtkComboBox *combo = ch_new_combo();
1039 for (i = 0;i < SPLT_ID3V1_NUMBER_OF_GENRES;i++)
1041 ch_append_to_combo(combo, splt_id3v1_genres[i], 0);
1044 g_signal_connect(G_OBJECT(combo),
"changed", G_CALLBACK(save_preferences), NULL);
1049 static GtkComboBox *create_text_preferences_combo()
1051 GtkComboBox *combo = ch_new_combo();
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);
1059 g_signal_connect(G_OBJECT(combo),
"changed", G_CALLBACK(save_preferences), NULL);
1064 void test_regex_event(GtkWidget *widget, gpointer data)
1066 put_tags_from_filename_regex_options();
1067 const gchar *test_regex_filename = gtk_entry_get_text(GTK_ENTRY(test_regex_fname_entry));
1070 gint error = SPLT_OK;
1071 splt_tags *tags = mp3splt_parse_filename_regex(the_state, &error);
1076 GString *regex_result = g_string_new(NULL);
1078 g_string_append(regex_result, _(
"<artist>: "));
1081 g_string_append(regex_result, tags->
artist);
1083 g_string_append(regex_result,
"\n");
1085 g_string_append(regex_result, _(
"<album>: "));
1088 g_string_append(regex_result, tags->
album);
1090 g_string_append(regex_result,
"\n");
1093 g_string_append(regex_result, _(
"<title>: "));
1096 g_string_append(regex_result, tags->
title);
1098 g_string_append(regex_result,
"\n");
1100 g_string_append(regex_result, _(
"<genre>: "));
1103 g_string_append(regex_result, tags->
genre);
1105 g_string_append(regex_result,
"\n");
1107 g_string_append(regex_result, _(
"<comment>: "));
1110 g_string_append(regex_result, tags->
comment);
1112 g_string_append(regex_result,
"\n");
1114 g_string_append(regex_result, _(
"<year>: "));
1117 g_string_append(regex_result, tags->
year);
1119 g_string_append(regex_result,
"\n");
1121 g_string_append(regex_result, _(
"<track>: "));
1122 if (tags->
track >= 0)
1124 g_string_append_printf(regex_result,
"%d", tags->
track);
1127 gchar *regex_result_text = g_string_free(regex_result, FALSE);
1128 if (regex_result_text)
1130 gtk_label_set_text(GTK_LABEL(sample_result_label), regex_result_text);
1131 g_free(regex_result_text);
1136 gtk_label_set_text(GTK_LABEL(sample_result_label),
"");
1139 mp3splt_free_one_tag(tags);
1142 static GtkWidget *create_extract_tags_from_filename_options_box()
1144 GtkWidget *table = wh_new_table();
1146 regex_entry = wh_new_entry(save_preferences);
1147 wh_add_in_table_with_label_expand(table, _(
"Regular expression:"), regex_entry);
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"
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));
1163 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_NO_CONVERSION));
1165 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_LOWERCASE));
1167 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_UPPERCASE));
1169 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_FIRST_UPPERCASE));
1171 g_list_append(text_options_list, GINT_TO_POINTER(SPLT_TO_WORD_FIRST_UPPERCASE));
1174 gtk_check_button_new_with_mnemonic(_(
"_Replace underscores by spaces"));
1176 G_CALLBACK(save_preferences), NULL);
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));
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));
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));
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));
1196 genre_combo = create_genre_combo();
1197 wh_add_in_table_with_label(table, _(
"Genre tag:"), GTK_WIDGET(genre_combo));
1199 comment_tag_entry = wh_new_entry(save_preferences);
1200 wh_add_in_table_with_label_expand(table, _(
"Comment tag:"), comment_tag_entry);
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);
1206 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1209 static GtkWidget *create_test_regex_table()
1211 GtkWidget *table = wh_new_table();
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);
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);
1222 wh_add_in_table_with_label_expand(table, _(
"Sample filename:"), sample_test_hbox);
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);
1228 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1234 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
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);
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);
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);
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);
1267 GtkWidget *outside_vbox = gtk_vbox_new(FALSE, 0);;
1268 GtkWidget *inside_hbox = gtk_hbox_new(FALSE, 0);
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);
1275 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);;
1276 gtk_box_pack_start(GTK_BOX(inside_hbox), vbox, TRUE, TRUE, 5);
1279 gtk_box_pack_start(GTK_BOX(vbox), tags_version_box, FALSE, FALSE, 2);
1282 gtk_box_pack_start(GTK_BOX(vbox), tags_opts_box, FALSE, FALSE, 1);
1284 return outside_vbox;
1291 GtkWidget *pref_vbox = gtk_vbox_new(FALSE, 0);
1293 GtkWidget *notebook = gtk_notebook_new();
1294 gtk_box_pack_start(GTK_BOX(pref_vbox), notebook, TRUE, TRUE, 0);
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);
1303 GtkWidget *notebook_label = gtk_label_new(_(
"Split"));
1304 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), splitpoints_prefs,
1305 (GtkWidget *)notebook_label);
1309 notebook_label = gtk_label_new(_(
"Tags"));
1310 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tags_prefs,
1311 (GtkWidget *)notebook_label);
1315 notebook_label = gtk_label_new(_(
"Output"));
1316 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), output_prefs,
1317 (GtkWidget *)notebook_label);
1321 notebook_label = gtk_label_new(_(
"Player"));
1322 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), player_prefs,
1323 (GtkWidget *)notebook_label);
1328 notebook_label = gtk_label_new(_(
"Language"));
1329 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), language_prefs,
1330 (GtkWidget *)notebook_label);