Hello everyone, I’m the developer of BIMP 
(http://alessandrofrancesconi.it/projects/bimp), that’s a plugin for Gimp 
written using the version 2.16 of GTK.

 

Some of my users are complaing a bug when trying to select image files using 
the classic GtkFileChooser: the list of files into every folder (that actually 
contains images) is always empty. The fact is that I can’t reproduce the bug 
while still having likely their same system configuration.

 

But proceed with order... There is a piece of code in my plugin that shows a 
GtkFileChooser filtered in order to show image files only. Here is the code:

 

/* +++++++++++++++++++++++++++++++++++++ */

 GtkFileFilter *filter_all, *supported[7];

 

  file_chooser = gtk_file_chooser_dialog_new(
   _("Select images"), 
   NULL, 
   GTK_FILE_CHOOSER_ACTION_OPEN, 
   GTK_STOCK_CANCEL, GTK_RESPONSE_CLOSE, 
   GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL
  );
  gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(file_chooser), TRUE);
  
  filter_all = gtk_file_filter_new();
  gtk_file_filter_set_name(filter_all,_("All supported types"));
  
  supported[0] = gtk_file_filter_new();
  gtk_file_filter_set_name(supported[0],"BMP");
 #ifdef __APPLE__
  /* Workaround for Mac OSX, that seems to have a bug on GTK file selectors */
  gtk_file_filter_add_pattern (supported[0], "*.[bB][mM][pP]");
  gtk_file_filter_add_pattern (filter_all, "*.[bB][mM][pP]");
 #else
  gtk_file_filter_add_mime_type(supported[0],"image/bmp");
  gtk_file_filter_add_mime_type(filter_all,"image/bmp");
 #endif
 
  supported[1] = gtk_file_filter_new();
  gtk_file_filter_set_name(supported[1],"JPEG");
 #ifdef __APPLE__
  gtk_file_filter_add_pattern (supported[1], "*.[jJ][pP][gG]");
  gtk_file_filter_add_pattern (supported[1], "*.[jJ][pP][eE][gG]");
  gtk_file_filter_add_pattern (filter_all, "*.[jJ][pP][gG]");
  gtk_file_filter_add_pattern (filter_all, "*.[jJ][pP][eE][gG]");
 #else
  gtk_file_filter_add_mime_type(supported[1],"image/jpeg");
  gtk_file_filter_add_mime_type(filter_all,"image/jpeg");
 #endif
 
  supported[2] = gtk_file_filter_new();
  gtk_file_filter_set_name(supported[2],"GIF");
 #ifdef __APPLE__
  gtk_file_filter_add_pattern (supported[2], "*.[gG][iI][fF]");
  gtk_file_filter_add_pattern (filter_all, "*.[gG][iI][fF]");
 #else
  gtk_file_filter_add_mime_type(supported[2],"image/gif");
  gtk_file_filter_add_mime_type(filter_all,"image/gif");
 #endif
 

/* ... other file formats... */
 
  supported[6] = gtk_file_filter_new();
  gtk_file_filter_set_name(supported[6],"XCF");
 #ifdef __APPLE__
  gtk_file_filter_add_pattern (supported[6], "*.[xX][cC][fF]");
  gtk_file_filter_add_pattern (filter_all, "*.[xX][cC][fF]");
 #else
  gtk_file_filter_add_mime_type(supported[6],"image/x-xcf");
  gtk_file_filter_add_mime_type(supported[6],"image/x-compressed-xcf");
  gtk_file_filter_add_mime_type(supported[6],"application/x-ext-xcf");
  gtk_file_filter_add_mime_type(filter_all,"image/x-xcf");
  gtk_file_filter_add_mime_type(filter_all,"image/x-compressed-xcf");
  gtk_file_filter_add_mime_type(filter_all,"application/x-ext-xcf");
 #endif
 

/* finally adds all the filters to the chooser */
  gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser), filter_all);
  int i;
  for(i = 0; i < 7; i++) {
     gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(file_chooser), supported[i]);
  }

/* ++++++++++++++++++++++++++++++++++++ */

 

 

You’ve seen already a thing: I use the mime type filtering by default because I 
think that’s the best approach (in this way the filter should catch files 
without extension too), but apparently it does not work for OSX users, so I 
needed to switch to the less robust “gtk_file_filter_add_pattern” function for 
them. I did the same thing written here 
https://mail.gnome.org/archives/commits-list/2011-February/msg07666.html

 

On the other hand, “some” people on Windows are complaing that they can’t 
select any file too. They have the last version of GIMP (2.8.4), with GTK set 
to 2.16 or higher and they run Windows 7 32bit or XP SP3.

 

Instead, while still having GIMP 2.8 + GTK 2.16 and Windows 7, I personally 
have no bugs when using the FileChooser. So what’s the real problem (also 
regarding OSX users)? Is it a known bug of the GTK core?

 

Could you help me? Thanks!

Ale
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to