diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-07-10 13:12:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-07-10 13:12:51 +0200 |
commit | 6c4b646d84836ac1adf881cf325f580ceb8ab7f6 (patch) | |
tree | 7f7ab804e124f31fe05c866c608e5185cd5b6425 | |
parent | 8cb8dca2f0683a29a2cb441a8cd995d25c29d79c (diff) | |
download | vim-6c4b646d84836ac1adf881cf325f580ceb8ab7f6.zip |
updated for version 7.3.592
Problem: Vim on GTK does not support g:browsefilter.
Solution: Add a GtkFileFilter to the file chooser. (Christian Brabandt)
-rw-r--r-- | src/gui_gtk.c | 44 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 44 insertions, 2 deletions
diff --git a/src/gui_gtk.c b/src/gui_gtk.c index 5266dd7ce..c62201e22 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -840,7 +840,7 @@ gui_mch_browse(int saving UNUSED, char_u *dflt, char_u *ext UNUSED, char_u *initdir, - char_u *filter UNUSED) + char_u *filter) { #ifdef USE_FILE_CHOOSER GtkWidget *fc; @@ -848,6 +848,7 @@ gui_mch_browse(int saving UNUSED, char_u dirbuf[MAXPATHL]; guint log_handler; const gchar *domain = "Gtk"; + GtkFileFilter *gfilter; title = CONVERT_TO_UTF8(title); @@ -879,6 +880,45 @@ gui_mch_browse(int saving UNUSED, NULL); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc), (const gchar *)dirbuf); + + if (filter != NULL && *filter != NUL) + { + int i = 0; + char_u *patt; + char_u *p = filter; + + gfilter = gtk_file_filter_new(); + patt = alloc(STRLEN(filter)); + while (p != NULL && *p != NUL) + { + if (*p == '\n' || *p == ';' || *p == '\t') + { + STRNCPY(patt, filter, i); + patt[i] = '\0'; + if (*p == '\t') + gtk_file_filter_set_name(gfilter, (gchar *)patt); + else + { + gtk_file_filter_add_pattern(gfilter, (gchar *)patt); + if (*p == '\n') + { + gtk_file_chooser_add_filter((GtkFileChooser *)fc, + gfilter); + if (*(p + 1) != NUL) + gfilter = gtk_file_filter_new(); + } + } + filter = ++p; + i = 0; + } + else + { + p++; + i++; + } + } + vim_free(patt); + } if (saving && dflt != NULL && *dflt != NUL) gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt); @@ -1304,7 +1344,7 @@ gui_mch_dialog(int type, /* type of dialog */ gtk_widget_show(entry); /* Make Enter work like pressing OK. */ - gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); + gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); text = CONVERT_TO_UTF8(textfield); gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text); diff --git a/src/version.c b/src/version.c index 4bfec7865..5f615edc4 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 592, +/**/ 591, /**/ 590, |