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
This commit is contained in:
Nick Treleaven 2008-05-07 12:13:58 +00:00
parent 67316db4c5
commit a0aa89cbe9
3 changed files with 14 additions and 5 deletions

View File

@ -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 <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -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]));

View File

@ -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;
}