]> git.lyx.org Git - lyx.git/commitdiff
Gnomified the FileDialog.
authorBaruch Even <baruch@lyx.org>
Tue, 3 Apr 2001 18:27:12 +0000 (18:27 +0000)
committerBaruch Even <baruch@lyx.org>
Tue, 3 Apr 2001 18:27:12 +0000 (18:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1880 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gnome/ChangeLog
src/frontends/gnome/FileDialog.C [new file with mode: 0644]
src/frontends/gnome/Makefile.am

index 1f3056f5845e68134e451793d93d4a29822aea86..d7869d677cc2f53fa5ddca0ed90e20338b8dd68a 100644 (file)
@@ -1,3 +1,7 @@
+2001-04-03  Baruch Even  <baruch@lyx.org>
+
+       * FileDialog.C: Added file to provide the gnome file dialog.
+
 2001-04-03  John Levon  <moz@compsoc.man.ac.uk>
 
        * Dialogs.C: s/popup/dialog/
 2001-04-03  John Levon  <moz@compsoc.man.ac.uk>
 
        * Dialogs.C: s/popup/dialog/
diff --git a/src/frontends/gnome/FileDialog.C b/src/frontends/gnome/FileDialog.C
new file mode 100644 (file)
index 0000000..466bcef
--- /dev/null
@@ -0,0 +1,126 @@
+// -*- C++ -*-
+/* This file is part of
+ * =================================================
+ * 
+ *          LyX, The Document Processor
+ *          Copyright 1995-2000 The LyX Team.
+ *
+ * ================================================= 
+ *
+ * \author Baruch Even 
+ **/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "FileDialog.h"
+#include "debug.h"
+#include "support/lstrings.h"
+#include <gtk--/fileselection.h>
+#include <gnome--/main.h>
+#include <gtk/gtkbutton.h>
+
+#include <sigc++/signal_system.h>
+
+#include "LyXView.h" // This is only needed while we have the xforms part!
+#include "bufferview_funcs.h"
+// FileDialog::Private
+
+class FileDialog::Private : public SigC::Object {
+public:
+       Private(string const & title);
+
+       void set_modal(bool modal) { modal_ = modal; }
+       void set_complete(const string & pattern) { sel_.complete(pattern); }
+       void set_filename(const string & filename) { sel_.set_filename(filename);}
+
+       string const exec();
+
+       void button_clicked(bool canceled);
+       void ok_clicked()     { button_clicked(false); }
+       void cancel_clicked() { button_clicked(true); }
+       
+private:
+       Gtk::FileSelection sel_;
+       bool modal_;
+       bool canceled_;
+};
+
+FileDialog::Private::Private(string const & title)
+       : sel_(title), modal_(false) 
+{
+       sel_.get_ok_button()->clicked.connect(slot(this, 
+                       &FileDialog::Private::ok_clicked));
+       sel_.get_cancel_button()->clicked.connect(slot(this, 
+                       &FileDialog::Private::cancel_clicked));
+}
+
+string const FileDialog::Private::exec()
+{
+       canceled_ = false;
+       sel_.set_modal(modal_);
+       sel_.show();
+       Gnome::Main::run();
+       // Find if its canceled or oked and return as needed.
+       
+       if (canceled_)
+               return string();
+       else
+               return sel_.get_filename();
+}
+
+void FileDialog::Private::button_clicked(bool canceled)
+{
+       canceled_ = canceled;
+       sel_.hide();
+       Gnome::Main::quit();
+}
+
+// FileDialog
+
+FileDialog::FileDialog(LyXView * lv, string const & title, kb_action a, 
+               Button /*b1*/, Button /*b2*/)
+       : private_(new Private(title))
+       , lv_(lv), title_(title), success_(a)
+{
+               private_->set_modal(LFUN_SELECT_FILE_SYNC == a);
+}
+
+
+FileDialog::~FileDialog()
+{
+       delete private_;
+}
+
+
+FileDialog::Result const 
+FileDialog::Select(string const & path, string const & mask, 
+               string const & suggested)
+{
+       // For some reason we need to ignore the asynchronous method...
+#if 0
+       if (LFUN_SELECT_FILE_SYNC != success_) {
+               lyxerr << "Asynchronous file dialog." << std::endl;
+               private_->show();
+
+               return FileDialog::Result(Later, string());
+       }
+#endif
+       lyxerr << "Synchronous file dialog." << std::endl;
+       
+       lyxerr << "Path: " << path << "\nMask: " << mask << "\nSuggested: " << suggested << std::endl;
+       
+       string filter = mask;
+       rsplit(mask, filter, '|');
+       private_->set_complete(mask);
+       private_->set_filename(path+suggested);
+       
+       ProhibitInput(lv_->view());
+       string const filename = private_->exec();
+       AllowInput(lv_->view());
+
+       // Collect the info and return it for synchronous dialog.
+       return FileDialog::Result(Chosen, filename);
+}
index 1d87c7a93758c5a3a9ceb59bb05922dc832a90f1..c28731921eb1e97faaafd8de33e8cf3af767e896 100644 (file)
@@ -19,10 +19,10 @@ libgnome_la_OBJADD = \
        ../xforms/FormMathsDelim.lo \
        ../xforms/FormMathsMatrix.lo \
        ../xforms/FormMathsPanel.lo \
        ../xforms/FormMathsDelim.lo \
        ../xforms/FormMathsMatrix.lo \
        ../xforms/FormMathsPanel.lo \
-       ../xforms/FormMathsSpace.lo \
-       ../xforms/FileDialog.lo \
-       ../xforms/FormFiledialog.lo \
-       ../xforms/form_filedialog.lo 
+       ../xforms/FormMathsSpace.lo 
+#      ../xforms/FileDialog.lo \
+#      ../xforms/FormFiledialog.lo \
+#      ../xforms/form_filedialog.lo 
 #      ../xforms/Timeout_pimpl.lo \
 #      ../xforms/Color.lo \
 #      ../xforms/FormFiledialog.lo \
 #      ../xforms/Timeout_pimpl.lo \
 #      ../xforms/Color.lo \
 #      ../xforms/FormFiledialog.lo \
@@ -65,12 +65,6 @@ LDFLAGS= $(libgnome_la_OBJADD)
 LYXDATADIRS = 
 #ETAGS_ARGS = --lang=c++
 libgnome_la_SOURCES = \
 LYXDATADIRS = 
 #ETAGS_ARGS = --lang=c++
 libgnome_la_SOURCES = \
-       Dialogs.C \
-       GUIRunTime.C \
-       Menubar_pimpl.C \
-       Menubar_pimpl.h \
-       Timeout_pimpl.C \
-       Timeout_pimpl.h \
        gnomeBC.C \
        gnomeBC.h \
        gnome_helpers.C \
        gnomeBC.C \
        gnomeBC.h \
        gnome_helpers.C \
@@ -80,14 +74,21 @@ libgnome_la_SOURCES = \
        support.c \
        support.h \
        pixbutton.h \
        support.c \
        support.h \
        pixbutton.h \
+       Dialogs.C \
        GnomeBase.C \
        GnomeBase.h \
        GnomeBase.C \
        GnomeBase.h \
+       GUIRunTime.C \
+       FileDialog.C \
        FormCopyright.C \
        FormCopyright.h \
        FormCredits.C \
        FormCredits.h \
        FormUrl.C \
        FormCopyright.C \
        FormCopyright.h \
        FormCredits.C \
        FormCredits.h \
        FormUrl.C \
-       FormUrl.h
+       FormUrl.h \
+       Menubar_pimpl.C \
+       Menubar_pimpl.h \
+       Timeout_pimpl.C \
+       Timeout_pimpl.h
 
 # These still have to be added. Sooner or later. ARRae-20000411
 #      GUI_defaults.C \
 
 # These still have to be added. Sooner or later. ARRae-20000411
 #      GUI_defaults.C \