Karsten Hopp 423a92
To: vim_dev@googlegroups.com
Karsten Hopp 423a92
Subject: Patch 7.3.592
Karsten Hopp 423a92
Fcc: outbox
Karsten Hopp 423a92
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 423a92
Mime-Version: 1.0
Karsten Hopp 423a92
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 423a92
Content-Transfer-Encoding: 8bit
Karsten Hopp 423a92
------------
Karsten Hopp 423a92
Karsten Hopp 423a92
Patch 7.3.592
Karsten Hopp 423a92
Problem:    Vim on GTK does not support g:browsefilter.
Karsten Hopp 423a92
Solution:   Add a GtkFileFilter to the file chooser. (Christian Brabandt)
Karsten Hopp 423a92
Files:	    src/gui_gtk.c
Karsten Hopp 423a92
Karsten Hopp 423a92
Karsten Hopp 423a92
*** ../vim-7.3.591/src/gui_gtk.c	2012-06-06 16:14:36.000000000 +0200
Karsten Hopp 423a92
--- src/gui_gtk.c	2012-07-10 13:08:06.000000000 +0200
Karsten Hopp 423a92
***************
Karsten Hopp 423a92
*** 840,846 ****
Karsten Hopp 423a92
  	       char_u *dflt,
Karsten Hopp 423a92
  	       char_u *ext UNUSED,
Karsten Hopp 423a92
  	       char_u *initdir,
Karsten Hopp 423a92
! 	       char_u *filter UNUSED)
Karsten Hopp 423a92
  {
Karsten Hopp 423a92
  #ifdef USE_FILE_CHOOSER
Karsten Hopp 423a92
      GtkWidget		*fc;
Karsten Hopp 423a92
--- 840,846 ----
Karsten Hopp 423a92
  	       char_u *dflt,
Karsten Hopp 423a92
  	       char_u *ext UNUSED,
Karsten Hopp 423a92
  	       char_u *initdir,
Karsten Hopp 423a92
! 	       char_u *filter)
Karsten Hopp 423a92
  {
Karsten Hopp 423a92
  #ifdef USE_FILE_CHOOSER
Karsten Hopp 423a92
      GtkWidget		*fc;
Karsten Hopp 423a92
***************
Karsten Hopp 423a92
*** 848,853 ****
Karsten Hopp 423a92
--- 848,854 ----
Karsten Hopp 423a92
      char_u		dirbuf[MAXPATHL];
Karsten Hopp 423a92
      guint		log_handler;
Karsten Hopp 423a92
      const gchar		*domain = "Gtk";
Karsten Hopp 423a92
+     GtkFileFilter	*gfilter;
Karsten Hopp 423a92
  
Karsten Hopp 423a92
      title = CONVERT_TO_UTF8(title);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
***************
Karsten Hopp 423a92
*** 879,884 ****
Karsten Hopp 423a92
--- 880,924 ----
Karsten Hopp 423a92
  	    NULL);
Karsten Hopp 423a92
      gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
Karsten Hopp 423a92
  						       (const gchar *)dirbuf);
Karsten Hopp 423a92
+ 
Karsten Hopp 423a92
+     if (filter != NULL && *filter != NUL)
Karsten Hopp 423a92
+     {
Karsten Hopp 423a92
+ 	int     i = 0;
Karsten Hopp 423a92
+ 	char_u  *patt;
Karsten Hopp 423a92
+ 	char_u  *p = filter;
Karsten Hopp 423a92
+ 
Karsten Hopp 423a92
+ 	gfilter = gtk_file_filter_new();
Karsten Hopp 423a92
+ 	patt = alloc(STRLEN(filter));
Karsten Hopp 423a92
+ 	while (p != NULL && *p != NUL)
Karsten Hopp 423a92
+ 	{
Karsten Hopp 423a92
+ 	    if (*p == '\n' || *p == ';' || *p == '\t')
Karsten Hopp 423a92
+ 	    {
Karsten Hopp 423a92
+ 		STRNCPY(patt, filter, i);
Karsten Hopp 423a92
+ 		patt[i] = '\0';
Karsten Hopp 423a92
+ 		if (*p == '\t')
Karsten Hopp 423a92
+ 		    gtk_file_filter_set_name(gfilter, (gchar *)patt);
Karsten Hopp 423a92
+ 		else
Karsten Hopp 423a92
+ 		{
Karsten Hopp 423a92
+ 		    gtk_file_filter_add_pattern(gfilter, (gchar *)patt);
Karsten Hopp 423a92
+ 		    if (*p == '\n')
Karsten Hopp 423a92
+ 		    {
Karsten Hopp 423a92
+ 			gtk_file_chooser_add_filter((GtkFileChooser *)fc,
Karsten Hopp 423a92
+ 								     gfilter);
Karsten Hopp 423a92
+ 			if (*(p + 1) != NUL)
Karsten Hopp 423a92
+ 			    gfilter = gtk_file_filter_new();
Karsten Hopp 423a92
+ 		    }
Karsten Hopp 423a92
+ 		}
Karsten Hopp 423a92
+ 		filter = ++p;
Karsten Hopp 423a92
+ 		i = 0;
Karsten Hopp 423a92
+ 	    }
Karsten Hopp 423a92
+ 	    else
Karsten Hopp 423a92
+ 	    {
Karsten Hopp 423a92
+ 		p++;
Karsten Hopp 423a92
+ 		i++;
Karsten Hopp 423a92
+ 	    }
Karsten Hopp 423a92
+ 	}
Karsten Hopp 423a92
+ 	vim_free(patt);
Karsten Hopp 423a92
+     }
Karsten Hopp 423a92
      if (saving && dflt != NULL && *dflt != NUL)
Karsten Hopp 423a92
  	gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), (char *)dflt);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
***************
Karsten Hopp 423a92
*** 1304,1310 ****
Karsten Hopp 423a92
  	gtk_widget_show(entry);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
  	/* Make Enter work like pressing OK. */
Karsten Hopp 423a92
!         gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
  	text = CONVERT_TO_UTF8(textfield);
Karsten Hopp 423a92
  	gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text);
Karsten Hopp 423a92
--- 1344,1350 ----
Karsten Hopp 423a92
  	gtk_widget_show(entry);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
  	/* Make Enter work like pressing OK. */
Karsten Hopp 423a92
! 	gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
Karsten Hopp 423a92
  
Karsten Hopp 423a92
  	text = CONVERT_TO_UTF8(textfield);
Karsten Hopp 423a92
  	gtk_entry_set_text(GTK_ENTRY(entry), (const char *)text);
Karsten Hopp 423a92
*** ../vim-7.3.591/src/version.c	2012-07-06 18:27:34.000000000 +0200
Karsten Hopp 423a92
--- src/version.c	2012-07-10 13:00:29.000000000 +0200
Karsten Hopp 423a92
***************
Karsten Hopp 423a92
*** 716,717 ****
Karsten Hopp 423a92
--- 716,719 ----
Karsten Hopp 423a92
  {   /* Add new patch number below this line */
Karsten Hopp 423a92
+ /**/
Karsten Hopp 423a92
+     592,
Karsten Hopp 423a92
  /**/
Karsten Hopp 423a92
Karsten Hopp 423a92
-- 
Karsten Hopp 423a92
To be rich is not the end, but only a change of worries.
Karsten Hopp 423a92
Karsten Hopp 423a92
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 423a92
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 423a92
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 423a92
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///