#include "wx/filedlg.h"
#endif
-#include <gtk/gtk.h>
#include "wx/gtk/private.h"
#include <unistd.h> // chdir
-
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-
//-----------------------------------------------------------------------------
// "clicked" for OK-button
//-----------------------------------------------------------------------------
extern "C" {
static void gtk_dirdialog_ok_callback(GtkWidget *widget, wxDirDialog *dialog)
{
- gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
-
// change to the directory where the user went if asked
if (dialog->HasFlag(wxDD_CHANGE_DIR))
+ {
+ wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
chdir(filename);
-
- g_free(filename);
+ }
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
event.SetEventObject(dialog);
gint response,
wxDirDialog *dialog)
{
- wxapp_install_idle_handler();
-
if (response == GTK_RESPONSE_ACCEPT)
gtk_dirdialog_ok_callback(w, dialog);
else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE
if (!gtk_check_version(2,4,0))
{
m_message = title;
- m_needParent = false;
+
+ parent = GetParentForModalDialog(parent);
if (!PreCreation(parent, pos, wxDefaultSize) ||
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
return;
}
- GtkFileChooserAction gtk_action;
GtkWindow* gtk_parent = NULL;
if (parent)
gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) );
- if (HasFlag(wxDD_DIR_MUST_EXIST))
- gtk_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
- else
- gtk_action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
-
m_widget = gtk_file_chooser_dialog_new(
wxGTK_CONV(m_message),
gtk_parent,
- gtk_action,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
- wxConvFileName->cWX2MB(defaultPath) );
+ defaultPath.fn_str() );
}
else
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
{
if (wxDirExists(dir))
{
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ dir.fn_str());
}
}
else
{
if (!gtk_check_version(2,4,0))
{
- gchar *str = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(m_widget) );
- wxString ret = wxConvFileName->cMB2WX(str);
- if (str) g_free(str);
-
- return ret;
+ wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
+ return wxString(str, *wxConvFileName);
}
- else
- return wxGenericDirDialog::GetPath();
+
+ return wxGenericDirDialog::GetPath();
}
#endif // wxUSE_DIRDLG