]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/filedlg.cpp
Add USE_GDIPLUS=1
[wxWidgets.git] / src / gtk / filedlg.cpp
index 499fe0c07c41f778c24841b5c251947cbc320a13..16cc0b0c5617b699e286bd0978912513cef73c46 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
 static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
 {
     int style = dialog->GetWindowStyle();
-    gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+    wxGtkString filename(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
 
     // gtk version numbers must be identical with the one in ctor (that calls set_do_overwrite_confirmation)
 #if GTK_CHECK_VERSION(2,7,3)
@@ -69,13 +69,10 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
     if (style & wxFD_CHANGE_DIR)
     {
         // Use chdir to not care about filename encodings
-        gchar* folder = g_path_get_dirname(filename);
+        wxGtkString folder(g_path_get_dirname(filename));
         chdir(folder);
-        g_free(folder);
     }
 
-    g_free(filename);
-
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
     event.SetEventObject(dialog);
     dialog->GetEventHandler()->ProcessEvent(event);
@@ -113,7 +110,9 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser,
 {
 #if GTK_CHECK_VERSION(2,4,0)
     GtkWidget *preview = GTK_WIDGET(user_data);
+
     wxGtkString filename(gtk_file_chooser_get_preview_filename(chooser));
+
     if ( !filename )
         return;
 
@@ -305,9 +304,12 @@ void wxFileDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags
 wxString wxFileDialog::GetPath() const
 {
     if (!gtk_check_version(2,4,0))
-        return wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
-    else
-        return wxGenericFileDialog::GetPath();
+    {
+        wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
+        return wxConvFileName->cMB2WX(str);
+    }
+
+    return wxGenericFileDialog::GetPath();
 }
 
 void wxFileDialog::GetFilenames(wxArrayString& files) const
@@ -390,10 +392,12 @@ void wxFileDialog::SetDirectory(const wxString& dir)
 wxString wxFileDialog::GetDirectory() const
 {
     if (!gtk_check_version(2,4,0))
-        return wxConvFileName->cMB2WX(
-            gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(m_widget) ) );
-    else
-        return wxGenericFileDialog::GetDirectory();
+    {
+        wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
+        return wxConvFileName->cMB2WX(str);
+    }
+
+    return wxGenericFileDialog::GetDirectory();
 }
 
 void wxFileDialog::SetFilename(const wxString& name)
@@ -412,8 +416,7 @@ void wxFileDialog::SetFilename(const wxString& name)
 wxString wxFileDialog::GetFilename() const
 {
     if (!gtk_check_version(2,4,0))
-        return wxFileName(
-            wxConvFileName->cMB2WX(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget))) ).GetFullName();
+        return wxFileName(GetPath()).GetFullName();
     else
         return wxGenericFileDialog::GetFilename();
 }