📄 build_store.c
字号:
voidgen_check_incl_toggled(GtkWidget * widget, gpointer * data) { gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gen_check_incl)); gtk_widget_set_sensitive(gen_entry_incl, state);}voidgen_check_cap_pre_toggled(GtkWidget * widget, gpointer * data) { gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gen_check_cap_pre)); gtk_widget_set_sensitive(gen_entry_cap_pre, state);}voidgen_check_cap_toggled(GtkWidget * widget, gpointer * data) { gboolean state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gen_check_cap)); gtk_widget_set_sensitive(gen_combo_cap, state); gtk_widget_set_sensitive(gen_check_cap_pre, state); gtk_widget_set_sensitive(gen_check_cap_low, state); if (state == FALSE) { gtk_widget_set_sensitive(gen_entry_cap_pre, FALSE); } else { gen_check_cap_pre_toggled(NULL, NULL); }}intbrowse_button_clicked(GtkWidget * widget, gpointer * data) { GtkWidget * dialog; const gchar * selected_filename = gtk_entry_get_text(GTK_ENTRY(data)); dialog = gtk_file_chooser_dialog_new(_("Please select the root directory."), GTK_WINDOW(browser_window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); if (options.show_hidden) { gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), options.show_hidden); } deflicker(); if (strlen(selected_filename)) { char * locale = g_locale_from_utf8(selected_filename, -1, NULL, NULL, NULL); if (locale == NULL) { gtk_widget_destroy(dialog); return 0; } gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), locale); g_free(locale); } else { gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), options.currdir); } gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_default_size(GTK_WINDOW(dialog), 580, 390); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); if (aqualung_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { char * utf8; selected_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); utf8 = g_locale_to_utf8(selected_filename, -1, NULL, NULL, NULL); if (utf8 == NULL) { gtk_widget_destroy(dialog); return 0; } gtk_entry_set_text(GTK_ENTRY(data), utf8); strncpy(options.currdir, selected_filename, MAXLEN-1); g_free(utf8); } gtk_widget_destroy(dialog); return 0;}inttest_button_clicked(GtkWidget * widget, gpointer * data) { char * input = (char *)gtk_entry_get_text(GTK_ENTRY(data)); char output[MAXLEN]; int err; fs_preset = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fs_radio_preset)); fs_rm_number = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fs_check_rm_number)); fs_rm_ext = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fs_check_rm_ext)); fs_underscore = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fs_check_underscore)); strncpy(fs_regexp, gtk_entry_get_text(GTK_ENTRY(fs_entry_regexp1)), MAXLEN-1); strncpy(fs_replacement, gtk_entry_get_text(GTK_ENTRY(fs_entry_regexp2)), MAXLEN-1); gtk_widget_hide(fs_label_error); gtk_entry_set_text(GTK_ENTRY(fs_entry_output), ""); if (!fs_preset) { if ((err = regcomp(&fs_compiled, fs_regexp, REG_EXTENDED))) { char msg[MAXLEN]; char * utf8; regerror(err, &fs_compiled, msg, MAXLEN); utf8 = g_locale_to_utf8(msg, -1, NULL, NULL, NULL); gtk_label_set_text(GTK_LABEL(fs_label_error), utf8); gtk_widget_show(fs_label_error); g_free(utf8); regfree(&fs_compiled); gtk_widget_grab_focus(fs_entry_regexp1); return 0; } if (!regexec(&fs_compiled, "", 0, NULL, 0)) { gtk_label_set_text(GTK_LABEL(fs_label_error), _("Regexp matches empty string")); gtk_widget_show(fs_label_error); regfree(&fs_compiled); gtk_widget_grab_focus(fs_entry_regexp1); return 0; } } transform_filename(output, input); if (fs_preset) { regfree(&fs_compiled); } gtk_entry_set_text(GTK_ENTRY(fs_entry_output), output); return 0;}intbuild_dialog(void) { GtkWidget * dialog; GtkWidget * notebook; GtkWidget * label; GtkWidget * table; GtkWidget * hbox; GtkWidget * root_entry; GtkWidget * browse_button; GtkWidget * gen_vbox; GtkWidget * gen_path_frame = NULL; GtkWidget * gen_artist_frame; GtkWidget * gen_artist_vbox; GtkWidget * gen_artist_combo; GtkWidget * gen_record_frame; GtkWidget * gen_record_vbox; GtkWidget * gen_record_combo; GtkWidget * gen_excl_frame; GtkWidget * gen_excl_frame_hbox; GtkWidget * gen_incl_frame; GtkWidget * gen_incl_frame_hbox; GtkWidget * gen_cap_frame; GtkWidget * gen_cap_frame_vbox; GtkWidget * gen_check_rm_spaces; GtkWidget * gen_check_reset_data; GtkWidget * gen_check_add_year; GtkWidget * meta_vbox; GtkWidget * meta_frame; GtkWidget * meta_frame_vbox; GtkWidget * fs_vbox; GtkWidget * fs_frame_preset; GtkWidget * fs_frame_preset_vbox; GtkWidget * fs_frame_regexp; GtkWidget * fs_frame_regexp_vbox; GtkWidget * fs_frame_sandbox;#ifdef HAVE_CDDB GtkWidget * gen_pri_frame; GtkWidget * gen_pri_combo; GtkWidget * gen_pri_vbox; GtkWidget * cddb_vbox; GtkWidget * cddb_frame; GtkWidget * cddb_frame_vbox;#endif /* HAVE_CDDB */ GdkColor red = { 0, 30000, 0, 0 }; char * title = NULL; int i, ret; char filter[20480]; char * pfilter = NULL; if (build_type == BUILD_STORE) { title = _("Build/Update store"); } else { title = _("Build/Update artist"); } dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(browser_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(dialog), 400, -1); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_REJECT); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), notebook); /* General */ gen_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_vbox), 5); label = gtk_label_new(_("General")); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), gen_vbox, label); if (build_type == BUILD_STORE) { gen_path_frame = gtk_frame_new(_("Root path")); } else { gen_path_frame = gtk_frame_new(_("Artist path")); } gtk_box_pack_start(GTK_BOX(gen_vbox), gen_path_frame, FALSE, FALSE, 5); hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); gtk_container_add(GTK_CONTAINER(gen_path_frame), hbox); root_entry = gtk_entry_new (); gtk_entry_set_max_length(GTK_ENTRY(root_entry), MAXLEN-1); gtk_box_pack_start(GTK_BOX(hbox), root_entry, TRUE, TRUE, 5); browse_button = gui_stock_label_button(_("_Browse..."), GTK_STOCK_OPEN); gtk_box_pack_start(GTK_BOX(hbox), browse_button, FALSE, TRUE, 2); g_signal_connect(G_OBJECT(browse_button), "clicked", G_CALLBACK(browse_button_clicked), (gpointer *)root_entry);#ifdef HAVE_CDDB gen_pri_frame = gtk_frame_new(_("Data source priority")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_pri_frame, FALSE, FALSE, 5); gen_pri_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_pri_vbox), 5); gtk_container_add(GTK_CONTAINER(gen_pri_frame), gen_pri_vbox); gen_pri_combo = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(gen_pri_vbox), gen_pri_combo, FALSE, FALSE, 0); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_pri_combo), _("Metadata, CDDB, Filesystem")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_pri_combo), _("CDDB, Metadata, Filesystem")); if (pri_meta_first) { gtk_combo_box_set_active(GTK_COMBO_BOX(gen_pri_combo), 0); } else { gtk_combo_box_set_active(GTK_COMBO_BOX(gen_pri_combo), 1); }#endif /* HAVE_CDDB */ gen_artist_frame = gtk_frame_new(_("Sort artists by")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_artist_frame, FALSE, FALSE, 5); gen_artist_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_artist_vbox), 5); gtk_container_add(GTK_CONTAINER(gen_artist_frame), gen_artist_vbox); gen_artist_combo = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(gen_artist_vbox), gen_artist_combo, FALSE, FALSE, 0); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_artist_combo), _("Artist name")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_artist_combo), _("Artist name (lowercase)")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_artist_combo), _("Directory name")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_artist_combo), _("Directory name (lowercase)")); switch (artist_sort_by) { case ARTIST_SORT_NAME: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_artist_combo), 0); break; case ARTIST_SORT_NAME_LOW: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_artist_combo), 1); break; case ARTIST_SORT_DIR: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_artist_combo), 2); break; case ARTIST_SORT_DIR_LOW: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_artist_combo), 3); break; } gen_record_frame = gtk_frame_new(_("Sort records by")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_record_frame, FALSE, FALSE, 5); gen_record_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_record_vbox), 5); gtk_container_add(GTK_CONTAINER(gen_record_frame), gen_record_vbox); gen_record_combo = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(gen_record_vbox), gen_record_combo, FALSE, FALSE, 0); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_record_combo), _("Year")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_record_combo), _("Record name")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_record_combo), _("Record name (lowercase)")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_record_combo), _("Directory name")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_record_combo), _("Directory name (lowercase)")); switch (record_sort_by) { case RECORD_SORT_YEAR: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_record_combo), 0); break; case RECORD_SORT_NAME: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_record_combo), 1); break; case RECORD_SORT_NAME_LOW: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_record_combo), 2); break; case RECORD_SORT_DIR: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_record_combo), 3); break; case RECORD_SORT_DIR_LOW: gtk_combo_box_set_active(GTK_COMBO_BOX(gen_record_combo), 4); break; } gen_excl_frame = gtk_frame_new(_("Exclude files matching wildcard")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_excl_frame, FALSE, FALSE, 5); gen_excl_frame_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_excl_frame_hbox), 5); gtk_container_add(GTK_CONTAINER(gen_excl_frame), gen_excl_frame_hbox); gen_check_excl = gtk_check_button_new(); gtk_widget_set_name(gen_check_excl, "check_on_notebook"); gtk_box_pack_start(GTK_BOX(gen_excl_frame_hbox), gen_check_excl, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(gen_check_excl), "toggled", G_CALLBACK(gen_check_excl_toggled), NULL); gen_entry_excl = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(gen_entry_excl), MAXLEN-1); gtk_entry_set_text(GTK_ENTRY(gen_entry_excl), "*.jpg,*.jpeg,*.png,*.gif,*.pls,*.m3u,*.cue,*.xml,*.html,*.htm,*.txt,*.avi"); gtk_box_pack_end(GTK_BOX(gen_excl_frame_hbox), gen_entry_excl, TRUE, TRUE, 0); if (excl_enabled) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gen_check_excl), TRUE); } else { gtk_widget_set_sensitive(gen_entry_excl, FALSE); } gen_incl_frame = gtk_frame_new(_("Include only files matching wildcard")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_incl_frame, FALSE, FALSE, 5); gen_incl_frame_hbox = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_incl_frame_hbox), 5); gtk_container_add(GTK_CONTAINER(gen_incl_frame), gen_incl_frame_hbox); gen_check_incl = gtk_check_button_new(); gtk_widget_set_name(gen_check_incl, "check_on_notebook"); gtk_box_pack_start(GTK_BOX(gen_incl_frame_hbox), gen_check_incl, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(gen_check_incl), "toggled", G_CALLBACK(gen_check_incl_toggled), NULL); gen_entry_incl = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(gen_entry_incl), MAXLEN-1); filter[0] = '\0';#ifdef HAVE_SNDFILE for (i = 0; valid_extensions_sndfile[i] != NULL; i++) { strcat(filter, "*."); strcat(filter, valid_extensions_sndfile[i]); strcat(filter, ","); }#endif /* HAVE_SNDFILE */#ifdef HAVE_FLAC strcat(filter, "*.flac,");#endif /* HAVE_FLAC */#ifdef HAVE_OGG_VORBIS strcat(filter, "*.ogg,");#endif /* HAVE_OGG_VORBIS */#ifdef HAVE_MPEG for (i = 0; valid_extensions_mpeg[i] != NULL; i++) { strcat(filter, "*."); strcat(filter, valid_extensions_mpeg[i]); strcat(filter, ","); }#endif /* HAVE_MPEG */#ifdef HAVE_SPEEX strcat(filter, "*.spx,");#endif /* HAVE_SPEEX */#ifdef HAVE_MPC strcat(filter, "*.mpc,");#endif /* HAVE_MPC */#ifdef HAVE_MAC strcat(filter, "*.ape,");#endif /* HAVE_MAC */#ifdef HAVE_MOD for (i = 0; valid_extensions_mod[i] != NULL; i++) { strcat(filter, "*."); strcat(filter, valid_extensions_mod[i]); strcat(filter, ","); }#endif /* HAVE_MOD */ if ((pfilter = strrchr(filter, ',')) != NULL) { *pfilter = '\0'; } gtk_entry_set_text(GTK_ENTRY(gen_entry_incl), filter); gtk_box_pack_end(GTK_BOX(gen_incl_frame_hbox), gen_entry_incl, TRUE, TRUE, 0); if (incl_enabled) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gen_check_incl), TRUE); } else { gtk_widget_set_sensitive(gen_entry_incl, FALSE); } gen_cap_frame = gtk_frame_new(_("Capitalization")); gtk_box_pack_start(GTK_BOX(gen_vbox), gen_cap_frame, FALSE, FALSE, 5); gen_cap_frame_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(gen_cap_frame_vbox), 5); gtk_container_add(GTK_CONTAINER(gen_cap_frame), gen_cap_frame_vbox); table = gtk_table_new(2, 2, FALSE); gtk_box_pack_start(GTK_BOX(gen_cap_frame_vbox), table, FALSE, FALSE, 0); gen_check_cap = gtk_check_button_new_with_label(_("Capitalize: ")); gtk_widget_set_name(gen_check_cap, "check_on_notebook"); gtk_table_attach(GTK_TABLE(table), gen_check_cap, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect(G_OBJECT(gen_check_cap), "toggled", G_CALLBACK(gen_check_cap_toggled), NULL); gen_combo_cap = gtk_combo_box_new_text(); gtk_table_attach(GTK_TABLE(table), gen_combo_cap, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 5, 0); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_combo_cap), _("All words")); gtk_combo_box_append_text(GTK_COMBO_BOX(gen_combo_cap), _("First word only")); gen_check_cap_pre = gtk_check_button_new_with_label(_("Force case: ")); gtk_widget_set_name(gen_check_cap_pre, "check_on_notebook"); gtk_table_attach(GTK_TABLE(table), gen_check_cap_pre, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 5); g_signal_connect(G_OBJECT(gen_check_cap_pre), "toggled", G_CALLBACK(gen_check_cap_pre_toggled), NULL); gen_entry_cap_pre = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(gen_entry_cap_pre), MAXLEN-1); gtk_entry_set_text(GTK_ENTRY(gen_entry_cap_pre), "CD,a),b),c),d),I,II,III,IV,V,VI,VII,VIII,IX,X"); gtk_table_attach(GTK_TABLE(table), gen_entry_cap_pre, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 5, 5);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -