Re: gtk_file_chooser_set_filter does not work as advertised



> the documentation for gtk_file_chooser_set_filter() indicates that this
> can be used without having to call gtk_file_chooser_add_filter() to
> restrict the files on display.  this simply does not work.
It appears to work for me. I've attached a sample program that does what
you've described. When I run it, I don't see the drop down to select a
filter, but it only contains files matching the pattern "*.1"

I'd be forced to guess, then, that there's either a bug in the
particular version of gtk you're running against, or there's a glitch in
your code. You describe giving a file entry to allow the user to specify
the pattern; assuming this simple test case works for you, can you post
your specific code, rather than a vague description that seems to match
my little test case here?

Of course, if the simple test case fails for you, it clearly points the
finger at your specific version of gtk. Mine, which it works
successfully with, is 2.6.7, from the fc4 2.6.7-4 rpm.

Hope this helps some.

-- 
David Hoover <karma deadmoose com>
/* gcc -o filter `pkg-config --cflags --libs gtk+-2.0` filter.c -Wall */
#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
   GtkWidget *dialog;
   GtkFileFilter *filter;

   gtk_init(&argc, &argv);


   dialog = gtk_file_chooser_dialog_new(NULL, NULL, 
                                        GTK_FILE_CHOOSER_ACTION_OPEN,
                                        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                        NULL);
   gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);

   filter = gtk_file_filter_new();
   gtk_file_filter_add_pattern(filter, "*.1");

   gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);

   gtk_dialog_run(GTK_DIALOG(dialog));

   return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]