+ else
+#endif
+ wxGenericFileDialog::SetWildcard( wildCard );
+}
+
+void wxFileDialog::SetFilterIndex(int filterIndex)
+{
+#ifdef __WXGTK24__
+ if (!gtk_check_version(2,4,0))
+ {
+ 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);
+ }
+ else
+#endif
+ wxGenericFileDialog::SetFilterIndex( filterIndex );
+}
+
+void wxFileDialog::UpdateDialog()
+{
+#ifdef __WXGTK24__
+ // set currently selected directory to match the path:
+ if (!m_dir.empty() && wxDirExists(m_dir))
+ {
+ // NB: This is important -- if we set directory only and not the path,
+ // then dialog will still remember old path set using previous
+ // call to gtk_chooser_set_filename. If the previous directory
+ // was a subdirectory of the directory we want to select now,
+ // the dialog would still contain directory selector controls
+ // for the subdirectory (with the parent directory selected),
+ // instead of showing only the parent directory as expected.
+ // This way, we force GtkFileChooser to really change the
+ // directory. Finally, it doesn't have to be done if filename
+ // is not empty because of the code that sets the filename below.
+ if (m_fileName.empty())
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_dir));
+ }
+
+ // if the user set only the directory (e.g. by calling SetDirectory)
+ // and not the default filename, then we don't want to set the filename:
+ if (!m_fileName.empty())
+ {
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_path));
+
+ // pre-fill the filename when saving, too (there's no text entry
+ // control when opening a file, so it doesn't make sense to
+ // do this when opening files):
+ if (GetWindowStyle() & wxSAVE)
+ {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+ wxGTK_CONV(m_fileName));
+ }
+ }
+#endif
+}
+
+void wxFileDialog::UpdateFromDialog()
+{
+#ifdef __WXGTK24__
+ // 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);
+#endif