gtk_file_chooser_set_filter() usage



hi,

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:

  gtk_file_chooser_dialog_new()

  gtk_file_chooser_set_select_multiple()

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

  gtk_dialog_run()

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]