gtk_file_chooser_set_filter does not work as advertised


last august i posted a question about the use of
gtk_file_chooser_set_filter() routine and that fact that it does not work
as advertised.  of course, i always prefer to think that i'm doing
something wrong since a bug of my own making is ultimately easier and
quicker to fix than a bug in gtk+.

however, after coming back to this and playing with it some more, i cannot
deduce how i am doing anything wrong.  this, coupled with the fact that i
didn't receive a single response to my original query back in august. 
(rather frustrating as well that when i googled this today as part of my
ongoing investigation, the first hit i got was my own email last august;
how frustrating is that?)

my original query is below, but basically it comes down to this:

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.

should i be submitting a bug instead of assuming i've done something wrong
(and then ask for help in identifying it)?


richard boaz

===== ORIGINAL QUERY======

I'm implementing the GtkFileChooser and am having a problem with the
gtk_file_chooser_set_filter() routine.

If I understand the documentation correctly, I should be able to use this
call without being required to call gtk_file_chooser_add_filter().  In
that, I want to apply a filter without the user having a pulldown list of
same.  (Actually, it's the user who wants to specify the filter, so I want
to provide them a text entry field on the dialogue where they can specify
the filter, and then apply it to the dialogue's contents without creating
any pulldown list of filters.)

My code follows the order:



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


Yet when the dialogue comes up, the filter has not been applied.  If I add
gtk_file_chooser_add_filter() with the same filter, the dialogue comes up
with a filter list, nothing selected, and no filter applied, (but with the
filter I've defined as being in the list); when I select my filter from
the list, everything works fine, filter is applied and works correctly.

So, am I doing something wrong?  The GTK+ documentation for
gtk_file_chooser_set_filter() states the following:

BEGIN DOC =================

Sets the current filter; only the files that pass the filter will be
displayed. If the user-selectable list of filters is non-empty, then the
filter should be one of the filters in that list. Setting the current
filter when the list of filters is empty is useful if you want to restrict
the displayed set of files without letting the user change it.

END DOC ===================

>From the last sentence I assume that what I am trying to do is possible,
so I also assume I'm doing it wrong.  (And what does it mean to say "when
the list of filters is empty"?  Simply that gtk_file_chooser_add_filter()
has never been called?  Or do i need to do something to create an "empty"
list as opposed to a "non-existent" list?)

Anybody have a clue and care to point me in the right direction?

All responses greatly appreciated, cheers,

richard boaz

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