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