# HG changeset patch # User Colin Clark # Date 1517744585 0 # Node ID c3417ff927226ca873df3e4174b9b0a0546cd490 # Parent 977b97448cbe0585fdd525776af603218e07b702 Show .icc files when selecting color profiles Modify tabcomp code to permit filter and filter description to be set. Modify preferences to filter on .icc when selecting color profiles. diff -r 977b97448cbe -r c3417ff92722 src/cache_maint.c --- a/src/cache_maint.c Sat Feb 03 11:29:16 2018 +0000 +++ b/src/cache_maint.c Sun Feb 04 11:43:05 2018 +0000 @@ -816,7 +816,7 @@ hbox = pref_box_new(cd->group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); pref_label_new(hbox, _("Folder:")); - label = tab_completion_new(&cd->entry, path, NULL, NULL); + label = tab_completion_new(&cd->entry, path, NULL, NULL, NULL, NULL); tab_completion_add_select_button(cd->entry,_("Select folder") , TRUE); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); gtk_widget_show(label); diff -r 977b97448cbe -r c3417ff92722 src/layout.c --- a/src/layout.c Sat Feb 03 11:29:16 2018 +0000 +++ b/src/layout.c Sun Feb 04 11:43:05 2018 +0000 @@ -2123,7 +2123,7 @@ pref_label_new(group, _("Home path (empty to use your home directory)")); hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); - tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL); + tabcomp = tab_completion_new(&lc->home_path_entry, lc->options.home_path, NULL, NULL, NULL, NULL); tab_completion_add_select_button(lc->home_path_entry, NULL, TRUE); gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); gtk_widget_show(tabcomp); diff -r 977b97448cbe -r c3417ff92722 src/preferences.c --- a/src/preferences.c Sat Feb 03 11:29:16 2018 +0000 +++ b/src/preferences.c Sun Feb 04 11:43:05 2018 +0000 @@ -2284,7 +2284,7 @@ gtk_widget_show(entry); color_profile_input_name_entry[i] = entry; - tabcomp = tab_completion_new(&entry, options->color_profile.input_file[i], NULL, NULL); + tabcomp = tab_completion_new(&entry, options->color_profile.input_file[i], NULL, ".icc", "ICC Files", NULL); tab_completion_add_select_button(entry, _("Select color profile"), FALSE); gtk_widget_set_size_request(entry, 160, -1); gtk_table_attach(GTK_TABLE(table), tabcomp, 2, 3, i + 1, i + 2, @@ -2304,7 +2304,7 @@ pref_table_label(table, 0, 0, _("Screen:"), 1.0); tabcomp = tab_completion_new(&color_profile_screen_file_entry, - options->color_profile.screen_file, NULL, NULL); + options->color_profile.screen_file, NULL, ".icc", "ICC Files", NULL); tab_completion_add_select_button(color_profile_screen_file_entry, _("Select color profile"), FALSE); gtk_widget_set_size_request(color_profile_screen_file_entry, 160, -1); #ifdef HAVE_LCMS @@ -2347,7 +2347,7 @@ pref_spacer(hbox, PREF_PAD_INDENT - PREF_PAD_SPACE); pref_label_new(hbox, _("Folder:")); - tabcomp = tab_completion_new(&safe_delete_path_entry, options->file_ops.safe_delete_path, NULL, NULL); + tabcomp = tab_completion_new(&safe_delete_path_entry, options->file_ops.safe_delete_path, NULL, NULL, NULL, NULL); tab_completion_add_select_button(safe_delete_path_entry, NULL, TRUE); gtk_box_pack_start(GTK_BOX(hbox), tabcomp, TRUE, TRUE, 0); gtk_widget_show(tabcomp); diff -r 977b97448cbe -r c3417ff92722 src/ui_tabcomp.c --- a/src/ui_tabcomp.c Sat Feb 03 11:29:16 2018 +0000 +++ b/src/ui_tabcomp.c Sun Feb 04 11:43:05 2018 +0000 @@ -87,6 +87,8 @@ gchar *fd_title; gboolean fd_folders_only; GtkWidget *fd_button; + gchar *filter; + gchar *filter_desc; guint choices; }; @@ -168,6 +170,9 @@ if (td->fd) file_dialog_close(td->fd); g_free(td->fd_title); + g_free(td->filter); + g_free(td->filter_desc); + g_free(td); } @@ -738,7 +743,7 @@ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); gtk_widget_show(button); - tab_completion_add_to_entry(combo_entry, enter_func, data); + tab_completion_add_to_entry(combo_entry, enter_func, NULL, NULL, data); td = g_object_get_data(G_OBJECT(combo_entry), "tab_completion_data"); if (!td) return NULL; /* this should never happen! */ @@ -821,7 +826,7 @@ } GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text, - void (*enter_func)(const gchar *, gpointer), gpointer data) + void (*enter_func)(const gchar *, gpointer), const gchar *filter, const gchar *filter_desc, gpointer data) { GtkWidget *hbox; GtkWidget *button; @@ -838,13 +843,12 @@ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_widget_show(button); - tab_completion_add_to_entry(newentry, enter_func, data); - + tab_completion_add_to_entry(newentry, enter_func, filter, filter_desc, data); if (entry) *entry = newentry; return hbox; } -void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gchar *, gpointer), gpointer data) +void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gchar *, gpointer), const gchar *filter, const gchar *filter_desc, gpointer data) { TabCompData *td; if (!entry) @@ -858,6 +862,8 @@ td->entry = entry; td->enter_func = enter_func; td->enter_data = data; + td->filter = g_strdup(filter); + td->filter_desc = g_strdup(filter_desc); g_object_set_data(G_OBJECT(td->entry), "tab_completion_data", td); @@ -923,6 +929,8 @@ { const gchar *title; const gchar *path; + gchar *filter = NULL; + gchar *filter_desc = NULL; if (td->fd) { @@ -938,6 +946,23 @@ generic_dialog_add_message(GENERIC_DIALOG(td->fd), NULL, title, NULL, FALSE); + if (td->filter) + { + filter = td->filter; + } + else + { + filter = "*"; + } + if (td->filter_desc) + { + filter_desc = td->filter_desc; + } + else + { + filter_desc = _("All files"); + } + path = gtk_entry_get_text(GTK_ENTRY(td->entry)); if (strlen(path) == 0) path = NULL; if (td->fd_folders_only) @@ -946,7 +971,7 @@ } else { - file_dialog_add_path_widgets(td->fd, NULL, path, td->history_key, "*", _("All files")); + file_dialog_add_path_widgets(td->fd, NULL, path, td->history_key, filter, filter_desc); } gtk_widget_show(GENERIC_DIALOG(td->fd)->dialog); diff -r 977b97448cbe -r c3417ff92722 src/ui_tabcomp.h --- a/src/ui_tabcomp.h Sat Feb 03 11:29:16 2018 +0000 +++ b/src/ui_tabcomp.h Sun Feb 04 11:43:05 2018 +0000 @@ -30,8 +30,8 @@ void tab_completion_append_to_history(GtkWidget *entry, const gchar *path); GtkWidget *tab_completion_new(GtkWidget **entry, const gchar *text, - void (*enter_func)(const gchar *, gpointer), gpointer data); -void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gchar *, gpointer), gpointer data); + void (*enter_func)(const gchar *, gpointer), const gchar *filter, const gchar *filter_desc, gpointer data); +void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(const gchar *, gpointer), const gchar *filter, const gchar *filter_desc, gpointer data); void tab_completion_add_tab_func(GtkWidget *entry, void (*tab_func)(const gchar *, gpointer), gpointer data); gchar *remove_trailing_slash(const gchar *path);