]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixes for file dialog. No longer spits out
authorRobert Roebling <robert@roebling.de>
Sat, 27 Nov 2004 23:18:40 +0000 (23:18 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 27 Nov 2004 23:18:40 +0000 (23:18 +0000)
   GTK error messages.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30799 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/filedlg.h
include/wx/gtk1/filedlg.h
src/gtk/filedlg.cpp
src/gtk1/filedlg.cpp

index 51daa86bfc209194a5b77c6d82605c6e7d9fc06d..31c9992dcec09a7a2bfd7f1b3399c913f8004b19 100644 (file)
@@ -31,6 +31,8 @@ public:
                  const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
                  long style = 0,
                  const wxPoint& pos = wxDefaultPosition);
+                 
+    ~wxFileDialog();
     
     virtual void GetPaths(wxArrayString& paths) const;
     virtual void GetFilenames(wxArrayString& files) const;
@@ -42,8 +44,6 @@ public:
     virtual void SetWildcard(const wxString& wildCard);
     virtual void SetFilterIndex(int filterIndex);
             void UpdateFromDialog();
-            void UpdateDialog();
-            void DoSetPath(const wxString& path);
 private:
     DECLARE_DYNAMIC_CLASS(wxFileDialog)
 };
index 51daa86bfc209194a5b77c6d82605c6e7d9fc06d..31c9992dcec09a7a2bfd7f1b3399c913f8004b19 100644 (file)
@@ -31,6 +31,8 @@ public:
                  const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
                  long style = 0,
                  const wxPoint& pos = wxDefaultPosition);
+                 
+    ~wxFileDialog();
     
     virtual void GetPaths(wxArrayString& paths) const;
     virtual void GetFilenames(wxArrayString& files) const;
@@ -42,8 +44,6 @@ public:
     virtual void SetWildcard(const wxString& wildCard);
     virtual void SetFilterIndex(int filterIndex);
             void UpdateFromDialog();
-            void UpdateDialog();
-            void DoSetPath(const wxString& path);
 private:
     DECLARE_DYNAMIC_CLASS(wxFileDialog)
 };
index fa7e6e81aff372e25050eee6b1849a3768db08bf..04aa374d7967ae63bd0ebf6ed371728389118de8 100644 (file)
@@ -82,7 +82,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
         }
     }
 
-    dialog->DoSetPath(filename);
+    dialog->SetPath(filename);
     dialog->UpdateFromDialog();
     
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
@@ -180,10 +180,9 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
     SetFilterIndex(0);
 }
 
-void wxFileDialog::SetPath(const wxString& path)
+wxFileDialog::~wxFileDialog()
 {
-    DoSetPath(path);
-    UpdateDialog();
+    m_widget = NULL;
 }
 
 void wxFileDialog::GetFilenames(wxArrayString& files) const 
@@ -201,6 +200,7 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
         files[n] = name;
     }
 }
+
 void wxFileDialog::GetPaths(wxArrayString& paths) const 
 {
     paths.Empty(); 
@@ -231,17 +231,56 @@ void wxFileDialog::SetMessage(const wxString& message)
     SetTitle(message);
 }
 
+void wxFileDialog::SetPath(const wxString& path)
+{
+    if (path.empty()) return;
+
+    wxFileName fn(path);
+    m_path = fn.GetFullPath();
+    m_dir = fn.GetPath();
+    m_fileName = fn.GetFullName();
+    
+    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+                                            wxGTK_CONV(m_dir));
+                                            
+    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+                                      wxGTK_CONV(m_path));
+                                      
+    // pre-fill the filename, too:
+    if (GetWindowStyle() & wxSAVE) // Why only then??
+    {
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+                                              wxGTK_CONV(m_fileName));
+    }
+}
+
 void wxFileDialog::SetDirectory(const wxString& dir)
 {
-    wxFileName fn(dir,m_fileName);
-    SetPath(fn.GetFullPath());
+    if (wxDirExists(dir))
+    {
+        m_dir = dir;
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+                                            wxGTK_CONV(m_dir));
+        wxFileName fn(m_dir,m_fileName);
+        m_path = fn.GetFullPath();
+    }
 }
 
 void wxFileDialog::SetFilename(const wxString& name)
 {
     m_fileName = name;
-    wxFileName fn(m_dir,name);
-    SetPath(fn.GetFullPath());
+    wxFileName fn(m_dir,m_fileName);
+    m_path = fn.GetFullPath();
+    
+    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+                                      wxGTK_CONV(m_path));
+
+    // pre-fill the filename, too:
+    if (GetWindowStyle() & wxSAVE) // Why only then??
+    {
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+                                              wxGTK_CONV(m_fileName));
+    }
 }
 
 void wxFileDialog::SetWildcard(const wxString& wildCard)
@@ -334,48 +373,4 @@ void wxFileDialog::UpdateFromDialog()
     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__)
index fa7e6e81aff372e25050eee6b1849a3768db08bf..04aa374d7967ae63bd0ebf6ed371728389118de8 100644 (file)
@@ -82,7 +82,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
         }
     }
 
-    dialog->DoSetPath(filename);
+    dialog->SetPath(filename);
     dialog->UpdateFromDialog();
     
     wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
@@ -180,10 +180,9 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
     SetFilterIndex(0);
 }
 
-void wxFileDialog::SetPath(const wxString& path)
+wxFileDialog::~wxFileDialog()
 {
-    DoSetPath(path);
-    UpdateDialog();
+    m_widget = NULL;
 }
 
 void wxFileDialog::GetFilenames(wxArrayString& files) const 
@@ -201,6 +200,7 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
         files[n] = name;
     }
 }
+
 void wxFileDialog::GetPaths(wxArrayString& paths) const 
 {
     paths.Empty(); 
@@ -231,17 +231,56 @@ void wxFileDialog::SetMessage(const wxString& message)
     SetTitle(message);
 }
 
+void wxFileDialog::SetPath(const wxString& path)
+{
+    if (path.empty()) return;
+
+    wxFileName fn(path);
+    m_path = fn.GetFullPath();
+    m_dir = fn.GetPath();
+    m_fileName = fn.GetFullName();
+    
+    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+                                            wxGTK_CONV(m_dir));
+                                            
+    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+                                      wxGTK_CONV(m_path));
+                                      
+    // pre-fill the filename, too:
+    if (GetWindowStyle() & wxSAVE) // Why only then??
+    {
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+                                              wxGTK_CONV(m_fileName));
+    }
+}
+
 void wxFileDialog::SetDirectory(const wxString& dir)
 {
-    wxFileName fn(dir,m_fileName);
-    SetPath(fn.GetFullPath());
+    if (wxDirExists(dir))
+    {
+        m_dir = dir;
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+                                            wxGTK_CONV(m_dir));
+        wxFileName fn(m_dir,m_fileName);
+        m_path = fn.GetFullPath();
+    }
 }
 
 void wxFileDialog::SetFilename(const wxString& name)
 {
     m_fileName = name;
-    wxFileName fn(m_dir,name);
-    SetPath(fn.GetFullPath());
+    wxFileName fn(m_dir,m_fileName);
+    m_path = fn.GetFullPath();
+    
+    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
+                                      wxGTK_CONV(m_path));
+
+    // pre-fill the filename, too:
+    if (GetWindowStyle() & wxSAVE) // Why only then??
+    {
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
+                                              wxGTK_CONV(m_fileName));
+    }
 }
 
 void wxFileDialog::SetWildcard(const wxString& wildCard)
@@ -334,48 +373,4 @@ void wxFileDialog::UpdateFromDialog()
     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__)