From a0aa89cbe9d645bd74739db268c51e5e7d4b646e Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 7 May 2008 12:13:58 +0000 Subject: [PATCH] Make Open dialog file filter work for custom filetypes. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/custom-filetypes@2554 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 ++ src/dialogs.c | 9 +++++++-- src/filetypes.c | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42f2ffea..68968998 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ filetypes_array->len. Highlighting and templates now use GEANY_MAX_BUILT_IN_FILETYPES. Move print_filetypes() out of parse_command_line_options(); + * src/dialogs.c, src/filetypes.c: + Make Open dialog file filter work for custom filetypes. 2008-05-06 Nick Treleaven diff --git a/src/dialogs.c b/src/dialogs.c index 01fa9380..2d9f29e3 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -87,7 +87,9 @@ on_file_open_dialog_response (GtkDialog *dialog, gchar *charset = NULL; gboolean ro = (response == GEANY_RESPONSE_VIEW); /* View clicked */ - if (filetype_idx >= 0 && filetype_idx < GEANY_FILETYPES_ALL) ft = filetypes[filetype_idx]; + /* ignore detect from file item */ + if (filetype_idx >= 0 && filetype_idx < GEANY_FILETYPES_ALL) + ft = filetypes[filetype_idx]; if (encoding_idx >= 0 && encoding_idx < GEANY_ENCODINGS_MAX) charset = encodings[encoding_idx].charset; @@ -205,8 +207,11 @@ static void create_open_file_dialog(void) /* now create meta filter "All Source" */ gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel), filetypes_create_file_filter_all_source()); - for (i = 0; i < filetypes_array->len - 1; i++) + for (i = 0; i < filetypes_array->len; i++) { + if (i == GEANY_FILETYPES_ALL) + continue; + gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), filetypes[i]->title); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(ui_widgets.open_filesel), filetypes_create_file_filter(filetypes[i])); diff --git a/src/filetypes.c b/src/filetypes.c index 414f7d3d..c8c504ea 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -978,19 +978,21 @@ void filetypes_save_commands() GtkFileFilter *filetypes_create_file_filter_all_source() { GtkFileFilter *new_filter; - gint i, j; + guint i, j; new_filter = gtk_file_filter_new(); gtk_file_filter_set_name(new_filter, _("All Source")); - for (i = 0; i < GEANY_FILETYPES_ALL; i++) + for (i = 0; i < filetypes_array->len; i++) { + if (i == GEANY_FILETYPES_ALL) + continue; + for (j = 0; filetypes[i]->pattern[j]; j++) { gtk_file_filter_add_pattern(new_filter, filetypes[i]->pattern[j]); } } - return new_filter; }