+void wxFileDialog::SetWildcard(const wxString& wildCard)
+{
+ 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);
+
+ // parse filters
+ wxArrayString wildDescriptions, wildFilters;
+ if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters))
+ {
+ wxFAIL_MSG( wxT("Wrong file type description") );
+ }
+ else
+ {
+ // 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]));
+ wxString after = wildFilters[n];
+ do
+ {
+ wxString ext = after.BeforeFirst(wxT(';'));
+ gtk_file_filter_add_pattern(filter,wxGTK_CONV(ext));
+ if (after.Find(wxT(';')) == wxNOT_FOUND)
+ break;
+ after = after.AfterLast(wxT(';'));
+ }
+ while (!after.empty());
+
+ gtk_file_chooser_add_filter(chooser, filter);
+ }
+ }
+}
+
+void wxFileDialog::SetFilterIndex(int filterIndex)
+{
+ m_filterIndex = filterIndex;
+
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER(m_widget);
+ GSList *fnode = gtk_file_chooser_list_filters(chooser);
+ GSList *filters = fnode;
+ int i = 0;
+ while (fnode)
+ {
+ if (i == filterIndex)
+ {
+ gtk_file_chooser_set_filter(chooser, GTK_FILE_FILTER(fnode->data));
+ m_filterIndex = i;
+ break;
+ }
+ i++;
+ fnode = fnode->next;
+ }
+ g_slist_free(filters);
+}
+
+void wxFileDialog::UpdateFromDialog()
+{
+ // update filterIndex
+ GSList *fnode = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(m_widget));
+ GSList *filters = fnode;
+ GtkFileFilter *current =
+ gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget));
+
+ int i = 0;
+ m_filterIndex = 0;
+ while (fnode)
+ {
+ if (fnode->data == (gpointer)current)
+ {
+ m_filterIndex = i;
+ break;
+ }
+ i++;
+ fnode = fnode->next;
+ }
+ g_slist_free(filters);
+}
+
+void wxFileDialog::UpdateDialog()
+{
+
+ if (wxDirExists(m_path))
+ {
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_path));
+ }
+ else
+ {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_path));
+
+ // pre-fill the filename, too:
+ if (GetWindowStyle() & wxSAVE)
+ {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_fileName));
+ }
+ }
+}
+
+void wxFileDialog::DoSetPath(const wxString& path)
+{
+ if (!path.empty())
+ {
+ wxFileName fn(path);
+ fn.MakeAbsolute();
+ m_path = fn.GetFullPath();
+
+ wxString ext;
+ wxSplitPath(path, &m_dir, &m_fileName, &ext);
+ if (!ext.empty())
+ {
+ m_fileName += wxT(".");
+ m_fileName += ext;
+ }
+ }
+ else
+ {
+ m_path = path;
+ }
+}
+
+#endif // wxUSE_FILEDLG && defined(__WXGTK24__)