Skip to content

Commit 5e85203

Browse files
committed
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)
1 parent ce20886 commit 5e85203

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/gui_gtk.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,14 +840,15 @@ gui_mch_browse(int saving UNUSED,
840840
char_u *dflt,
841841
char_u *ext UNUSED,
842842
char_u *initdir,
843-
char_u *filter UNUSED)
843+
char_u *filter)
844844
{
845845
#ifdef USE_FILE_CHOOSER
846846
GtkWidget *fc;
847847
#endif
848848
char_u dirbuf[MAXPATHL];
849849
guint log_handler;
850850
const gchar *domain = "Gtk";
851+
GtkFileFilter *gfilter;
851852

852853
title = CONVERT_TO_UTF8(title);
853854

@@ -879,6 +880,45 @@ gui_mch_browse(int saving UNUSED,
879880
NULL);
880881
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
881882
(const gchar *)dirbuf);
883+
884+
if (filter != NULL && *filter != NUL)
885+
{
886+
int i = 0;
887+
char_u *patt;
888+
char_u *p = filter;
889+
890+
gfilter = gtk_file_filter_new();
891+
patt = alloc(STRLEN(filter));
892+
while (p != NULL && *p != NUL)
893+
{
894+
if (*p == '\n' || *p == ';' || *p == '\t')
895+
{
896+
STRNCPY(patt, filter, i);
897+
patt[i] = '\0';
898+
if (*p == '\t')
899+
gtk_file_filter_set_name(gfilter, (gchar *)patt);
900+
else
901+
{
902+
gtk_file_filter_add_pattern(gfilter, (gchar *)patt);
903+
if (*p == '\n')
904+
{
905+
gtk_file_chooser_add_filter((GtkFileChooser *)fc,
906+
gfilter);
907+
if (*(p + 1) != NUL)
908+
gfilter = gtk_file_filter_new();
909+
}
910+
}
911+
filter = ++p;
912+
i = 0;
913+
}
914+
else
915+
{
916+
p++;
917+
i++;
918+
}
919+
}
920+
vim_free(patt);
921+
}
882922
if (saving && dflt != NULL && *dflt != NUL)
883923
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt);
884924

@@ -1304,7 +1344,7 @@ gui_mch_dialog(int type, /* type of dialog */
13041344
gtk_widget_show(entry);
13051345

13061346
/* Make Enter work like pressing OK. */
1307-
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
1347+
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
13081348

13091349
text = CONVERT_TO_UTF8(textfield);
13101350
gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
592,
717719
/**/
718720
591,
719721
/**/

0 commit comments

Comments
 (0)