]> git.saurik.com Git - wxWidgets.git/commitdiff
Added use of default file/dir and confirm on overwrite to file selection
authorUnknown (MO) <nobody@localhost>
Mon, 20 Jul 1998 14:59:54 +0000 (14:59 +0000)
committerUnknown (MO) <nobody@localhost>
Mon, 20 Jul 1998 14:59:54 +0000 (14:59 +0000)
dialog

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

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

index 665debbe74734b2b0a7381c9cb08956f2ca5ee7b..9955be184e547dd54944abdf3172e617c826de58 100644 (file)
@@ -29,6 +29,8 @@ class wxFileDialog: public wxDialog
 {
 
   DECLARE_DYNAMIC_CLASS(wxFileDialog)
+
+       friend void gtk_filedialog_ok_callback( GtkWidget *widget, gpointer data );
   
   public:
 
index 665debbe74734b2b0a7381c9cb08956f2ca5ee7b..9955be184e547dd54944abdf3172e617c826de58 100644 (file)
@@ -29,6 +29,8 @@ class wxFileDialog: public wxDialog
 {
 
   DECLARE_DYNAMIC_CLASS(wxFileDialog)
+
+       friend void gtk_filedialog_ok_callback( GtkWidget *widget, gpointer data );
   
   public:
 
index 74798f65f22f04ab0b8f3125d35dda329cbb485d..8f7b97ed89c261ffdf99c9f0e5c0efe394a091c3 100644 (file)
@@ -15,6 +15,7 @@
 #include "wx/filedlg.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
+#include "wx/generic/msgdlgg.h"
 
 //-----------------------------------------------------------------------------
 // wxFileDialog
@@ -24,6 +25,13 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), gpointer data )
 {
   wxFileDialog *dialog = (wxFileDialog*)data;
   wxCommandEvent event(wxEVT_NULL);
+
+  if(dialog->GetStyle()&(wxSAVE|wxOVERWRITE_PROMPT))
+       if(wxFileExists(gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->m_widget) ))) {
+         if(wxMessageBox("File exists. Overwrite?","Confirm",wxYES_NO)!=wxYES)
+               return;
+       }
+
   dialog->OnOk( event );
 };
 
@@ -49,11 +57,18 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
   m_fileName = defaultFileName;
   m_dir = defaultDir;
   m_wildCard = wildCard;
+  m_dialogStyle = style;
   m_filterIndex = 1;
   
   m_widget = gtk_file_selection_new( "File selection" );
   
   GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget);
+
+  m_path.Append(m_dir);
+  if(m_path.Last()!='/') m_path.Append('/');
+  m_path.Append(m_fileName);
+
+  if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path);
   
   gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", 
     GTK_SIGNAL_FUNC(gtk_filedialog_ok_callback), (gpointer*)this );
@@ -65,6 +80,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
 int wxFileDialog::ShowModal(void)
 {
   int ret = wxDialog::ShowModal();
+
   if (ret == wxID_OK)
   {
     m_fileName = gtk_file_selection_get_filename( GTK_FILE_SELECTION(m_widget) );
index 74798f65f22f04ab0b8f3125d35dda329cbb485d..8f7b97ed89c261ffdf99c9f0e5c0efe394a091c3 100644 (file)
@@ -15,6 +15,7 @@
 #include "wx/filedlg.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
+#include "wx/generic/msgdlgg.h"
 
 //-----------------------------------------------------------------------------
 // wxFileDialog
@@ -24,6 +25,13 @@ void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), gpointer data )
 {
   wxFileDialog *dialog = (wxFileDialog*)data;
   wxCommandEvent event(wxEVT_NULL);
+
+  if(dialog->GetStyle()&(wxSAVE|wxOVERWRITE_PROMPT))
+       if(wxFileExists(gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog->m_widget) ))) {
+         if(wxMessageBox("File exists. Overwrite?","Confirm",wxYES_NO)!=wxYES)
+               return;
+       }
+
   dialog->OnOk( event );
 };
 
@@ -49,11 +57,18 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
   m_fileName = defaultFileName;
   m_dir = defaultDir;
   m_wildCard = wildCard;
+  m_dialogStyle = style;
   m_filterIndex = 1;
   
   m_widget = gtk_file_selection_new( "File selection" );
   
   GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget);
+
+  m_path.Append(m_dir);
+  if(m_path.Last()!='/') m_path.Append('/');
+  m_path.Append(m_fileName);
+
+  if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path);
   
   gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", 
     GTK_SIGNAL_FUNC(gtk_filedialog_ok_callback), (gpointer*)this );
@@ -65,6 +80,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
 int wxFileDialog::ShowModal(void)
 {
   int ret = wxDialog::ShowModal();
+
   if (ret == wxID_OK)
   {
     m_fileName = gtk_file_selection_get_filename( GTK_FILE_SELECTION(m_widget) );