40#include "preferences_window.h"
42static GtkWidget *create_extract_tags_from_filename_options_box(
ui_state *ui);
43static GtkWidget *create_test_regex_table(
ui_state *ui);
44static void update_wave_preview_label_markup(gint index, gint interpolation_level,
ui_state *ui);
52 GSList *radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(ui->gui->radio_button));
55 GtkWidget *our_button = GTK_WIDGET(g_slist_nth_data(radio_button_list, 0));
56 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(our_button)))
58 return g_string_new(
"de_DE");
61 our_button = GTK_WIDGET(g_slist_nth_data(radio_button_list, 1));
62 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(our_button)))
64 return g_string_new(
"fr_FR");
67 return g_string_new(
"en");
73 GSList *radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(ui->gui->radio_output));
79 GtkToggleButton *test = (GtkToggleButton *)g_slist_nth_data(radio_button_list,i);
80 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(test)))
92 GSList *radio_button_list = gtk_radio_button_get_group(GTK_RADIO_BUTTON(gui->tags_version_radio));
101 GtkToggleButton *button = GTK_TOGGLE_BUTTON(g_slist_nth_data(radio_button_list,i));
102 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
111static void set_output_directory(gchar *dirname,
ui_state *ui)
118 lock_mutex(&ui->variables_mutex);
119 if (ui->infos->outputdirname != NULL)
121 g_string_free(ui->infos->outputdirname, TRUE);
123 ui->infos->outputdirname = g_string_new(dirname);
124 unlock_mutex(&ui->variables_mutex);
127static void change_output_dir_options(GtkToggleButton *button, gpointer data)
131 GtkWidget *dir_file_chooser_button = ui->gui->custom_dir_file_chooser_button;
132 if (!dir_file_chooser_button || !ui->gui->example_output_dir_box)
137 if (rh_get_active_value(ui->gui->output_dir_radio) == CUSTOM_DIRECTORY)
139 gchar *directory = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dir_file_chooser_button));
140 set_output_directory(directory, ui);
141 gtk_widget_set_sensitive(dir_file_chooser_button, SPLT_TRUE);
142 gtk_widget_set_sensitive(ui->gui->example_output_dir_box, SPLT_FALSE);
146 set_output_directory(
"", ui);
147 gtk_widget_set_sensitive(dir_file_chooser_button, SPLT_FALSE);
148 gtk_widget_set_sensitive(ui->gui->example_output_dir_box, SPLT_TRUE);
151 ui_save_preferences(NULL, ui);
154static void update_output_directory_in_gui(
ui_state *ui,
char *output_dir)
156 GtkWidget *custom_dir_file_chooser_button = ui->gui->custom_dir_file_chooser_button;
158 if (output_dir == NULL || output_dir[0] ==
'\0')
160 rh_set_radio_value(ui->gui->output_dir_radio, FILE_DIRECTORY, TRUE);
164 rh_set_radio_value(ui->gui->output_dir_radio, CUSTOM_DIRECTORY, TRUE);
165 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(custom_dir_file_chooser_button), output_dir);
168 change_output_dir_options(GTK_TOGGLE_BUTTON(ui->gui->output_dir_radio), ui);
171void set_output_directory_and_update_ui(gchar *dirname,
ui_state *ui)
178 set_output_directory(dirname, ui);
180 update_output_directory_in_gui(ui, dirname);
191 if (ui->infos->outputdirname != NULL)
193 return ui->infos->outputdirname->str;
200static void output_radio_box_event(GtkToggleButton *radio_b,
ui_state *ui)
205 gtk_widget_set_sensitive(ui->gui->output_entry, TRUE);
206 gtk_widget_set_sensitive(ui->gui->output_label, TRUE);
207 gtk_widget_set_sensitive(ui->gui->output_default_label, FALSE);
211 gtk_widget_set_sensitive(ui->gui->output_entry, FALSE);
212 gtk_widget_set_sensitive(ui->gui->output_label, FALSE);
213 gtk_widget_set_sensitive(ui->gui->output_default_label, TRUE);
216 ui_save_preferences(NULL, ui);
222static GtkWidget *create_language_box(
ui_state *ui)
224 GtkWidget *radio_vbox = wh_vbox_new();
226 GtkWidget *radio_button = gtk_radio_button_new_with_label(NULL,
"English");
227 ui->gui->radio_button = radio_button;
228 g_signal_connect(GTK_TOGGLE_BUTTON(radio_button),
"toggled",
229 G_CALLBACK(ui_save_preferences), ui);
230 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
232 radio_button = gtk_radio_button_new_with_label_from_widget
233 (GTK_RADIO_BUTTON(radio_button),
"Français");
234 ui->gui->radio_button = radio_button;
235 g_signal_connect(GTK_TOGGLE_BUTTON(radio_button),
"toggled",
236 G_CALLBACK(ui_save_preferences), ui);
237 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
239 radio_button = gtk_radio_button_new_with_label_from_widget
240 (GTK_RADIO_BUTTON(radio_button),
"Deutsch");
241 ui->gui->radio_button = radio_button;
242 g_signal_connect(GTK_TOGGLE_BUTTON (radio_button),
"toggled",
243 G_CALLBACK(ui_save_preferences), ui);
244 gtk_box_pack_start(GTK_BOX(radio_vbox), radio_button, TRUE, TRUE, 0);
247 _(
"<b>Choose language (requires restart)</b>"));
251static GtkWidget *create_pref_language_page(
ui_state *ui)
253 GtkWidget *language_hbox = wh_hbox_new();;
254 GtkWidget *language_inside_hbox = wh_hbox_new();;
257 wh_add_box_to_scrolled_window(language_inside_hbox, scrolled_window);
258 gtk_box_pack_start(GTK_BOX(language_hbox), scrolled_window, TRUE, TRUE, 0);
260 GtkWidget *vbox = wh_vbox_new();;
261 gtk_box_pack_start(GTK_BOX(language_inside_hbox), vbox, TRUE, TRUE, 10);
263 GtkWidget *lang_box = create_language_box(ui);
264 gtk_box_pack_start(GTK_BOX(vbox), lang_box, FALSE, FALSE, 10);
266 return language_hbox;
271static void disable_adjust_parameters(
gui_state *gui)
273 gtk_widget_set_sensitive(gui->adjust_param_vbox, FALSE);
277static void enable_adjust_parameters(
gui_state *gui)
279 gtk_widget_set_sensitive(gui->adjust_param_vbox, TRUE);
283static void adjust_event(GtkToggleButton *adjust_mode,
ui_state *ui)
285 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adjust_mode)))
287 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->gui->frame_mode),TRUE);
288 enable_adjust_parameters(ui->gui);
292 disable_adjust_parameters(ui->gui);
295 ui_save_preferences(NULL, ui);
299static void frame_event(GtkToggleButton *frame_mode,
ui_state *ui)
301 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(frame_mode)))
303 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->gui->adjust_mode), FALSE);
304 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->gui->bit_reservoir_mode), FALSE);
307 ui_save_preferences(NULL, ui);
310static void splitpoints_from_filename_event(GtkToggleButton *frame_mode,
ui_state *ui)
312 gint splitpoints_from_filename = gtk_toggle_button_get_active(ui->gui->names_from_filename);
313 if (splitpoints_from_filename == TRUE && ui->status->file_browsed == TRUE)
319 clear_current_description(ui);
322 ui_save_preferences(NULL, ui);
326static void set_default_prefs_event(GtkWidget *widget,
ui_state *ui)
330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui->frame_mode), FALSE);
331 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui->bit_reservoir_mode), FALSE);
332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui->adjust_mode), FALSE);
333 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui->spinner_adjust_threshold),
334 SPLT_DEFAULT_PARAM_THRESHOLD);
335 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui->spinner_adjust_offset),
336 SPLT_DEFAULT_PARAM_OFFSET);
337 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui->spinner_adjust_gap),
338 SPLT_DEFAULT_PARAM_GAP);
339 gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui->spinner_adjust_min),
340 SPLT_DEFAULT_PARAM_MINIMUM_LENGTH);
341 gtk_toggle_button_set_active(gui->names_from_filename, FALSE);
342 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui->create_dirs_from_output_files), TRUE);
344 ui_save_preferences(NULL, ui);
347static void custom_directory_changed(GtkFileChooser *custom_dir_file_chooser,
ui_state *ui)
349 gchar *filename = gtk_file_chooser_get_filename(custom_dir_file_chooser);
350 set_output_directory(filename, ui);
351 ui_save_preferences(NULL, ui);
354static GtkWidget *create_custom_directory_box(
ui_state *ui)
356 GtkWidget *custom_dir_file_chooser_button =
357 gtk_file_chooser_button_new(_(
"Browse directory ..."), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
358 wh_set_browser_directory_handler(ui, custom_dir_file_chooser_button);
360 g_signal_connect(G_OBJECT(custom_dir_file_chooser_button),
"selection-changed",
361 G_CALLBACK(custom_directory_changed), ui);
363 ui->gui->custom_dir_file_chooser_button = custom_dir_file_chooser_button;
365 GtkWidget *hbox = wh_hbox_new();
366 gtk_box_pack_start(GTK_BOX(hbox), custom_dir_file_chooser_button, TRUE, TRUE, 20);
371static GtkWidget *create_input_file_directory_example_box(
ui_state *ui)
373 GtkWidget *vbox = wh_vbox_new();
375 GtkWidget *example_output_dir_label = gtk_label_new(_(
"Example for the single file split:"));
376 GtkWidget *fake_hbox = wh_hbox_new();
377 gtk_box_pack_start(GTK_BOX(fake_hbox), example_output_dir_label, FALSE, FALSE, 0);
379 gtk_box_pack_start(GTK_BOX(vbox), fake_hbox, FALSE, FALSE, 0);
381 GtkWidget *example_output_dir_entry = gtk_entry_new();
382 gtk_editable_set_editable(GTK_EDITABLE(example_output_dir_entry), FALSE);
383 gtk_box_pack_start(GTK_BOX(vbox), example_output_dir_entry, TRUE, TRUE, 5);
384 ui->gui->example_output_dir_entry = example_output_dir_entry;
386 GtkWidget *hbox_for_margin = wh_hbox_new();
387 gtk_box_pack_start(GTK_BOX(hbox_for_margin), vbox, TRUE, TRUE, 20);
389 ui->gui->example_output_dir_box = hbox_for_margin;
391 return hbox_for_margin;
394void update_example_output_dir_for_single_file_split(
ui_state *ui)
396 if (!ui->gui->example_output_dir_entry)
402 gtk_entry_set_text(GTK_ENTRY(ui->gui->example_output_dir_entry), dirname);
407static GtkWidget *create_directory_box(
ui_state *ui)
411 GtkWidget *vbox = wh_vbox_new();
413 GtkWidget *output_dir_radio = NULL;
414 output_dir_radio = rh_append_radio_to_vbox(output_dir_radio, _(
"Custom directory"),
415 CUSTOM_DIRECTORY, change_output_dir_options, ui, vbox);
416 gtk_widget_set_tooltip_text(output_dir_radio, _(
"Create split files in a custom directory"));
418 GtkWidget *custom_dir_box = create_custom_directory_box(ui);
419 gtk_box_pack_start(GTK_BOX(vbox), custom_dir_box, FALSE, FALSE, 0);
421 output_dir_radio = rh_append_radio_to_vbox(output_dir_radio, _(
"Input file directory"),
422 FILE_DIRECTORY, change_output_dir_options, ui, vbox);
423 gtk_widget_set_tooltip_text(output_dir_radio,
424 _(
"Create split files in the same directory as the file being split"));
425 gui->output_dir_radio = output_dir_radio;
427 GtkWidget *input_file_directory_example_box = create_input_file_directory_example_box(ui);
428 gtk_box_pack_start(GTK_BOX(vbox), input_file_directory_example_box, FALSE, FALSE, 0);
433static void bit_reservoir_event(GtkToggleButton *bit_reservoir,
ui_state *ui)
435 gint with_bit_reservoir =
436 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui->gui->bit_reservoir_mode));
437 if (with_bit_reservoir == TRUE)
439 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->gui->frame_mode), TRUE);
442 ui_save_preferences(NULL, ui);
446static GtkWidget *create_split_options_box(
ui_state *ui)
450 GtkWidget *vbox = wh_vbox_new();
453 GtkToggleButton *names_from_filename =
454 GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(
455 _(
"_Splitpoint name from filename (manual single file split only)")));
456 gtk_widget_set_tooltip_text(GTK_WIDGET(names_from_filename),
457 _(
"Name newly added splitpoints as the input file"));
458 gui->names_from_filename = names_from_filename;
460 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(names_from_filename), FALSE, FALSE, 0);
461 g_signal_connect(G_OBJECT(names_from_filename),
"toggled",
462 G_CALLBACK(splitpoints_from_filename_event), ui);
464 GtkWidget *create_dirs_from_output_files =
465 gtk_check_button_new_with_mnemonic(_(
"Create directories from _filenames "));
467 gtk_widget_set_tooltip_text(create_dirs_from_output_files,
468 _(
"If the splitpoint name is 'a/b/output', the directory chain 'a/b' is created in the"
469 " output\ndirectory and the file 'output.<extension>' is written in the"
470 " '<output_directory>/a/b' directory"));
471 gui->create_dirs_from_output_files = create_dirs_from_output_files;
472 gtk_box_pack_start(GTK_BOX(vbox), create_dirs_from_output_files, FALSE, FALSE, 0);
473 g_signal_connect(G_OBJECT(create_dirs_from_output_files),
"toggled",
474 G_CALLBACK(ui_save_preferences), ui);
477 GtkWidget *frame_mode =
478 gtk_check_button_new_with_mnemonic(_(
"F_rame mode (useful for mp3 VBR) (mp3 only)"));
479 gtk_widget_set_tooltip_text(frame_mode,
480 _(
"The split is slower with this option, but some mp3 files having\n"
481 "Variable Bit Rate need this mode to be enabled"));
482 gui->frame_mode = frame_mode;
483 gtk_box_pack_start(GTK_BOX(vbox), frame_mode, FALSE, FALSE, 0);
484 g_signal_connect(G_OBJECT(frame_mode),
"toggled", G_CALLBACK(frame_event), ui);
487 GtkWidget *bit_reservoir_mode =
488 gtk_check_button_new_with_mnemonic(_(
"_[Experimental] Bit reservoir handling for gapless playback (mp3 only)"));
489 gtk_widget_set_tooltip_text(bit_reservoir_mode,
490 _(
"Split files will play gapless only on players "
491 "supporting the LAME tag delay and padding values\n"
492 "Gapless players examples: cmus, mpg123, foobar2000"));
493 gui->bit_reservoir_mode = bit_reservoir_mode;
494 gtk_box_pack_start(GTK_BOX(vbox), bit_reservoir_mode, FALSE, FALSE, 0);
495 g_signal_connect(G_OBJECT(bit_reservoir_mode),
"toggled", G_CALLBACK(bit_reservoir_event), ui);
498 GtkWidget *adjust_mode = gtk_check_button_new_with_mnemonic(_(
"_Auto-adjust mode (use"
499 " silence detection to auto-adjust splitpoints)"));
500 gtk_widget_set_tooltip_text(adjust_mode,
501 _(
"Splitpoints will be adjusted to match silences (if found)\n"
502 "This mode requires the frame mode"));
503 gui->adjust_mode = adjust_mode;
504 gtk_box_pack_start(GTK_BOX(vbox), adjust_mode, FALSE, FALSE, 0);
505 g_signal_connect(G_OBJECT(adjust_mode),
"toggled", G_CALLBACK(adjust_event), ui);
508 GtkWidget *horiz_fake = wh_hbox_new();
509 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
511 GtkWidget *param_vbox = wh_vbox_new();
512 gui->adjust_param_vbox = param_vbox;
513 gtk_box_pack_start(GTK_BOX(horiz_fake), param_vbox, FALSE, FALSE, 25);
516 horiz_fake = wh_hbox_new();
517 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
519 GtkWidget *threshold_label = gtk_label_new(_(
"Threshold level (dB):"));
520 gtk_box_pack_start(GTK_BOX(horiz_fake), threshold_label, FALSE, FALSE, 0);
523 (GtkAdjustment *) gtk_adjustment_new(0.0, -96.0, 0.0, 0.5, 10.0, 0.0);
524 GtkWidget *spinner_adjust_threshold = gtk_spin_button_new (adj, 0.5, 2);
525 gui->spinner_adjust_threshold = spinner_adjust_threshold;
526 g_signal_connect(G_OBJECT(spinner_adjust_threshold),
"value_changed",
527 G_CALLBACK(ui_save_preferences), ui);
528 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_threshold,
532 horiz_fake = wh_hbox_new();
533 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
535 GtkWidget *min_label = gtk_label_new(_(
"Minimum silence length (seconds):"));
536 gtk_box_pack_start(GTK_BOX(horiz_fake), min_label, FALSE, FALSE, 0);
538 adj = (GtkAdjustment *)gtk_adjustment_new(0.0, 0, 2000, 0.5, 10.0, 0.0);
539 GtkWidget *spinner_adjust_min = gtk_spin_button_new(adj, 1, 2);
540 gui->spinner_adjust_min = spinner_adjust_min;
541 g_signal_connect(G_OBJECT(spinner_adjust_min),
"value_changed",
542 G_CALLBACK(ui_save_preferences), ui);
543 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_min,
547 horiz_fake = wh_hbox_new();
548 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
550 GtkWidget *offset_label = gtk_label_new(_(
"Cutpoint offset (0 is the begin of silence "
552 gtk_box_pack_start(GTK_BOX(horiz_fake), offset_label, FALSE, FALSE, 0);
555 adj = (GtkAdjustment *)gtk_adjustment_new(0.0, -2, 2, 0.05, 10.0, 0.0);
556 GtkWidget *spinner_adjust_offset = gtk_spin_button_new (adj, 0.05, 2);
557 gui->spinner_adjust_offset = spinner_adjust_offset;
558 g_signal_connect(G_OBJECT(spinner_adjust_offset),
"value_changed",
559 G_CALLBACK(ui_save_preferences), ui);
560 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_offset, FALSE, FALSE, 6);
563 horiz_fake = wh_hbox_new();
564 gtk_box_pack_start(GTK_BOX(param_vbox), horiz_fake, FALSE, FALSE, 0);
566 GtkWidget *gap_label =
567 gtk_label_new(_(
"Gap level (seconds around splitpoint to search for silence):"));
568 gtk_box_pack_start(GTK_BOX(horiz_fake), gap_label, FALSE, FALSE, 0);
570 adj = (GtkAdjustment *) gtk_adjustment_new(0.0, 0, 2000, 1.0, 10.0, 0.0);
571 GtkWidget *spinner_adjust_gap = gtk_spin_button_new (adj, 1, 0);
572 gui->spinner_adjust_gap = spinner_adjust_gap;
573 g_signal_connect(G_OBJECT(spinner_adjust_gap),
"value_changed",
574 G_CALLBACK(ui_save_preferences), ui);
575 gtk_box_pack_start(GTK_BOX(horiz_fake), spinner_adjust_gap, FALSE, FALSE, 6);
577 disable_adjust_parameters(ui->gui);
580 horiz_fake = wh_hbox_new();
581 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
583 GtkWidget *set_default_prefs_button =
584 wh_create_cool_button(
"document-properties", _(
"Set _default split options"),FALSE);
585 g_signal_connect(G_OBJECT(set_default_prefs_button),
"clicked",
586 G_CALLBACK(set_default_prefs_event), ui);
587 gtk_box_pack_start (GTK_BOX (horiz_fake), set_default_prefs_button, FALSE, FALSE, 5);
593static GtkWidget *create_pref_splitpoints_page(
ui_state *ui)
595 GtkWidget *general_hbox = wh_hbox_new();
596 GtkWidget *inside_hbox = wh_hbox_new();
599 wh_add_box_to_scrolled_window(inside_hbox, scrolled_window);
600 gtk_box_pack_start(GTK_BOX(general_hbox), scrolled_window, TRUE, TRUE, 0);
602 GtkWidget *inside_vbox = wh_vbox_new();
603 gtk_box_pack_start(GTK_BOX(inside_hbox), inside_vbox, TRUE, TRUE, 5);
605 GtkWidget *dir_box = create_directory_box(ui);
606 gtk_box_pack_start(GTK_BOX(inside_vbox), dir_box, FALSE, FALSE, 2);
608 GtkWidget *split_options_box = create_split_options_box(ui);
609 gtk_box_pack_start(GTK_BOX(inside_vbox), split_options_box, FALSE, FALSE, 1);
615static void player_combo_box_event(GtkComboBox *widget,
ui_state *ui)
619 ui->infos->selected_player = ch_get_active_value(widget);
620 if (ui->infos->selected_player == PLAYER_GSTREAMER)
623 gtk_widget_show(ui->gui->playlist_box);
624 gtk_widget_set_sensitive(ui->gui->gstreamer_stop_before_end_box, TRUE);
629 gtk_widget_hide(ui->gui->playlist_box);
630 gtk_widget_set_sensitive(ui->gui->gstreamer_stop_before_end_box, FALSE);
633 gtk_widget_show(ui->gui->player_box);
634 gtk_widget_show(ui->gui->queue_files_button);
636 ui_save_preferences(NULL, ui);
639static void update_timeout_value(GtkWidget *spinner,
ui_state *ui)
641 ui->infos->timeout_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
643 restart_player_timer(ui);
644 ui_save_preferences(NULL, ui);
647static void update_gstreamer_stop_before_end_value(GtkWidget *spinner,
ui_state *ui)
649 ui->infos->gstreamer_stop_before_end = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
650 ui_save_preferences(NULL, ui);
653static void update_small_seek_jump_value(GtkWidget *spinner,
ui_state *ui)
655 ui->infos->small_seek_jump_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
656 ui_save_preferences(NULL, ui);
659static void update_seek_jump_value(GtkWidget *spinner,
ui_state *ui)
661 ui->infos->seek_jump_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
662 ui_save_preferences(NULL, ui);
665static void update_big_seek_jump_value(GtkWidget *spinner,
ui_state *ui)
667 ui->infos->big_seek_jump_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner));
668 ui_save_preferences(NULL, ui);
672static GtkWidget *create_player_options_box(
ui_state *ui)
674 GtkWidget *vbox = wh_vbox_new();
675 GtkWidget *horiz_fake = wh_hbox_new();
677 GtkWidget *label = gtk_label_new(_(
"Player:"));
678 gtk_box_pack_start(GTK_BOX(horiz_fake), label, FALSE, FALSE, 0);
680 GtkWidget *player_combo_box = GTK_WIDGET(ch_new_combo());
681 ui->gui->player_combo_box = player_combo_box;
684 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box),
"Audacious", PLAYER_AUDACIOUS);
686 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box),
"SnackAmp", PLAYER_SNACKAMP);
688 ch_append_to_combo(GTK_COMBO_BOX(player_combo_box),
"GStreamer", PLAYER_GSTREAMER);
691 g_signal_connect(G_OBJECT(player_combo_box),
"changed", G_CALLBACK(player_combo_box_event), ui);
693 gtk_box_pack_start(GTK_BOX(horiz_fake), player_combo_box, FALSE, FALSE, 5);
694 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
696 GtkWidget *spinner = wh_create_int_spinner_in_box(_(
"Refresh player every "),
698 (gdouble)DEFAULT_TIMEOUT_VALUE, 20.0, 1000.0, 10.0, 100.0,
699 _(
"\t(higher refresh rate decreases CPU usage - default is 200)"),
700 update_timeout_value, ui, vbox);
701 ui_register_spinner_int_preference(
"player",
"refresh_rate", DEFAULT_TIMEOUT_VALUE,
702 spinner, (
void (*)(GtkWidget *, gpointer)) update_timeout_value,
705 GtkWidget *gstreamer_vbox = wh_vbox_new();
706 ui->gui->gstreamer_stop_before_end_box = gstreamer_vbox;
709 GtkWidget *gstreamer_stop_before_end =
710 wh_create_int_spinner_in_box(_(
"Stop GStreamer preview"), _(
"milliseconds before the end."),
711 (gdouble)DEFAULT_GSTREAMER_STOP_BEFORE_END_VALUE, 0.0, 1000.0, 50.0, 100.0,
712 NULL, update_gstreamer_stop_before_end_value, ui, gstreamer_vbox);
713 ui_register_spinner_int_preference(
"player",
"gstreamer_stop_before_end",
714 DEFAULT_GSTREAMER_STOP_BEFORE_END_VALUE, gstreamer_stop_before_end,
715 (
void (*)(GtkWidget *, gpointer)) update_gstreamer_stop_before_end_value, ui, ui);
717 gtk_box_pack_start(GTK_BOX(vbox), gstreamer_vbox, TRUE, TRUE, 0);
722 GtkWidget *seek_vbox = wh_vbox_new();
724 GtkWidget *small_seek_jump = wh_create_int_spinner_in_box(_(
"Small seek jumps for "),
726 (gdouble)DEFAULT_SMALL_SEEK_JUMP_VALUE, 0.0, (gdouble)G_MAXINT, 100.0, 1000.0,
728 update_small_seek_jump_value, ui, seek_vbox);
729 ui_register_spinner_int_preference(
"player",
"small_seek_jump", DEFAULT_SMALL_SEEK_JUMP_VALUE,
730 small_seek_jump, (
void (*)(GtkWidget *, gpointer)) update_small_seek_jump_value,
733 GtkWidget *seek_jump = wh_create_int_spinner_in_box(_(
"Seek jumps for "),
734 _(
"milliseconds. (0=auto)"),
735 (gdouble)DEFAULT_SEEK_JUMP_VALUE, 0.0, (gdouble)G_MAXINT, 1000.0, 10000.0,
737 update_seek_jump_value, ui, seek_vbox);
738 ui_register_spinner_int_preference(
"player",
"seek_jump", DEFAULT_SEEK_JUMP_VALUE,
739 seek_jump, (
void (*)(GtkWidget *, gpointer)) update_seek_jump_value,
742 GtkWidget *big_seek_jump = wh_create_int_spinner_in_box(_(
"Big seek jumps for "),
743 _(
"milliseconds. (0=auto)"),
744 (gdouble)DEFAULT_BIG_SEEK_JUMP_VALUE, 0.0, (gdouble)G_MAXINT, 1000.0, 60000.0,
746 update_big_seek_jump_value, ui, seek_vbox);
747 ui_register_spinner_int_preference(
"player",
"big_seek_jump", DEFAULT_BIG_SEEK_JUMP_VALUE,
748 big_seek_jump, (
void (*)(GtkWidget *, gpointer)) update_big_seek_jump_value,
751 GtkWidget *hbox_for_margin = wh_put_in_new_hbox(seek_vbox, 3, FALSE, FALSE);
753 GtkWidget *seek_times_frame = gtk_frame_new(_(
"Seek times"));
754 gtk_container_add(GTK_CONTAINER(seek_times_frame), hbox_for_margin);
756 horiz_fake = wh_hbox_new();
757 gtk_box_pack_start(GTK_BOX(horiz_fake), seek_times_frame, FALSE, FALSE, 0);
759 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 0);
764static void wave_quality_changed_event(GtkAdjustment *wave_quality_adjustment,
ui_state *ui)
766 gint quality_level = (gint)gtk_adjustment_get_value(GTK_ADJUSTMENT(wave_quality_adjustment));
769 for (level = 0; level <= 5; level++)
771 gdouble default_value = ui->infos->douglas_peucker_thresholds_defaults[level];
772 gdouble final_value = default_value - quality_level;
773 if (final_value <= 0)
778 ui->infos->douglas_peucker_thresholds[level] = final_value;
781 gint default_number_of_points_th = DEFAULT_SILENCE_WAVE_NUMBER_OF_POINTS_THRESHOLD;
782 gint number_of_points_th = default_number_of_points_th + (quality_level * 1000);
783 if (number_of_points_th <= 0)
785 number_of_points_th = 0;
788 ui->infos->silence_wave_number_of_points_threshold = number_of_points_th;
790 compute_douglas_peucker_filters(ui);
791 refresh_preview_drawing_areas(ui->gui);
793 ui_save_preferences(NULL, ui);
796void refresh_preview_drawing_areas(
gui_state *gui)
799 for (i = 0; i < gui->wave_quality_das->len; i++)
801 gtk_widget_queue_draw(g_ptr_array_index(gui->wave_quality_das, i));
804 gtk_widget_queue_draw(gui->player_scrolled_window);
807static gint get_wave_preview_width_drawing_area(
ui_state *ui)
809 if (ui->infos->width_drawing_area < 50)
814 return ui->infos->width_drawing_area;
817static gboolean wave_quality_draw_event(GtkWidget *drawing_area, cairo_t *cairo_surface,
821 gint index = data->index;
823 gint width = get_wave_preview_width_drawing_area(ui);
824 gtk_widget_set_size_request(drawing_area, width, 70);
826 gint expected_drawing_time_int = g_array_index(ui->infos->preview_time_windows, gint, index);
827 gfloat expected_drawing_time = (gfloat)(expected_drawing_time_int);
829 dh_set_white_color(cairo_surface);
831 dh_draw_rectangle(cairo_surface, TRUE, 0, 0, width, 70);
832 gfloat current_time = ui->infos->total_time / 2.0;
834 gfloat drawing_time = 0;
835 gfloat zoom_coeff = 0.2;
837 gfloat left_time = 0;
838 gfloat right_time = 0;
839 while ((((gint)drawing_time) == 0) || (drawing_time > expected_drawing_time))
843 drawing_time = right_time - left_time;
846 if (zoom_coeff > 100) {
break; }
849 ui->infos->drawing_preferences_silence_wave = SPLT_TRUE;
851 gint interpolation_level =
draw_silence_wave((gint)left_time, (gint)right_time, width / 2, 50,
852 drawing_time, width, 0,
853 current_time, ui->infos->total_time, zoom_coeff,
854 drawing_area, cairo_surface, ui);
856 ui->infos->drawing_preferences_silence_wave = SPLT_FALSE;
858 update_wave_preview_label_markup(index, interpolation_level, ui);
863static GtkWidget *create_wave_quality_preview_box(
ui_state *ui)
865 GtkWidget *vbox = wh_vbox_new();
867 GtkWidget *label_hbox = wh_hbox_new();
868 GtkWidget *wave_preview_label = gtk_label_new(NULL);
870 gchar wave_availability[256] = {
'\0' };
871 g_snprintf(wave_availability, 256,
"<span style='italic' color='#0000AA'>%s</span>",
872 _(
"Only available if the amplitude wave is shown in the player"));
873 gtk_label_set_markup(GTK_LABEL(wave_preview_label), wave_availability);
874 gtk_box_pack_start(GTK_BOX(label_hbox), wave_preview_label, FALSE, FALSE, 0);
875 gtk_box_pack_start(GTK_BOX(vbox), label_hbox, FALSE, FALSE, 4);
877 ui->gui->wave_quality_das = g_ptr_array_new();
878 ui->gui->wave_preview_labels = g_ptr_array_new();
881 for (i = 0; i < ui->infos->preview_time_windows->len; i++)
883 GtkWidget *wave_quality_da = gtk_drawing_area_new();
884 g_ptr_array_add(ui->gui->wave_quality_das, (gpointer)wave_quality_da);
885 ui->infos->preview_indexes[i].index = i;
886 ui->infos->preview_indexes[i].data = ui;
888 g_signal_connect(wave_quality_da,
"draw", G_CALLBACK(wave_quality_draw_event),
889 &ui->infos->preview_indexes[i]);
891 wh_put_in_hbox_and_attach_to_vbox(wave_quality_da, vbox, 0);
893 GtkWidget *minutes_label = gtk_label_new(NULL);
894 g_ptr_array_add(ui->gui->wave_preview_labels, minutes_label);
895 update_wave_preview_label_markup(i, -1, ui);
897 wh_put_in_hbox_and_attach_to_vbox_with_bottom_margin(minutes_label, vbox, 0, 4);
900 GtkWidget *hbox_for_margin = wh_put_in_new_hbox(vbox, 6, FALSE, FALSE);
902 GtkWidget *wave_preview_frame = gtk_frame_new(_(
"Wave preview"));
903 gtk_container_add(GTK_CONTAINER(wave_preview_frame), hbox_for_margin);
904 return wh_put_in_new_hbox(wave_preview_frame, 0, FALSE, FALSE);
907static void update_wave_preview_label_markup(gint index, gint interpolation_level,
ui_state *ui)
909 gint time_window = g_array_index(ui->infos->preview_time_windows, gint, index);
911 gchar minutes_text[128] = {
'\0' };
912 g_snprintf(minutes_text, 128, _(
"%d minute(s) window"), time_window / 100 / 60);
914 gchar interpolation_text[256] = {
'\0' };
915 if (interpolation_level >= 0)
917 g_snprintf(interpolation_text, 256, _(
"Wave interpolation level %d with threshold of %.1lf"),
918 interpolation_level + 1, ui->infos->douglas_peucker_thresholds[interpolation_level]);
921 g_snprintf(interpolation_text, 256, _(
"No wave interpolation"));
924 gchar final_text_with_color[512] = {
'\0' };
925 g_snprintf(final_text_with_color, 512,
926 "<span color='#DD0000'>%s</span> - <span>%s</span>",
927 minutes_text, interpolation_text);
929 GtkWidget *text_label = g_ptr_array_index(ui->gui->wave_preview_labels, index);
930 gtk_label_set_markup(GTK_LABEL(text_label), final_text_with_color);
933static GtkWidget *create_wave_options_box(
ui_state *ui)
935 GtkWidget *vbox = wh_vbox_new();
936 GtkWidget *range_hbox = wh_hbox_new();
938 GtkWidget *wave_quality_label =
939 gtk_label_new(_(
"Wave quality (higher is better but consumes more CPU):"));
940 gtk_box_pack_start(GTK_BOX(range_hbox), wave_quality_label, FALSE, FALSE, 0);
942 GtkWidget *wave_quality_hscale = wh_hscale_new_with_range(-6.0, 6.0, 1.0);
943 gtk_scale_set_draw_value(GTK_SCALE(wave_quality_hscale), TRUE);
944 gtk_box_pack_start(GTK_BOX(range_hbox), wave_quality_hscale, FALSE, FALSE, 4);
945 gtk_widget_set_size_request(wave_quality_hscale, 160, 0);
947 gtk_range_set_increments(GTK_RANGE(wave_quality_hscale), 1.0, 1.0);
949 ui_register_range_preference(
"player",
"wave_quality", 0.0,
950 wave_quality_hscale, (
void (*)(GtkAdjustment *,gpointer))wave_quality_changed_event, ui, ui);
952 GtkAdjustment *wave_quality_adjustment = gtk_range_get_adjustment(GTK_RANGE(wave_quality_hscale));
953 g_signal_connect(G_OBJECT(wave_quality_adjustment),
"value-changed",
954 G_CALLBACK(wave_quality_changed_event), ui);
956 gtk_box_pack_start(GTK_BOX(vbox), range_hbox, FALSE, FALSE, 0);
958 GtkWidget *wave_quality_box = create_wave_quality_preview_box(ui);
959 gtk_box_pack_start(GTK_BOX(vbox), wave_quality_box, FALSE, FALSE, 0);
965static GtkWidget *create_pref_player_page(
ui_state *ui)
967 GtkWidget *player_hbox = wh_hbox_new();;
968 GtkWidget *inside_hbox = wh_hbox_new();;
970 GtkWidget *inside_vbox = wh_vbox_new();;
971 gtk_box_pack_start(GTK_BOX(inside_hbox), inside_vbox, TRUE, TRUE, 5);
974 ui->gui->player_scrolled_window = player_scrolled_window;
975 wh_add_box_to_scrolled_window(inside_hbox, player_scrolled_window);
976 gtk_box_pack_start(GTK_BOX(player_hbox), player_scrolled_window, TRUE, TRUE, 0);
978 GtkWidget *vbox = wh_vbox_new();;
979 gtk_box_pack_start(GTK_BOX(inside_vbox), vbox, TRUE, TRUE, 0);
981 GtkWidget *player_options_box = create_player_options_box(ui);
982 gtk_box_pack_start(GTK_BOX(vbox), player_options_box, FALSE, FALSE, 3);
984 GtkWidget *wave_options_box = create_wave_options_box(ui);
985 gtk_box_pack_start(GTK_BOX(vbox), wave_options_box, FALSE, FALSE, 3);
990static gboolean check_output_format_end(
ui_with_err *ui_err)
995 print_status_bar_confirmation_in_idle(ui_err->err, ui);
997 set_process_in_progress_and_wait_safe(FALSE, ui_err->ui);
1004static gpointer check_output_format_thread(
ui_with_fname *ui_fname)
1008 set_process_in_progress_and_wait_safe(TRUE, ui);
1010 gint error = mp3splt_set_oformat(ui->mp3splt_state, ui_fname->fname);
1013 ui_err->err = error;
1016 add_idle(G_PRIORITY_HIGH_IDLE, (GSourceFunc)check_output_format_end, ui_err, NULL);
1018 g_free(ui_fname->fname);
1025static gboolean output_entry_event(GtkWidget *widget, GdkEventKey *event,
ui_state *ui)
1027 const char *data = gtk_entry_get_text(GTK_ENTRY(ui->gui->output_entry));
1032 ui_fname->fname = strdup(data);
1034 create_thread_and_unref((GThreadFunc)check_output_format_thread,
1035 (gpointer) ui_fname, ui,
"check_output_format");
1038 ui_save_preferences(NULL, ui);
1044static GtkWidget *create_output_filename_box(
ui_state *ui)
1048 GtkWidget *vbox = wh_vbox_new();
1050 GtkWidget *horiz_fake = wh_hbox_new();
1051 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
1054 GtkWidget *radio_output = gtk_radio_button_new_with_label(NULL, _(
"Default format"));
1055 gui->radio_output = radio_output;
1056 gtk_box_pack_start(GTK_BOX(vbox), radio_output, FALSE, FALSE, 0);
1058 horiz_fake = wh_hbox_new();
1059 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
1061 GString *outputs_str = g_string_new(_(
" Default output: "));
1062 g_string_append(outputs_str,
"<span color='#222288'>");
1063 g_string_append(outputs_str, SPLT_DEFAULT_OUTPUT);
1064 g_string_append(outputs_str,
"</span>");
1066 g_string_append(outputs_str,
"\n");
1067 g_string_append(outputs_str, _(
" CDDB, CUE and tracktype.org default: "));
1068 g_string_append(outputs_str,
"<span color='#222288'>");
1069 g_string_append(outputs_str, SPLT_DEFAULT_CDDB_CUE_OUTPUT);
1070 g_string_append(outputs_str,
"</span>");
1072 g_string_append(outputs_str,
"\n");
1073 g_string_append(outputs_str, _(
" Split with silence detection default: "));
1074 g_string_append(outputs_str,
"<span color='#222288'>");
1075 g_string_append(outputs_str, SPLT_DEFAULT_SILENCE_OUTPUT);
1076 g_string_append(outputs_str,
"</span>");
1078 g_string_append(outputs_str,
"\n");
1079 g_string_append(outputs_str, _(
" Trim using silence detection default: "));
1080 g_string_append(outputs_str,
"<span color='#222288'>");
1081 g_string_append(outputs_str, SPLT_DEFAULT_TRIM_SILENCE_OUTPUT);
1082 g_string_append(outputs_str,
"</span>");
1084 g_string_append(outputs_str,
"\n");
1085 g_string_append(outputs_str, _(
" Error mode default: "));
1086 g_string_append(outputs_str,
"<span color='#222288'>");
1087 g_string_append(outputs_str, SPLT_DEFAULT_SYNCERROR_OUTPUT);
1088 g_string_append(outputs_str,
"</span>");
1090 GtkWidget *default_label = gtk_label_new(NULL);
1091 gui->output_default_label = default_label;
1092 gtk_label_set_markup(GTK_LABEL(default_label), outputs_str->str);
1093 gtk_label_set_selectable(GTK_LABEL(default_label), TRUE);
1094 gtk_box_pack_start(GTK_BOX(horiz_fake), default_label, FALSE, FALSE, 0);
1096 g_string_free(outputs_str, TRUE);
1099 radio_output = gtk_radio_button_new_with_label_from_widget
1100 (GTK_RADIO_BUTTON(radio_output), _(
"Custom format"));
1101 gui->radio_output = radio_output;
1102 gtk_box_pack_start(GTK_BOX(vbox), radio_output, FALSE, FALSE, 0);
1105 horiz_fake = wh_hbox_new();
1106 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
1108 GtkWidget *output_entry = gtk_entry_new();
1109 gui->output_entry = output_entry;
1110 gtk_editable_set_editable(GTK_EDITABLE(output_entry), TRUE);
1111 g_signal_connect(G_OBJECT(output_entry),
"key_release_event", G_CALLBACK(output_entry_event), ui);
1112 gtk_entry_set_max_length(GTK_ENTRY(output_entry),244);
1113 gtk_box_pack_start(GTK_BOX(horiz_fake), output_entry, TRUE, TRUE, 0);
1116 horiz_fake = wh_hbox_new();
1117 gtk_box_pack_start(GTK_BOX(vbox), horiz_fake, FALSE, FALSE, 5);
1118 GtkWidget *output_label = gtk_label_new(_(
1119 " @A: performer if found, otherwise artist\n"
1120 " @a: artist name\n"
1121 " @p: performer of each song (only with .cue)\n"
1122 " @b: album title\n"
1125 " @n: track number identifier (not the real ID3 track number) **\n"
1126 " @N: track tag number **\n"
1127 " @l: track number identifier as lowercase letter (not the real ID3 track number) **\n"
1128 " @L: track tag number as lowercase letter **\n"
1129 " @u: track number identifier as uppercase letter (not the real ID3 track number) **\n"
1130 " @U: track tag number as uppercase letter **\n"
1131 " @f: input filename (without extension)\n"
1132 " @d: last directory of the input filename or the filename itself if no directory\n"
1133 " @m, @s or @h: the number of minutes, seconds or hundreths of seconds of the start splitpoint **\n"
1134 " @M, @S or @H: the number of minutes, seconds or hundreths of seconds of the end splitpoint **\n"
1136 " (**) a digit may follow for the number of digits to output\n"));
1137 gtk_label_set_selectable(GTK_LABEL(output_label), TRUE);
1138 gui->output_label = output_label;
1139 gtk_box_pack_start(GTK_BOX(horiz_fake), output_label, FALSE, FALSE, 0);
1141 g_signal_connect(GTK_TOGGLE_BUTTON(gui->radio_output),
1142 "toggled", G_CALLBACK(output_radio_box_event), ui);
1145 _(
"<b>Output format for batch split and when importing splitpoints</b>"));
1149static GtkWidget *create_pref_output_page(
ui_state *ui)
1151 GtkWidget *output_hbox = wh_hbox_new();;
1152 GtkWidget *output_inside_hbox = wh_hbox_new();;
1155 wh_add_box_to_scrolled_window(output_inside_hbox, scrolled_window);
1156 gtk_box_pack_start(GTK_BOX(output_hbox), scrolled_window, TRUE, TRUE, 0);
1158 GtkWidget *vbox = wh_vbox_new();;
1159 gtk_box_pack_start(GTK_BOX(output_inside_hbox), vbox, TRUE, TRUE, 5);
1161 GtkWidget *output_fname_box = create_output_filename_box(ui);
1162 gtk_box_pack_start(GTK_BOX(vbox), output_fname_box, FALSE, FALSE, 2);
1167static void change_tags_options(GtkToggleButton *button, gpointer data)
1171 if (ui->gui->extract_tags_box != NULL)
1173 if (rh_get_active_value(ui->gui->tags_radio) == TAGS_FROM_FILENAME)
1175 gtk_widget_set_sensitive(ui->gui->extract_tags_box, SPLT_TRUE);
1179 gtk_widget_set_sensitive(ui->gui->extract_tags_box, SPLT_FALSE);
1183 ui_save_preferences(NULL, ui);
1187static GtkWidget *create_tags_options_box(
ui_state *ui)
1191 GtkWidget *vbox = wh_vbox_new();
1193 GtkWidget *tags_radio = NULL;
1194 tags_radio = rh_append_radio_to_vbox(tags_radio, _(
"Original file tags"),
1195 ORIGINAL_FILE_TAGS, change_tags_options, ui, vbox);
1196 gui->tags_radio = tags_radio;
1197 tags_radio = rh_append_radio_to_vbox(tags_radio, _(
"Custom tags (from the splitpoints table)"),
1198 DEFAULT_TAGS, change_tags_options, ui, vbox);
1199 gui->tags_radio = tags_radio;
1200 tags_radio = rh_append_radio_to_vbox(tags_radio, _(
"No tags"),
1201 NO_TAGS, change_tags_options, ui, vbox);
1202 gui->tags_radio = tags_radio;
1203 tags_radio = rh_append_radio_to_vbox(tags_radio, _(
"Extract tags from filename"),
1204 TAGS_FROM_FILENAME, change_tags_options, ui, vbox);
1205 gui->tags_radio = tags_radio;
1207 GtkWidget *extract_tags_box = create_extract_tags_from_filename_options_box(ui);
1208 gui->extract_tags_box = extract_tags_box;
1209 gtk_widget_set_sensitive(extract_tags_box, SPLT_FALSE);
1210 gtk_box_pack_start(GTK_BOX(vbox), extract_tags_box, FALSE, FALSE, 2);
1215static GtkComboBox *create_genre_combo(
ui_state *ui)
1217 GtkComboBox *combo = ch_new_combo();
1220 for (i = 0;i < SPLT_ID3V1_NUMBER_OF_GENRES;i++)
1222 ch_append_to_combo(combo, splt_id3v1_genres[i], 0);
1225 g_signal_connect(G_OBJECT(combo),
"changed", G_CALLBACK(ui_save_preferences), ui);
1230static GtkComboBox *create_text_preferences_combo(
ui_state *ui)
1232 GtkComboBox *combo = ch_new_combo();
1234 ch_append_to_combo(combo, _(
"No change"), SPLT_NO_CONVERSION);
1235 ch_append_to_combo(combo, _(
"lowercase"), SPLT_TO_LOWERCASE);
1236 ch_append_to_combo(combo, _(
"UPPERCASE"), SPLT_TO_UPPERCASE);
1237 ch_append_to_combo(combo, _(
"First uppercase"), SPLT_TO_FIRST_UPPERCASE);
1238 ch_append_to_combo(combo, _(
"Word Uppercase"), SPLT_TO_WORD_FIRST_UPPERCASE);
1240 g_signal_connect(G_OBJECT(combo),
"changed", G_CALLBACK(ui_save_preferences), ui);
1249 if (ui_fname->fname)
1251 gtk_label_set_text(GTK_LABEL(ui->gui->sample_result_label), ui_fname->fname);
1252 g_free(ui_fname->fname);
1256 gtk_label_set_text(GTK_LABEL(ui->gui->sample_result_label),
"");
1261 set_process_in_progress_and_wait_safe(FALSE, ui);
1270 set_process_in_progress_and_wait_safe(TRUE, ui);
1272 put_tags_from_filename_regex_options(ui_fs);
1274 mp3splt_set_filename_to_split(ui->mp3splt_state, ui_fs->test_regex_filename);
1276 gint error = SPLT_OK;
1277 splt_tags *tags = mp3splt_parse_filename_regex(ui->mp3splt_state, &error);
1278 print_status_bar_confirmation_in_idle(error, ui);
1280 if (error < 0) {
goto end; }
1282 GString *regex_result = g_string_new(NULL);
1284 g_string_append(regex_result, _(
"<artist>: "));
1285 char *artist = mp3splt_tags_get(tags, SPLT_TAGS_ARTIST);
1288 g_string_append(regex_result, artist);
1291 g_string_append(regex_result,
"\n");
1293 g_string_append(regex_result, _(
"<album>: "));
1294 char *album = mp3splt_tags_get(tags, SPLT_TAGS_ALBUM);
1297 g_string_append(regex_result, album);
1300 g_string_append(regex_result,
"\n");
1303 g_string_append(regex_result, _(
"<title>: "));
1304 char *title = mp3splt_tags_get(tags, SPLT_TAGS_TITLE);
1307 g_string_append(regex_result, title);
1310 g_string_append(regex_result,
"\n");
1312 g_string_append(regex_result, _(
"<genre>: "));
1313 char *genre = mp3splt_tags_get(tags, SPLT_TAGS_GENRE);
1316 g_string_append(regex_result, genre);
1319 g_string_append(regex_result,
"\n");
1321 g_string_append(regex_result, _(
"<comment>: "));
1322 char *comment = mp3splt_tags_get(tags, SPLT_TAGS_COMMENT);
1325 g_string_append(regex_result, comment);
1328 g_string_append(regex_result,
"\n");
1330 g_string_append(regex_result, _(
"<year>: "));
1331 char *year = mp3splt_tags_get(tags, SPLT_TAGS_YEAR);
1334 g_string_append(regex_result, year);
1337 g_string_append(regex_result,
"\n");
1339 g_string_append(regex_result, _(
"<track>: "));
1340 gchar *track = mp3splt_tags_get(tags, SPLT_TAGS_TRACK);
1343 g_string_append(regex_result, track);
1348 mp3splt_free_one_tag(tags);
1349 free_ui_for_split(ui_fs);
1353 ui_fname->fname = g_string_free(regex_result, FALSE);
1355 add_idle(G_PRIORITY_HIGH_IDLE, (GSourceFunc)test_regex_end, ui_fname, NULL);
1360static void test_regex_event(GtkWidget *widget,
ui_state *ui)
1364 const gchar *test_regex_filename = gtk_entry_get_text(GTK_ENTRY(ui->gui->test_regex_fname_entry));
1365 if (test_regex_filename != NULL)
1367 ui_fs->test_regex_filename = g_strdup(test_regex_filename);
1370 create_thread_and_unref((GThreadFunc)test_regex_thread, (gpointer) ui_fs, ui,
"test_regex");
1373static GtkWidget *create_extract_tags_from_filename_options_box(
ui_state *ui)
1375 GtkWidget *table = wh_new_table();
1377 GtkWidget *regex_entry = wh_new_entry(ui_save_preferences, ui);
1378 ui->gui->regex_entry = regex_entry;
1379 wh_add_in_table_with_label_expand(table, _(
"Regular expression:"), regex_entry);
1381 GtkWidget *regex_label = gtk_label_new(_(
1382 "Above enter PERL-like regular expression using named subgroups.\nFollowing names are recognized:\n"
1383 " (?<artist>) - artist name\n"
1384 " (?<album>) - album title\n"
1385 " (?<title>) - track title\n"
1386 " (?<tracknum>) - current track number\n"
1388 " (?<year>) - year of emission\n"
1389 " (?<genre>) - genre\n"
1390 " (?<comment>) - comment"));
1391 gtk_label_set_selectable(GTK_LABEL(regex_label), TRUE);
1392 gtk_misc_set_alignment(GTK_MISC(regex_label), 0.0, 0.5);
1393 wh_add_in_table(table, wh_put_in_new_hbox_with_margin_level(regex_label, 2));
1397 infos->text_options_list =
1398 g_list_append(infos->text_options_list, GINT_TO_POINTER(SPLT_NO_CONVERSION));
1399 infos->text_options_list =
1400 g_list_append(infos->text_options_list, GINT_TO_POINTER(SPLT_TO_LOWERCASE));
1401 infos->text_options_list =
1402 g_list_append(infos->text_options_list, GINT_TO_POINTER(SPLT_TO_UPPERCASE));
1403 infos->text_options_list =
1404 g_list_append(infos->text_options_list, GINT_TO_POINTER(SPLT_TO_FIRST_UPPERCASE));
1405 infos->text_options_list =
1406 g_list_append(infos->text_options_list, GINT_TO_POINTER(SPLT_TO_WORD_FIRST_UPPERCASE));
1408 GtkWidget *replace_underscore_by_space_check_box =
1409 gtk_check_button_new_with_mnemonic(_(
"_Replace underscores by spaces"));
1410 ui->gui->replace_underscore_by_space_check_box = replace_underscore_by_space_check_box;
1411 g_signal_connect(G_OBJECT(replace_underscore_by_space_check_box),
"toggled",
1412 G_CALLBACK(ui_save_preferences), ui);
1414 wh_add_in_table(table, replace_underscore_by_space_check_box);
1416 GtkComboBox *artist_text_properties_combo = create_text_preferences_combo(ui);
1417 ui->gui->artist_text_properties_combo = artist_text_properties_combo;
1418 wh_add_in_table_with_label(table,
1419 _(
"Artist text properties:"), GTK_WIDGET(artist_text_properties_combo));
1421 GtkComboBox *album_text_properties_combo = create_text_preferences_combo(ui);
1422 ui->gui->album_text_properties_combo = album_text_properties_combo;
1423 wh_add_in_table_with_label(table,
1424 _(
"Album text properties:"), GTK_WIDGET(album_text_properties_combo));
1426 GtkComboBox *title_text_properties_combo = create_text_preferences_combo(ui);
1427 ui->gui->title_text_properties_combo = title_text_properties_combo;
1428 wh_add_in_table_with_label(table,
1429 _(
"Title text properties:"), GTK_WIDGET(title_text_properties_combo));
1431 GtkComboBox *comment_text_properties_combo = create_text_preferences_combo(ui);
1432 ui->gui->comment_text_properties_combo = comment_text_properties_combo;
1433 wh_add_in_table_with_label(table,
1434 _(
"Comment text properties:"), GTK_WIDGET(comment_text_properties_combo));
1436 GtkComboBox *genre_combo = create_genre_combo(ui);
1437 ui->gui->genre_combo = genre_combo;
1438 wh_add_in_table_with_label(table, _(
"Genre tag:"), GTK_WIDGET(genre_combo));
1440 GtkWidget *comment_tag_entry = wh_new_entry(ui_save_preferences, ui);
1441 ui->gui->comment_tag_entry = comment_tag_entry;
1442 wh_add_in_table_with_label_expand(table, _(
"Comment tag:"), comment_tag_entry);
1444 GtkWidget *test_regex_expander = gtk_expander_new(_(
"Regular expression test"));
1445 gtk_container_add(GTK_CONTAINER(test_regex_expander), create_test_regex_table(ui));
1446 wh_add_in_table(table, test_regex_expander);
1448 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1451static GtkWidget *create_test_regex_table(
ui_state *ui)
1453 GtkWidget *table = wh_new_table();
1455 GtkWidget *sample_test_hbox = wh_hbox_new();
1456 GtkWidget *test_regex_fname_entry = wh_new_entry(ui_save_preferences, ui);
1457 ui->gui->test_regex_fname_entry = test_regex_fname_entry;
1458 gtk_box_pack_start(GTK_BOX(sample_test_hbox), test_regex_fname_entry, TRUE, TRUE, 0);
1460 GtkWidget *test_regex_button = wh_new_button(_(
"_Test"));
1461 gtk_box_pack_start(GTK_BOX(sample_test_hbox), test_regex_button, FALSE, FALSE, 5);
1462 g_signal_connect(G_OBJECT(test_regex_button),
"clicked", G_CALLBACK(test_regex_event), ui);
1464 wh_add_in_table_with_label_expand(table, _(
"Sample filename:"), sample_test_hbox);
1466 GtkWidget *sample_result_label = gtk_label_new(
"");
1467 ui->gui->sample_result_label = sample_result_label;
1468 gtk_misc_set_alignment(GTK_MISC(ui->gui->sample_result_label), 0.0, 0.5);
1469 wh_add_in_table_with_label_expand(table, _(
"Sample result:"), ui->gui->sample_result_label);
1471 return wh_put_in_new_hbox_with_margin_level(GTK_WIDGET(table), 3);
1475static GtkWidget *create_tags_version_box(
ui_state *ui)
1479 GtkWidget *vbox = wh_vbox_new();
1481 GtkWidget *tags_version_radio = gtk_radio_button_new_with_label(NULL, _(
"ID3v1 & ID3v2 tags"));
1482 gui->tags_version_radio = tags_version_radio;
1483 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1484 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio),
"toggled",
1485 G_CALLBACK(ui_save_preferences), ui);
1487 tags_version_radio = gtk_radio_button_new_with_label_from_widget
1488 (GTK_RADIO_BUTTON(tags_version_radio), _(
"ID3v2 tags"));
1489 gui->tags_version_radio = tags_version_radio;
1490 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1491 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio),
"toggled",
1492 G_CALLBACK(ui_save_preferences), ui);
1494 tags_version_radio = gtk_radio_button_new_with_label_from_widget
1495 (GTK_RADIO_BUTTON(tags_version_radio), _(
"ID3v1 tags"));
1496 gui->tags_version_radio = tags_version_radio;
1497 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio),
"toggled",
1498 G_CALLBACK(ui_save_preferences), ui);
1499 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1501 tags_version_radio = gtk_radio_button_new_with_label_from_widget
1502 (GTK_RADIO_BUTTON (tags_version_radio),_(
"Same tags version as the input file"));
1503 gui->tags_version_radio = tags_version_radio;
1504 g_signal_connect(GTK_TOGGLE_BUTTON(tags_version_radio),
"toggled",
1505 G_CALLBACK(ui_save_preferences), ui);
1506 gtk_box_pack_start(GTK_BOX(vbox), tags_version_radio, FALSE, FALSE, 0);
1512static GtkWidget *create_pref_tags_page(
ui_state *ui)
1514 GtkWidget *outside_vbox = wh_vbox_new();;
1515 GtkWidget *inside_hbox = wh_hbox_new();
1518 wh_add_box_to_scrolled_window(inside_hbox, scrolled_window);
1519 gtk_box_pack_start(GTK_BOX(outside_vbox), scrolled_window, TRUE, TRUE, 0);
1521 GtkWidget *vbox = wh_vbox_new();;
1522 gtk_box_pack_start(GTK_BOX(inside_hbox), vbox, TRUE, TRUE, 5);
1524 GtkWidget *tags_version_box = create_tags_version_box(ui);
1525 gtk_box_pack_start(GTK_BOX(vbox), tags_version_box, FALSE, FALSE, 2);
1527 GtkWidget *tags_opts_box = create_tags_options_box(ui);
1528 gtk_box_pack_start(GTK_BOX(vbox), tags_opts_box, FALSE, FALSE, 1);
1530 return outside_vbox;
1536 GtkWidget *pref_vbox = wh_vbox_new();
1538 GtkWidget *notebook = gtk_notebook_new();
1539 gtk_box_pack_start(GTK_BOX(pref_vbox), notebook, TRUE, TRUE, 0);
1541 gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook));
1542 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
1543 gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
1544 gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
1547 GtkWidget *splitpoints_prefs = create_pref_splitpoints_page(ui);
1548 GtkWidget *notebook_label = gtk_label_new(_(
"Split"));
1549 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), splitpoints_prefs, notebook_label);
1552 GtkWidget *tags_prefs = create_pref_tags_page(ui);
1553 notebook_label = gtk_label_new(_(
"Tags"));
1554 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tags_prefs, notebook_label);
1557 GtkWidget *player_prefs = create_pref_player_page(ui);
1558 notebook_label = gtk_label_new(_(
"Player"));
1559 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), player_prefs, notebook_label);
1562 GtkWidget *output_prefs = create_pref_output_page(ui);
1563 notebook_label = gtk_label_new(_(
"Output format"));
1564 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), output_prefs, notebook_label);
1568 GtkWidget *language_prefs = create_pref_language_page(ui);
1569 notebook_label = gtk_label_new(_(
"Language"));
1570 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), language_prefs, notebook_label);
void remove_status_message(gui_state *gui)
Removes status bar message.
gchar * get_input_filename(gui_state *gui)
Get the name of the input file.
gfloat get_left_drawing_time(gfloat current_time, gfloat total_time, gfloat zoom_coeff)
returns the value of the left drawing area
void show_connect_button(gui_state *gui)
Show the connect button.
gfloat get_right_drawing_time(gfloat current_time, gfloat total_time, gfloat zoom_coeff)
returns the value of the right drawing area
void disconnect_button_event(GtkWidget *widget, ui_state *ui)
disconnect button event
void hide_connect_button(gui_state *gui)
Hide the connect button.
gint draw_silence_wave(gint left_mark, gint right_mark, gint interpolation_text_x, gint interpolation_text_y, gfloat draw_time, gint width_drawing_area, gint y_margin, gfloat current_time, gfloat total_time, gfloat zoom_coeff, GtkWidget *da, cairo_t *gc, ui_state *ui)
Draws the silence wave.
gchar * get_output_directory(ui_state *ui)
Get the name of the output directory.
GString * get_checked_language(ui_state *ui)
Returns the selected language.
GtkWidget * create_choose_preferences(ui_state *ui)
creates the preferences tab
gboolean get_checked_output_radio_box(ui_state *ui)
returns the checked output radio box
gint get_checked_tags_version_radio_box(gui_state *gui)
returns the checked tags radio box