+wxString wxFileDialog::GetFilename() const
+{
+ if (!gtk_check_version(2,4,0))
+ return wxFileName(GetPath()).GetFullName();
+ else
+ return wxGenericFileDialog::GetFilename();
+}
+
+void wxFileDialog::SetWildcard(const wxString& wildCard)
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ // parse filters
+ wxArrayString wildDescriptions, wildFilters;
+ if (!wxParseCommonDialogsFilter(wildCard, wildDescriptions, wildFilters))
+ {
+ wxFAIL_MSG( wxT("wxFileDialog::SetWildCard - bad wildcard string") );
+ }
+ else
+ {
+ // Parsing went fine. Set m_wildCard to be returned by wxFileDialogBase::GetWildcard
+ m_wildCard = wildCard;
+
+ GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
+
+ // empty current filter list:
+ GSList* ifilters = gtk_file_chooser_list_filters(chooser);
+ GSList* filters = ifilters;
+
+ while (ifilters)
+ {
+ gtk_file_chooser_remove_filter(chooser,GTK_FILE_FILTER(ifilters->data));
+ ifilters = ifilters->next;
+ }
+ g_slist_free(filters);
+
+ // add parsed to GtkChooser
+ for (size_t n = 0; n < wildFilters.GetCount(); ++n)
+ {
+ GtkFileFilter* filter = gtk_file_filter_new();
+ gtk_file_filter_set_name(filter, wxGTK_CONV(wildDescriptions[n]));
+
+ wxStringTokenizer exttok(wildFilters[n], wxT(";"));
+ while (exttok.HasMoreTokens())
+ {
+ wxString token = exttok.GetNextToken();
+ gtk_file_filter_add_pattern(filter, wxGTK_CONV(token));
+ }
+
+ gtk_file_chooser_add_filter(chooser, filter);
+ }
+
+ // Reset the filter index
+ SetFilterIndex(0);
+ }
+ }
+ else
+ wxGenericFileDialog::SetWildcard( wildCard );
+}
+
+void wxFileDialog::SetFilterIndex(int filterIndex)
+{
+
+ if (!gtk_check_version(2,4,0))
+ {
+ gpointer filter;
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
+ GSList *filters = gtk_file_chooser_list_filters(chooser);
+
+ filter = g_slist_nth_data(filters, filterIndex);
+
+ if (filter != NULL)
+ {
+ gtk_file_chooser_set_filter(chooser, GTK_FILE_FILTER(filter));
+ }
+ else
+ {
+ wxFAIL_MSG( wxT("wxFileDialog::SetFilterIndex - bad filter index") );
+ }
+
+ g_slist_free(filters);
+ }
+ else
+ wxGenericFileDialog::SetFilterIndex( filterIndex );
+}
+
+int wxFileDialog::GetFilterIndex() const
+{
+ if (!gtk_check_version(2,4,0))
+ {
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
+ GtkFileFilter *filter = gtk_file_chooser_get_filter(chooser);
+ GSList *filters = gtk_file_chooser_list_filters(chooser);
+ gint index = g_slist_index(filters, filter);
+ g_slist_free(filters);
+
+ if (index == -1)
+ {
+ wxFAIL_MSG( wxT("wxFileDialog::GetFilterIndex - bad filter index returned by gtk+") );
+ return 0;
+ }
+ else
+ return index;
+ }
+ else
+ return wxGenericFileDialog::GetFilterIndex();