]> git.lyx.org Git - lyx.git/commitdiff
Applied John's FileDialog patch.
authorJürgen Vigna <jug@sad.it>
Wed, 7 Mar 2001 14:25:31 +0000 (14:25 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 7 Mar 2001 14:25:31 +0000 (14:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1702 a592a061-630c-0410-9148-cb99ea01b6c8

73 files changed:
lib/ChangeLog
lib/bind/cua.bind
lib/bind/de_menus.bind
lib/bind/emacs.bind
lib/bind/fr_menus.bind
lib/bind/hu_menus.bind
lib/bind/pt_menus.bind
lib/bind/sciword.bind
lib/bind/sv_menus.bind
lib/bind/xemacs.bind
lib/images/buffer-open.xpm [deleted file]
lib/images/file-open.xpm [new file with mode: 0644]
lib/ui/default.ui
po/POTFILES.in
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/Makefile.am
src/ToolbarDefaults.C
src/bufferlist.C
src/commandtags.h
src/filedlg.C [deleted file]
src/filedlg.h [deleted file]
src/form1.C
src/form1.h
src/frontends/ChangeLog
src/frontends/FileDialog.h [new file with mode: 0644]
src/frontends/Makefile.am
src/frontends/kde/ChangeLog
src/frontends/kde/Dialogs.C
src/frontends/kde/FileDialog.C [new file with mode: 0644]
src/frontends/kde/FileDialog_private.C [new file with mode: 0644]
src/frontends/kde/FileDialog_private.h [new file with mode: 0644]
src/frontends/kde/FormCitation.h
src/frontends/kde/FormCopyright.h
src/frontends/kde/FormDocument.h
src/frontends/kde/FormIndex.h
src/frontends/kde/FormLog.h
src/frontends/kde/FormParagraph.h
src/frontends/kde/FormPrint.h
src/frontends/kde/FormRef.h
src/frontends/kde/FormTabularCreate.h
src/frontends/kde/FormToc.h
src/frontends/kde/FormUrl.h
src/frontends/kde/FormVCLog.h
src/frontends/kde/Makefile.am
src/frontends/kde/docdlg.C
src/frontends/kde/moc/Makefile.am
src/frontends/xforms/ChangeLog
src/frontends/xforms/FileDialog.C [new file with mode: 0644]
src/frontends/xforms/FormFiledialog.C [new file with mode: 0644]
src/frontends/xforms/FormFiledialog.h [new file with mode: 0644]
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormInclude.C
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/Makefile.am
src/frontends/xforms/Toolbar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.h
src/frontends/xforms/form_filedialog.C [new file with mode: 0644]
src/frontends/xforms/form_filedialog.h [new file with mode: 0644]
src/frontends/xforms/forms/fdfix.sh
src/frontends/xforms/forms/form_filedialog.fd [new file with mode: 0644]
src/frontends/xforms/forms/makefile
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h
src/insets/ChangeLog
src/insets/figinset.C
src/insets/insetexternal.C
src/lyx_cb.C
src/lyx_cb.h
src/lyxfunc.C
src/lyxfunc.h

index d442ed8f12fb92beb9571e62ded9b74ea5ecea70..22222b36bcd082b969646bc01ffc9f8b32d15826 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-06  John Levon  <moz@compsoc.man.ac.uk>
+
+       * ui/default.ui:
+       * bind/<various>: update for file dialog change
+
 2001-03-06  Chanop Silpa-Anan  <chanop@debian.org>
 
        * encodings:
index 113586ac7fc93f67b0dfaa997fa3299b5ef83dfa..9778500cd3e1ae77ecb7c5879edce175eb530a79 100644 (file)
@@ -31,7 +31,7 @@
 
 \bind "C-n"                    "buffer-new"
 \bind "C-S-N"                  "buffer-new-template"
-\bind "C-o"                    "buffer-open"
+\bind "C-o"                    "file-open"
 \bind "C-r"                    "buffer-reload"
 \bind "C-w"                    "buffer-close"
 \bind "C-s"                    "buffer-write"
@@ -77,7 +77,7 @@
 #bind "F1"                     "help"                  # Not yet implemented!
 #bind "C-F1"                   "help-context"          # Not yet implemented!
 \bind "F2"                     "buffer-write"
-\bind "F3"                     "buffer-open"
+\bind "F3"                     "file-open"
 \bind "C-F4"                   "buffer-close"
 \bind "F5"                     "screen-recenter"
 \bind "M-F4"                   "lyx-quit"
index e3c1a5ce033da15bbd46e5c3886324b1f6b65e87..098febedd5d4e0b0df3f9468cccface1fc47a816 100644 (file)
@@ -47,7 +47,7 @@
 #
 #\bind "M-d n"                 "buffer-new"
 #\bind "M-d v"                 "buffer-new-template"
-#\bind "M-d o"                 "buffer-open"
+#\bind "M-d o"                 "file-open"
 #\bind "M-d c"                 "buffer-close"
 #\bind "M-d s"                 "buffer-write"
 #\bind "M-d u"                 "buffer-write-as"
 #\bind "M-e a"                 "figure-insert"
 #\bind "M-e t"                 "table-insert"
 #\bind "M-e d"                 "buffer-child-insert"
-#\bind "M-e c z"                       "file-insert-ascii line"         
-#\bind "M-e c a"                       "file-insert-ascii paragraph"
+#\bind "M-e c z"                       "file-insert-ascii"         
+#\bind "M-e c a"                       "file-insert-ascii-para"
 #\bind "M-e l"                 "file-insert"
 #\bind "M-e f"                 "footnote-insert"
 #\bind "M-e r"                 "marginpar-insert"
index 5b72ee63fa1859389312126440d34cfb9c41ebad..b967d2917861949866de2f09886c996a22243d11 100644 (file)
@@ -91,7 +91,7 @@
 \bind "C-x C-b"                "menu-open documents"
 \bind "C-x C-c"                "lyx-quit"
 \bind "C-x C-d"                "buffer-new"
-\bind "C-x C-f"                "buffer-open"
+\bind "C-x C-f"                "file-open"
 \bind "C-x C-g"                "buffer-view ps"
 \bind "C-x C-p"                "buffer-view dvi"
 \bind "C-x C-q"                "buffer-toggle-read-only"
 #bind "F1"                     "help"                          # Not yet implemented!
 #bind "C-F1"                   "help-context"                  # Not yet implemented!
 #\bind "F2"                     "buffer-write"
-#\bind "F3"                     "buffer-open"
+#\bind "F3"                     "file-open"
 #bind "F4"                     "------"
 #bind "F5"                     "------"
 #bind "F6"                     "------"
index 4fc125a88a7d9b003d1a0a10a78c6bed27d40d30..1ffdd443960b333deada409c6798f637054f92ba 100644 (file)
@@ -29,7 +29,7 @@
 
 #\bind "M-f n"                 "buffer-new"            #Nouveau
 #\bind "M-f m"                 "buffer-new-template"   #... Modèle
-#\bind "M-f o"                 "buffer-open"           #Ouvrir
+#\bind "M-f o"                 "file-open"             #Ouvrir
 #\bind "M-f f"                 "buffer-close"          #Fermer
 #\bind "M-f e"                 "buffer-write"          #Enregistrer
 #\bind "M-f s"                 "buffer-write-as"       #Enregistrer Sous
index 0967ede76067cb1ec0842fa9275d765b97173fab..ef7184102c429e6deb743d309adf9d31c74d49af 100644 (file)
@@ -30,7 +30,7 @@
 #\bind "M-f space"             "menu-open Fájl" 
 #\bind "M-f j"                 "buffer-new"
 #\bind "M-f a"                 "buffer-new-template"
-#\bind "M-f n"                 "buffer-open"
+#\bind "M-f n"                 "file-open"
 #\bind "M-f z"                 "buffer-close"
 #\bind "M-f m"                 "buffer-write"
 #\bind "M-f t"                 "buffer-write-as"
index 2afeb2a3d3c772186e25da79a381aa081c958d4f..3116621dc9849373be6c995a220d005d9608c1d1 100644 (file)
@@ -33,7 +33,7 @@
 
 #\bind "M-a n"                 "buffer-new"
 #\bind "M-a m"                 "buffer-new-template"
-#\bind "M-a a"                 "buffer-open"
+#\bind "M-a a"                 "file-open"
 #\bind "M-a f"                 "buffer-close"
 #\bind "M-a l"                 "buffer-write"
 #\bind "M-a c"                 "buffer-write-as"
 #\bind "M-i g"                 "figure-insert"
 #\bind "M-i b"                 "table-insert"
 #\bind "M-i a"                 "buffer-child-insert"
-#\bind "M-i i l"                       "file-insert-ascii line"         
-#\bind "M-i i p"                       "file-insert-ascii paragraph"
+#\bind "M-i i l"                       "file-insert-ascii"         
+#\bind "M-i i p"                       "file-insert-ascii-para"
 #\bind "M-i x"                 "file-insert"
 #\bind "M-i r"                 "footnote-insert"
 #\bind "M-i m"                 "marginpar-insert"
index 5bb71c2d3b9815a32d0966df9d35168a2fc677cd..e6eafa41d0bd759fb05dbbdf513ecda9fe931f29 100644 (file)
 #\bind "M-f c"                  "buffer-close"
 #\bind "M-f n"                  "buffer-new"
 #\bind "M-f l"                  "file-last"                      # Not yet implemented.
-#\bind "M-f o"                  "buffer-open"
+#\bind "M-f o"                  "file-open"
 #\bind "M-f p"                  "buffer-print"
 #\bind "M-f q"                  "lyx-quit"
 #\bind "M-f r"                  "buffer-update dvi"
index f83e6711223e5c80ec1003202dfd5cf493c40593..edaf1b2e1af780964636b1b0b4d0b8d7523c8b2a 100644 (file)
@@ -39,7 +39,7 @@
 
 #\bind "M-f n"                 "buffer-new"
 #\bind "M-f m"                 "buffer-new-template"
-#\bind "M-f p"                 "buffer-open"
+#\bind "M-f p"                 "file-open"
 #\bind "M-f g"                 "buffer-close"
 #\bind "M-f s"                 "buffer-write"
 #\bind "M-f o"                 "buffer-write-as"
index 3e211275b8ac0b614c9faceff00be5d1ba011915..668d73d2108bfb200b814181dbe44b93021a7d72 100644 (file)
@@ -96,7 +96,7 @@
 \bind "C-x C-b"                "menu-open documents"   # list all buffers
 \bind "C-x C-c"                "lyx-quit"
 \bind "C-x C-d"                "buffer-new"
-\bind "C-x C-f"                "buffer-open"
+\bind "C-x C-f"                "file-open"
 \bind "C-x C-g"                "buffer-view ps"
 \bind "C-x C-l"                        "word-lowcase"          # downcase-region!
 \bind "C-x C-p"                "buffer-view dvi"
 #bind "F1"                     "help"                          # Not yet implemented!
 #bind "C-F1"                   "help-context"                  # Not yet implemented!
 #\bind "F2"                     "buffer-write"
-#\bind "F3"                     "buffer-open"
+#\bind "F3"                     "file-open"
 #bind "F4"                     "------"
 #bind "F5"                     "------"
 #bind "F6"                     "------"
diff --git a/lib/images/buffer-open.xpm b/lib/images/buffer-open.xpm
deleted file mode 100644 (file)
index 90b133a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* XPM */
-static char const * open_xpm[] = {
-"20 20 5 1",
-"      c None",
-".     c navy",
-"X     c #000000000000",
-"o     c #9A9A94949494",
-"O     c #E5E5E0E0E1E1",
-"                    ",
-"              ...   ",
-"             .   . .",
-" XXXXX           . .",
-"XXooooX           ..",
-"XooooooXXXXXXXX ....",
-"XoooooooooooooX     ",
-"XoooooooooooooX     ",
-"XoooooooooooooX     ",
-"XooooXXXXXXXXXXXXXXX",
-"XooooXOOOOOOOOOOOOOX",
-"XoooXOOOOOOOOOOOOOX ",
-"XoooXOOOOOOOOOOOOOX ",
-"XooXOOOOOOOOOOOOOX  ",
-"XooXOOOOOOOOOOOOOX  ",
-"XoXOOOOOOOOOOOOOX   ",
-"XoXOOOOOOOOOOOOOX   ",
-"XXOOOOOOOOOOOOOX    ",
-"XXOOOOOOOOOOOOOX    ",
-"XXXXXXXXXXXXXXX     "};
-
-
diff --git a/lib/images/file-open.xpm b/lib/images/file-open.xpm
new file mode 100644 (file)
index 0000000..90b133a
--- /dev/null
@@ -0,0 +1,30 @@
+/* XPM */
+static char const * open_xpm[] = {
+"20 20 5 1",
+"      c None",
+".     c navy",
+"X     c #000000000000",
+"o     c #9A9A94949494",
+"O     c #E5E5E0E0E1E1",
+"                    ",
+"              ...   ",
+"             .   . .",
+" XXXXX           . .",
+"XXooooX           ..",
+"XooooooXXXXXXXX ....",
+"XoooooooooooooX     ",
+"XoooooooooooooX     ",
+"XoooooooooooooX     ",
+"XooooXXXXXXXXXXXXXXX",
+"XooooXOOOOOOOOOOOOOX",
+"XoooXOOOOOOOOOOOOOX ",
+"XoooXOOOOOOOOOOOOOX ",
+"XooXOOOOOOOOOOOOOX  ",
+"XooXOOOOOOOOOOOOOX  ",
+"XoXOOOOOOOOOOOOOX   ",
+"XoXOOOOOOOOOOOOOX   ",
+"XXOOOOOOOOOOOOOX    ",
+"XXOOOOOOOOOOOOOX    ",
+"XXXXXXXXXXXXXXX     "};
+
+
index 2d7192e6650f2f1afe8743a5c8cf691b116c68b5..50ead52ec34b9714c4b96f1b59aba5532a9adffe 100644 (file)
@@ -28,7 +28,7 @@ Menuset
     Menu "file_nobuffer"
        Item "New...|N" "buffer-new"
        Item "New from Template...|T" "buffer-new-template"
-       Item "Open...|O" "buffer-open"
+       Item "Open...|O" "file-open"
        Separator
        Submenu "Import|I" "file_import"
        Separator
@@ -40,7 +40,7 @@ Menuset
     Menu "file"
        Item "New...|N" "buffer-new"
        Item "New from Template...|T" "buffer-new-template"
-       Item "Open...|O" "buffer-open"
+       Item "Open...|O" "file-open"
        Separator
        Item "Close|C" "buffer-close"
        Item "Save|S" "buffer-write"
@@ -219,8 +219,8 @@ Menuset
 
     Menu "insert_file"
        Item "LyX Document...|X" "file-insert"
-       Item "Ascii as Lines...|L" "file-insert-ascii lines"
-       Item "Ascii as Paragraphs...|P" "file-insert-ascii paragraphs"
+       Item "Ascii as Lines...|L" "file-insert-ascii"
+       Item "Ascii as Paragraphs...|P" "file-insert-ascii-para"
     End
 
 #
@@ -335,7 +335,7 @@ End
 
 Toolbar
     Layouts
-    Icon "buffer-open"
+    Icon "file-open"
     Icon "buffer-write"
     Icon "buffer-print"
     Separator
index 61022eaf3d72cee2e14c716048b0be5f522ac84c..023141b20fcefe8db77f6270d6817b750a4263de 100644 (file)
@@ -13,7 +13,6 @@ src/CutAndPaste.C
 src/debug.C
 src/exporter.C
 src/ext_l10n.h
-src/filedlg.C
 src/FontLoader.C
 src/form1.C
 src/frontends/gnome/FormCitation.C
@@ -43,6 +42,7 @@ src/frontends/kde/dlg/parageneraldlgdata.C
 src/frontends/kde/dlg/printdlgdata.C
 src/frontends/kde/dlg/tabcreatedlgdata.C
 src/frontends/kde/docdlg.C
+src/frontends/kde/FileDialog.C
 src/frontends/kde/FormCitation.C
 src/frontends/kde/FormCopyright.C
 src/frontends/kde/FormDocument.C
@@ -72,6 +72,7 @@ src/frontends/qt2/FormSearch.C
 src/frontends/qt2/FormTabularCreate.C
 src/frontends/qt2/paragraphdlgimpl.C
 src/frontends/qt2/tabularcreatedlgimpl.C
+src/frontends/xforms/FileDialog.C
 src/frontends/xforms/FormBase.h
 src/frontends/xforms/form_bibitem.C
 src/frontends/xforms/FormBibitem.C
@@ -88,6 +89,8 @@ src/frontends/xforms/form_document.C
 src/frontends/xforms/FormDocument.C
 src/frontends/xforms/form_error.C
 src/frontends/xforms/FormError.C
+src/frontends/xforms/form_filedialog.C
+src/frontends/xforms/FormFiledialog.C
 src/frontends/xforms/form_graphics.C
 src/frontends/xforms/FormGraphics.C
 src/frontends/xforms/form_include.C
index ef248328b92528ad33e568298455346b04ace6f2..152a5bf0c590842383515b284ede86b302d4b5a1 100644 (file)
@@ -30,7 +30,7 @@
 #include "insets/insettext.h"
 /// added for Dispatch functions
 #include "lyx_cb.h"
-#include "filedlg.h"
+#include "frontends/FileDialog.h"
 #include "lyx_main.h"
 #include "FloatList.h"
 #include "support/filetools.h"
@@ -1424,7 +1424,6 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
        if (filename.empty()) {
                // Launch a file browser
                string initpath = lyxrc.document_path;
-               LyXFileDlg fileDlg;
 
                if (available()) {
                        string const trypath = owner_->buffer()->filepath;
@@ -1433,21 +1432,24 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
                                initpath = trypath;
                }
 
-               // launches dialog
-               ProhibitInput(bv_);
-               fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-               fileDlg.SetButton(1, _("Examples"), 
-                                 AddPath(system_lyxdir, "examples"));
-               filename = fileDlg.Select(_("Select Document to Insert"),
-                                         initpath, "*.lyx");
-               AllowInput(bv_);
+               FileDialog fileDlg(bv_->owner(), _("Select LyX document to insert"),
+                       LFUN_FILE_INSERT,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
+
+               FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx| LyX Documents (*.lyx)"));
+               if (result.first == FileDialog::Later)
+                       return;
+
+               filename = result.second;
 
                // check selected filename
                if (filename.empty()) {
                        owner_->getMiniBuffer()->Set(_("Canceled."));
                        return;
                }
-       } 
+       }
 
        // get absolute path of file and make sure the filename ends
        // with .lyx
@@ -1618,12 +1620,13 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
        }
        break;
        
+       case LFUN_FILE_INSERT_ASCII_PARA:
+               InsertAsciiFile(bv_, argument, true);
+               break;
+
        case LFUN_FILE_INSERT_ASCII:
-       {
-               bool asPara = (argument == "paragraph");
-               InsertAsciiFile(bv_, string(), asPara);
-       }
-       break;
+               InsertAsciiFile(bv_, argument, false);
+               break;
                
        case LFUN_LAYOUT:
        {
index fd8057f05a07ac2cf5d5503d49d3435b6bc6eec4..e0eb0352e61b77d13252af9fd6baa7e562ec7a51 100644 (file)
@@ -1,3 +1,23 @@
+2001-03-06  John Levon  <moz@compsoc.man.ac.uk>
+
+       * Makefile.am:
+       * filedlg.h:
+       * filedlg.C:
+       * LyXAction.C:
+       * ToolbarDefaults.C:
+       * bufferlist.C:
+       * commandtags.h:
+       * form1.C:
+       * form1.h:
+       * lyx_cb.C:
+       * lyx_cb.h:
+       * lyxfunc.h:
+       * lyxfunc.C:
+       * BufferView_pimpl.C: use new file dialog in GUII
+
+       * lyx_cb.h:
+       * lyx_cb.C: remove LayoutsCB to Toolbar
+
 2001-03-07  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * ShareContainer.h (get): add std:: qualifier
index ee540e3fa87b27f04f2f57ffcc06e7a31d87300a..e2ff7d3b71be497235add2e048e2d39099393d27 100644 (file)
@@ -140,7 +140,6 @@ void LyXAction::init()
                { LFUN_MENUNEW, "buffer-new", N_("New document") , NoBuffer },
                { LFUN_MENUNEWTMPLT,"buffer-new-template",
                  N_("New document from template"), NoBuffer },
-               { LFUN_MENUOPEN, "buffer-open", N_("Open"), NoBuffer },
                { LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
                { LFUN_MENURELOAD, "buffer-reload",
                  N_("Revert to saved"), ReadOnly },
@@ -151,7 +150,7 @@ void LyXAction::init()
                { LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly },
                { LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly },
                { LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
-               { LFUN_MENUWRITEAS, "buffer-write-as", N_("Save As"),
+               { LFUN_WRITEAS, "buffer-write-as", N_("Save As"),
                  ReadOnly },
                { LFUN_CANCEL, "cancel", N_("Cancel"), NoBuffer },
                { LFUN_INSET_CAPTION, "caption-insert", "", Noop },
@@ -197,9 +196,10 @@ void LyXAction::init()
                { LFUN_INSET_GRAPHICS, "graphics-insert",
                  N_("Insert Graphics"), Noop },
                { LFUN_FILE_INSERT, "file-insert", "", Noop },
-               { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", "", Noop },
+               { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
+               { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
                { LFUN_FILE_NEW, "file-new", "", NoBuffer },
-               { LFUN_FILE_OPEN, "file-open", "", NoBuffer },
+               { LFUN_FILE_OPEN, "file-open", _("Open a file"), NoBuffer },
                { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"),
                  ReadOnly },
                { LFUN_INSET_FLOAT, "float-insert", "", Noop },
index e35a6bf7404a76d974452c564cf458c918cc9d76..57a8ffc17567ec40a9df05f178e5ab99139fd2de 100644 (file)
@@ -117,8 +117,6 @@ lyx_SOURCES = \
        exporter.h \
        ext_l10n.h \
        figure.h \
-       filedlg.C \
-       filedlg.h \
        font.C \
        font.h \
        form1.C \
index d92b09e86ffab12c7994dbae20faca5e02804d03..656949e45e2a799d8005b4fdd8a6e21fa55ba49e 100644 (file)
@@ -46,7 +46,7 @@ void ToolbarDefaults::add(int action)
 void ToolbarDefaults::init() 
 {
        add(LAYOUTS);
-       add(LFUN_MENUOPEN);
+       add(LFUN_FILE_OPEN);
        //add(LFUN_CLOSEBUFFER);
        add(LFUN_MENUWRITE);
        add(LFUN_MENUPRINT);
index 3f4477636478f3fe8f20590692be00d5112c1ee7..900cda89df1e83e0f54fa21973876850ffe973d3 100644 (file)
@@ -113,7 +113,7 @@ bool BufferList::QwriteAll()
                                                       _("Save document?"))) {
                                case 1: // Yes
                                        if ((*it)->isUnnamed())
-                                               reask = !MenuWriteAs(current_view, (*it));
+                                               reask = !WriteAs(current_view, (*it));
                                        else {
                                                reask = !MenuWrite(current_view, (*it));
                                        }
@@ -189,7 +189,7 @@ bool BufferList::close(Buffer * buf)
                                               _("Save document?"))){
                        case 1: // Yes
                                if (buf->isUnnamed())
-                                       reask = !MenuWriteAs(current_view, buf);
+                                       reask = !WriteAs(current_view, buf);
                                else if (buf->save()) {
                                        lastfiles->newFile(buf->fileName());
                                        reask = false;
index e5c81a2a2bec808a0f5312efaab41fdac9754f87..308ae4f6ca143d0f6828a83af3a739cdb80cf10d 100644 (file)
     Please add new functions at the end of the enum, right
     before LFUN_LASTACTION.
  */
+
 enum kb_action {
        LFUN_UNKNOWN_ACTION = -1,
        LFUN_NOACTION = 0,
        LFUN_PREFIX,
        LFUN_CENTER,
        LFUN_MENUNEW,
-       LFUN_MENUOPEN,
        LFUN_MENUWRITE,
-       LFUN_MENUWRITEAS,
+       LFUN_WRITEAS,
        LFUN_MENUPRINT,
        LFUN_MENUSENDTO,
         LFUN_BUILDPROG,
@@ -177,6 +177,7 @@ enum kb_action {
        LFUN_EXEC_COMMAND,
        LFUN_FILE_INSERT,
        LFUN_FILE_INSERT_ASCII,         // CFO-G 1997-11-19
+       LFUN_FILE_INSERT_ASCII_PARA,    // Levon 2001-02-14
        LFUN_FILE_NEW,
        LFUN_FILE_OPEN,  // 160
        LFUN_UP_PARAGRAPH,              // Asger 1996-10-01
@@ -274,6 +275,7 @@ enum kb_action {
        LFUN_BOOKMARK_SAVE,              // Dekel 20010127
        LFUN_BOOKMARK_GOTO,              // Dekel 20010127
        LFUN_CHILD_CREATE,              // Levon 20010207
+       LFUN_SELECT_FILE_SYNC,          // Levon 20010214
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
diff --git a/src/filedlg.C b/src/filedlg.C
deleted file mode 100644 (file)
index 2b69490..0000000
+++ /dev/null
@@ -1,769 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *        
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
- *
- * ====================================================== */
-
-#include <config.h>
-
-#include <unistd.h>
-#include <cstdlib>
-#include <pwd.h>
-#include <grp.h>
-#include <cstring>
-#include <map>
-#include <algorithm>
-
-using std::map;
-using std::max;
-using std::sort;
-
-#include "lyx_gui_misc.h" // CancelCloseCB
-#include "support/FileInfo.h"
-#include "support/lyxlib.h"
-#include "gettext.h"
-#include "frontends/Dialogs.h"
-
-#ifdef HAVE_ERRNO_H
-#include <cerrno>
-#endif
-
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <ctime>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <ctime>
-# endif
-#endif
-
-#ifdef BROKEN_HEADERS
-extern "C" int gettimeofday(struct timeval *, struct timezone *);
-#endif
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "support/filetools.h"
-#include "filedlg.h"
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
-// six months, in seconds
-static const long SIX_MONTH_SEC = 6L * 30L * 24L * 60L * 60L;
-static const long ONE_HOUR_SEC = 60L * 60L;
-
-// *** User cache class implementation
-/// User cache class definition
-class UserCache {
-public:
-       /// seeks user name from group ID
-       string const & find(uid_t ID) const {
-               Users::const_iterator cit = users.find(ID);
-               if (cit == users.end()) {
-                       add(ID);
-                       return users[ID];
-               }
-               return (*cit).second;
-       }
-private:
-       ///
-       void add(uid_t ID) const;
-       ///
-       typedef map<uid_t, string> Users;
-       ///
-       mutable Users users;
-};
-
-
-void UserCache::add(uid_t ID) const 
-{
-       string pszNewName;
-       struct passwd * pEntry;
-       
-       // gets user name
-       if ((pEntry = getpwuid(ID)))
-               pszNewName = pEntry->pw_name;
-       else {
-               pszNewName = tostr(ID);
-       }
-       
-       // adds new node
-       users[ID] = pszNewName;
-}      
-
-
-/// Group cache class definition
-class GroupCache {
-public:
-       /// seeks group name from group ID
-       string const & find(gid_t ID) const ;
-private:
-       ///
-       void add(gid_t ID) const;
-       ///
-       typedef map<gid_t, string> Groups;
-       ///
-       mutable Groups groups;
-};
-
-
-string const & GroupCache::find(gid_t ID) const 
-{
-       Groups::const_iterator cit = groups.find(ID);
-       if (cit == groups.end()) {
-               add(ID);
-               return groups[ID];
-       }
-       return (*cit).second;
-}
-
-
-void GroupCache::add(gid_t ID) const 
-{
-       string pszNewName;
-       struct group * pEntry;
-       
-       // gets user name
-       if ((pEntry = getgrgid(ID))) pszNewName = pEntry->gr_name;
-       else {
-               pszNewName = tostr(ID);
-       }
-       // adds new node
-       groups[ID] = pszNewName;
-}
-
-
-// static instances
-static UserCache lyxUserCache;
-static GroupCache lyxGroupCache;
-
-
-// some "C" wrappers around callbacks
-extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT *, long lArgument);
-extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT *, long);
-extern "C" int C_LyXFileDlg_CancelCB(FL_FORM *, void *);
-
-
-// compares two LyXDirEntry objects content (used for sort)
-class comp_direntry {
-public:
-       int operator()(LyXDirEntry const & r1,
-                      LyXDirEntry const & r2) const ;
-};
-       int comp_direntry::operator()(LyXDirEntry const & r1,
-                      LyXDirEntry const & r2) const {
-               bool r1d = suffixIs(r1.pszName, '/');
-               bool r2d = suffixIs(r2.pszName, '/');
-               if (r1d && !r2d) return 1;
-               if (!r1d && r2d) return 0;
-               return r1.pszName < r2.pszName;
-       }
-
-
-// *** LyXFileDlg class implementation
-
-// static members
-FD_FileDlg * LyXFileDlg::pFileDlgForm = 0;
-LyXFileDlg * LyXFileDlg::pCurrentDlg = 0;
-
-
-// Reread: updates dialog list to match class directory
-void LyXFileDlg::Reread()
-{
-       // Opens directory
-       DIR * pDirectory = ::opendir(pszDirectory.c_str());
-       if (!pDirectory) {
-               WriteFSAlert(_("Warning! Couldn't open directory."), 
-                            pszDirectory);
-               pszDirectory = lyx::getcwd();
-               pDirectory = ::opendir(pszDirectory.c_str());
-       }
-
-       // Clear the present namelist
-       direntries.clear();
-
-       // Updates display
-       fl_hide_object(pFileDlgForm->List);
-       fl_clear_browser(pFileDlgForm->List);
-       fl_set_input(pFileDlgForm->DirBox, pszDirectory.c_str());
-
-       // Splits complete directory name into directories and compute depth
-       iDepth = 0;
-       string line, Temp;
-       char szMode[15];
-       FileInfo fileInfo;
-       string File = pszDirectory;
-       if (File != "/") {
-               File = split(File, Temp, '/');
-       }
-       while (!File.empty() || !Temp.empty()) {
-               string dline = "@b"+line + Temp + '/';          
-               fl_add_browser_line(pFileDlgForm->List, dline.c_str());
-               File = split(File, Temp, '/');
-               line += ' ';
-               ++iDepth;
-       }
-
-       // Parses all entries of the given subdirectory
-       time_t curTime = time(0);
-       rewinddir(pDirectory);
-       struct dirent * pDirEntry;
-       while ((pDirEntry = readdir(pDirectory))) {
-               bool isLink = false, isDir = false;
-
-               // If the pattern doesn't start with a dot, skip hidden files
-               if (!pszMask.empty() && pszMask[0] != '.' && 
-                   pDirEntry->d_name[0] == '.')
-                        continue;
-
-               // Gets filename
-               string fname = pDirEntry->d_name;
-
-               // Under all circumstances, "." and ".." are not wanted
-               if (fname == "." || fname == "..")
-                       continue;
-
-               // gets file status
-               File = AddName(pszDirectory, fname);
-
-               fileInfo.newFile(File, true);
-               fileInfo.modeString(szMode);
-               unsigned int nlink = fileInfo.getNumberOfLinks();
-               string user =   lyxUserCache.find(fileInfo.getUid());
-               string group = lyxGroupCache.find(fileInfo.getGid());
-
-               time_t modtime = fileInfo.getModificationTime();
-               string Time = ctime(&modtime);
-               
-               if (curTime > fileInfo.getModificationTime() + SIX_MONTH_SEC
-                   || curTime < fileInfo.getModificationTime()
-                   + ONE_HOUR_SEC) {
-                       // The file is fairly old or in the future. POSIX says
-                       // the cutoff is 6 months old. Allow a 1 hour slop
-                       // factor for what is considered "the future", to
-                       // allow for NFS server/client clock disagreement.
-                       // Show the year instead of the time of day.
-                       Time.erase(10, 9);
-                       Time.erase(15, string::npos);
-               } else {
-                       Time.erase(16, string::npos);
-               }
-
-               string Buffer = string(szMode) + ' ' +
-                       tostr(nlink) + ' ' +
-                       user + ' ' +
-                       group + ' ' +
-                       Time.substr(4, string::npos) + ' ';
-
-               Buffer += pDirEntry->d_name;
-               Buffer += fileInfo.typeIndicator();
-
-               if ((isLink = fileInfo.isLink())) {
-                       string Link;
-
-                       if (LyXReadLink(File, Link)) {
-                               Buffer += " -> ";
-                               Buffer += Link;
-
-                               // This gives the FileType of the file that
-                               // is really pointed too after resolving all
-                               // symlinks. This is not necessarily the same
-                               // as the type of Link (which could again be a
-                               // link). Is that intended?
-                               //                              JV 199902
-                               fileInfo.newFile(File);
-                               Buffer += fileInfo.typeIndicator();
-                       }
-               }
-
-               // filters files according to pattern and type
-               if (fileInfo.isRegular()
-                   || fileInfo.isChar()
-                   || fileInfo.isBlock()
-                   || fileInfo.isFifo()) {
-                       if (!regexMatch(fname, pszMask))
-                               continue;
-               } else if (!(isDir = fileInfo.isDir()))
-                       continue;
-
-               LyXDirEntry tmp;
-
-               // Note pszLsEntry is an string!
-               tmp.pszLsEntry = Buffer;
-               // creates used name
-               string temp = fname;
-               if (isDir) temp += '/';
-
-               tmp.pszName = temp;
-               // creates displayed name
-               temp = pDirEntry->d_name;
-               if (isLink)
-                       temp += '@';
-               else
-                       temp += fileInfo.typeIndicator();
-               tmp.pszDisplayed = temp;
-
-               direntries.push_back(tmp);
-       }
-
-       closedir(pDirectory);
-
-       // Sort the names
-       sort(direntries.begin(), direntries.end(), comp_direntry());
-       
-       // Add them to directory box
-       for (DirEntries::const_iterator cit = direntries.begin();
-            cit != direntries.end(); ++cit) {
-               string const temp = line + (*cit).pszDisplayed;
-               fl_add_browser_line(pFileDlgForm->List, temp.c_str());
-       }
-       fl_set_browser_topline(pFileDlgForm->List, iDepth);
-       fl_show_object(pFileDlgForm->List);
-       iLastSel = -1;
-}
-
-
-// SetDirectory: sets dialog current directory
-void LyXFileDlg::SetDirectory(string const & Path)
-{
-       if (!pszDirectory.empty()) {
-               string TempPath = ExpandPath(Path); // Expand ~/
-               TempPath = MakeAbsPath(TempPath, pszDirectory);
-               pszDirectory = MakeAbsPath(TempPath);
-       } else pszDirectory = MakeAbsPath(Path);
-}
-
-
-// SetMask: sets dialog file mask
-void LyXFileDlg::SetMask(string const & NewMask)
-{
-       pszMask = NewMask;
-       fl_set_input(pFileDlgForm->PatBox, pszMask.c_str());
-}
-
-
-// SetInfoLine: sets dialog information line
-void LyXFileDlg::SetInfoLine(string const & Line)
-{
-       pszInfoLine = Line;
-       fl_set_object_label(pFileDlgForm->FileInfo, pszInfoLine.c_str());
-}
-
-
-LyXFileDlg::LyXFileDlg()
-{
-       pszDirectory = MakeAbsPath(string("."));
-       pszMask = '*';
-
-       // Creates form if necessary. 
-       if (!pFileDlgForm) {
-               pFileDlgForm = create_form_FileDlg();
-               // Set callbacks. This means that we don't need a patch file
-               fl_set_object_callback(pFileDlgForm->DirBox,
-                                      C_LyXFileDlg_FileDlgCB, 0);
-               fl_set_object_callback(pFileDlgForm->PatBox,
-                                      C_LyXFileDlg_FileDlgCB, 1);
-               fl_set_object_callback(pFileDlgForm->List,
-                                      C_LyXFileDlg_FileDlgCB, 2);
-               fl_set_object_callback(pFileDlgForm->Filename,
-                                      C_LyXFileDlg_FileDlgCB, 3);
-               fl_set_object_callback(pFileDlgForm->Rescan,
-                                      C_LyXFileDlg_FileDlgCB, 10);
-               fl_set_object_callback(pFileDlgForm->Home,
-                                      C_LyXFileDlg_FileDlgCB, 11);
-               fl_set_object_callback(pFileDlgForm->User1,
-                                      C_LyXFileDlg_FileDlgCB, 12);
-               fl_set_object_callback(pFileDlgForm->User2,
-                                      C_LyXFileDlg_FileDlgCB, 13);
-               
-               // Make sure pressing the close box doesn't crash LyX. (RvdK)
-               fl_set_form_atclose(pFileDlgForm->FileDlg, 
-                                   C_LyXFileDlg_CancelCB, 0);
-               // Register doubleclick callback
-               fl_set_browser_dblclick_callback(pFileDlgForm->List,
-                                                C_LyXFileDlg_DoubleClickCB,
-                                                0);
-       }
-       fl_hide_object(pFileDlgForm->User1);
-       fl_hide_object(pFileDlgForm->User2);
-
-       r_ = Dialogs::redrawGUI.connect(slot(this, &LyXFileDlg::redraw));
-}
-
-
-LyXFileDlg::~LyXFileDlg()
-{
-       r_.disconnect();
-}
-
-
-void LyXFileDlg::redraw()
-{
-       if (pFileDlgForm->FileDlg && pFileDlgForm->FileDlg->visible)
-               fl_redraw_form(pFileDlgForm->FileDlg);
-}
-
-
-// SetButton: sets file selector user button action
-void LyXFileDlg::SetButton(int iIndex, string const & pszName, 
-                          string const & pszPath)
-{
-       FL_OBJECT * pObject;
-       string * pTemp;
-
-       if (iIndex == 0) {
-               pObject = pFileDlgForm->User1;
-               pTemp = &pszUserPath1;
-       } else if (iIndex == 1) {                       
-               pObject = pFileDlgForm->User2;
-               pTemp = &pszUserPath2;
-       } else return;
-
-       if (!pszName.empty() && !pszPath.empty()) {
-               fl_set_object_label(pObject, pszName.c_str());
-               fl_show_object(pObject);
-               *pTemp = pszPath;
-       } else {
-               fl_hide_object(pObject);
-               (*pTemp).erase();
-       }
-}
-
-
-// GetDirectory: gets last dialog directory
-string const LyXFileDlg::GetDirectory() const
-{
-       if (!pszDirectory.empty())
-               return pszDirectory;
-       else
-               return string(".");
-}
-
-
-// RunDialog: handle dialog during file selection
-bool LyXFileDlg::RunDialog()
-{
-       force_cancel = false;
-       force_ok = false;
-       
-        // event loop
-        while(true) {
-                FL_OBJECT * pObject = fl_do_forms();
-
-                if (pObject == pFileDlgForm->Ready) {
-                       if (HandleOK())
-                               return true;
-               } else if (pObject == pFileDlgForm->Cancel 
-                          || force_cancel) 
-                       return false;
-               else if (force_ok)
-                       return true;
-       }
-}
-
-
-// XForms objects callback (static)
-void LyXFileDlg::FileDlgCB(FL_OBJECT *, long lArgument)
-{
-       if (!pCurrentDlg) return;
-
-       switch (lArgument) {
-
-       case 0: // get directory
-               pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
-               pCurrentDlg->Reread();
-               break;
-
-       case 1: // get mask
-               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
-               pCurrentDlg->Reread();
-               break;
-
-       case 2: // list
-               pCurrentDlg->HandleListHit();
-               break;  
-
-       case 10: // rescan
-               pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
-               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
-               pCurrentDlg->Reread();
-               break;
-
-       case 11: // home
-               pCurrentDlg->SetDirectory(GetEnvPath("HOME"));
-               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
-               pCurrentDlg->Reread();
-               break;
-
-       case 12: // user button 1
-               if (!pCurrentDlg->pszUserPath1.empty()) {
-                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1);
-                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
-                                                         ->PatBox));
-                       pCurrentDlg->Reread();
-               }
-               break;
-
-       case 13: // user button 2
-               if (!pCurrentDlg->pszUserPath2.empty()) {
-                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2);
-                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
-                                                         ->PatBox));
-                       pCurrentDlg->Reread();
-               }
-               break;
-
-       }
-}
-
-
-extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data) 
-{
-       LyXFileDlg::FileDlgCB(ob, data);
-}
-
-
-// Handle callback from list
-void LyXFileDlg::HandleListHit()
-{
-       // set info line
-       int const iSelect = fl_get_browser(pFileDlgForm->List);
-       if (iSelect > iDepth)  {
-               SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
-       } else {
-               SetInfoLine(string());
-       }
-}
-
-
-// Callback for double click in list
-void LyXFileDlg::DoubleClickCB(FL_OBJECT *, long)
-{
-       if (pCurrentDlg->HandleDoubleClick())
-               // Simulate click on OK button
-               pCurrentDlg->Force(false);
-}
-
-
-extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
-{
-       LyXFileDlg::DoubleClickCB(ob, data);
-}
-
-
-// Handle double click from list
-bool LyXFileDlg::HandleDoubleClick()
-{
-       string pszTemp;
-
-       // set info line
-       bool isDir = true;
-       int const iSelect = fl_get_browser(pFileDlgForm->List);
-       if (iSelect > iDepth)  {
-               pszTemp = direntries[iSelect - iDepth - 1].pszName;
-               SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
-               if (!suffixIs(pszTemp, '/')) {
-                       isDir = false;
-                       fl_set_input(pFileDlgForm->Filename, pszTemp.c_str());
-               }
-       } else if (iSelect != 0) {
-               SetInfoLine(string());
-       } else
-               return true;
-
-       // executes action
-       if (isDir) {
-               string Temp;
-
-               // builds new directory name
-               if (iSelect > iDepth) {
-                       // Directory deeper down
-                       // First, get directory with trailing /
-                       Temp = fl_get_input(pFileDlgForm->DirBox);
-                       if (!suffixIs(Temp, '/'))
-                               Temp += '/';
-                       Temp += pszTemp;
-               } else {
-                       // Directory higher up
-                       Temp.erase();
-                       for (int i = 0; i < iSelect; ++i) {
-                               string piece = fl_get_browser_line(pFileDlgForm->List, i+1);
-                               // The '+2' is here to count the '@b' (JMarc)
-                               Temp += piece.substr(i + 2);
-                       }
-               }
-
-               // assigns it
-               SetDirectory(Temp);
-               Reread();
-               return false;
-       }
-       return true;
-}
-
-
-// Handle OK button call
-bool LyXFileDlg::HandleOK()
-{
-       // mask was changed
-       string pszTemp = fl_get_input(pFileDlgForm->PatBox);
-       if (pszTemp != pszMask) {
-               SetMask(pszTemp);
-               Reread();
-               return false;
-       }
-
-       // directory was changed
-       pszTemp = fl_get_input(pFileDlgForm->DirBox);
-       if (pszTemp!= pszDirectory) {
-               SetDirectory(pszTemp);
-               Reread();
-               return false;
-       }
-       
-       // Handle return from list
-       int const select = fl_get_browser(pFileDlgForm->List);
-       if (select > iDepth) {
-               string const temp = direntries[select - iDepth - 1].pszName;
-               if (!suffixIs(temp, '/')) {
-                       // If user didn't type anything, use browser
-                       string const name =
-                               fl_get_input(pFileDlgForm->Filename);
-                       if (name.empty()) {
-                               fl_set_input(pFileDlgForm->Filename, temp.c_str());
-                       }
-                       return true;
-               }
-       }
-
-       // Emulate a doubleclick
-       return HandleDoubleClick();
-}
-
-
-// Handle Cancel CB from WM close
-int LyXFileDlg::CancelCB(FL_FORM *, void *)
-{
-       // Simulate a click on the cancel button
-       pCurrentDlg->Force(true);
-       return FL_IGNORE;
-}
-
-
-extern "C" int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev)
-{
-       return LyXFileDlg::CancelCB(fl, xev);
-}
-
-
-// Simulates a click on OK/Cancel
-void LyXFileDlg::Force(bool cancel)
-{
-       if (cancel) {
-               force_cancel = true;
-               fl_set_button(pFileDlgForm->Cancel, 1);
-       } else {
-               force_ok = true;
-               fl_set_button(pFileDlgForm->Ready, 1);
-       }
-       // Start timer to break fl_do_forms loop soon
-       fl_set_timer(pFileDlgForm->timer, 0.1);
-}
-
-
-// Select: launches dialog and returns selected file
-string const LyXFileDlg::Select(string const & title, string const & path, 
-                               string const & mask, string const & suggested)
-{
-       // handles new mask and path
-       bool isOk = true;
-       if (!mask.empty()) {
-               SetMask(mask);
-               isOk = false;
-       }
-       if (!path.empty()) {
-               SetDirectory(path);
-               isOk = false;
-       }
-       if (!isOk) Reread();
-
-       // highlight the suggested file in the browser, if it exists.
-       int sel = 0;
-       string const filename = OnlyFilename(suggested);
-       if (!filename.empty()) {
-               for (int i = 0; 
-                    i < fl_get_browser_maxline(pFileDlgForm->List); ++i) {
-                       string s =
-                               fl_get_browser_line(pFileDlgForm->List, i + 1);
-                       s = strip(frontStrip(s));
-                       if (s == filename) {
-                               sel = i + 1;
-                               break;
-                       }
-               }
-       }
-       
-       if (sel != 0) fl_select_browser_line(pFileDlgForm->List, sel);
-       int const top = max(sel - 5, 1);
-       fl_set_browser_topline(pFileDlgForm->List, top);
-
-       // checks whether dialog can be started
-       if (pCurrentDlg) return string();
-       pCurrentDlg = this;
-
-       // runs dialog
-       SetInfoLine(string());
-       fl_set_input(pFileDlgForm->Filename, suggested.c_str());
-       fl_set_button(pFileDlgForm->Cancel, 0);
-       fl_set_button(pFileDlgForm->Ready, 0);
-       fl_set_focus_object(pFileDlgForm->FileDlg, pFileDlgForm->Filename);
-       fl_deactivate_all_forms();
-       fl_show_form(pFileDlgForm->FileDlg, 
-                    FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
-                    title.c_str());
-
-       isOk = RunDialog();
-       
-       fl_hide_form(pFileDlgForm->FileDlg);
-       fl_activate_all_forms();
-       pCurrentDlg = 0;
-
-       // Returns filename or string() if no valid selection was made
-       if (!isOk || !fl_get_input(pFileDlgForm->Filename)[0]) return string();
-
-       pszFileName = fl_get_input(pFileDlgForm->Filename);
-
-       if (!AbsolutePath(pszFileName)) {
-               pszFileName = AddName(fl_get_input(pFileDlgForm->DirBox), 
-                                     pszFileName);
-       }
-       return pszFileName;
-}
diff --git a/src/filedlg.h b/src/filedlg.h
deleted file mode 100644 (file)
index 2633d70..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *        
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
- *
- * ====================================================== */
-
-#ifndef FILEDLG_H
-#define FILEDLG_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <vector>
-#include <sigc++/signal_system.h>
-
-#include "LString.h"
-#include FORMS_H_LOCATION
-#include "form1.h"
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::Object;
-using SigC::Connection;
-#endif
-
-/// LyXDirEntry internal structure definition
-class LyXDirEntry {
-public:
-       ///
-       string pszName;
-       ///
-       string pszDisplayed;
-       ///
-       string pszLsEntry;
-};
-
-
-/// FileDlg class definition
-class LyXFileDlg : public Object
-{
-public:
-       ///
-       LyXFileDlg();
-       ///
-       ~LyXFileDlg();
-
-       /// sets file selector user button action
-       void SetButton(int iIndex, string const & pszName = string(), 
-                      string const & pszPath = string());
-       /// gets last dialog directory
-       string const GetDirectory() const;
-       /// launches dialog and returns selected file
-       string const Select(string const & pszTitle = string(),
-                      string const & pszPath = string(),
-                      string const & pszMask = string(), 
-                      string const & pszSuggested = string());
-       /// XForms objects callback (static)
-       static void FileDlgCB(FL_OBJECT *, long);
-       /// Callback for double click in list
-       static void DoubleClickCB(FL_OBJECT *, long);
-       /// Handle Cancel CB from WM close
-       static int CancelCB(FL_FORM *, void *);
-private:
-       /// data
-       static FD_FileDlg * pFileDlgForm;
-       ///
-       static LyXFileDlg * pCurrentDlg;
-       ///
-       string pszUserPath1;
-       ///
-       string pszUserPath2;
-       ///
-       string pszDirectory;
-       ///
-       string pszMask;
-       ///
-       string pszFileName;
-       ///
-       int iDepth;
-       ///
-       int iLastSel;
-       ///
-       long lLastTime;
-       ///
-       string pszInfoLine;
-       ///
-       typedef std::vector<LyXDirEntry> DirEntries;
-       ///
-       DirEntries direntries;
-       ///
-       bool force_cancel;
-       ///
-       bool force_ok;
-
-       /** Redraw the form (on receipt of a Signal indicating, for example,
-           that the xform colors have been re-mapped).
-       */
-       void redraw();
-       /// updates dialog list to match class directory
-       void Reread();
-       /// sets dialog current directory
-       void SetDirectory(string const & pszPath);
-       /// sets dialog file mask
-       void SetMask(string const & pszNewMask);
-       /// sets dialog information line
-       void SetInfoLine(string const & pszLine);
-       /// handle dialog during file selection
-       bool RunDialog();
-       /// Handle callback from list
-       void HandleListHit();
-       /// Handle double click from list
-       bool HandleDoubleClick();
-       /// Handle OK button call
-       bool HandleOK();
-       /// Simulates a click on OK/Cancel
-       void Force(bool);
-       /// Redraw connection.
-       Connection r_;
-};
-
-#endif
index e05c8885755be89fc6efb9bb83bbe9291edc545f..55194284a99451772befa2462c952e16d8181cd6 100644 (file)
@@ -217,60 +217,3 @@ FD_Figure *create_form_Figure(void)
   return fdui;
 }
 /*---------------------------------------*/
-
-FD_FileDlg *create_form_FileDlg(void)
-{
-  FL_OBJECT *obj;
-  FD_FileDlg *fdui = (FD_FileDlg *) fl_calloc(1, sizeof(FD_FileDlg));
-
-  fdui->FileDlg = fl_bgn_form(FL_NO_BOX, 440, 380);
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 440, 380, "");
-  fdui->FileInfo = obj = fl_add_text(FL_NORMAL_TEXT, 10, 260, 420, 30, "");
-    fl_set_object_boxtype(obj, FL_SHADOW_BOX);
-    fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
-    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
-    fl_set_object_resize(obj, FL_RESIZE_X);
-  fdui->DirBox = obj = fl_add_input(FL_NORMAL_INPUT, 100, 10, 330, 30, idex(_("Directory:|#D")));fl_set_button_shortcut(obj, scex(_("Directory:|#D")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
-    fl_set_object_resize(obj, FL_RESIZE_X);
-  fdui->PatBox = obj = fl_add_input(FL_NORMAL_INPUT, 100, 40, 330, 30, idex(_("Pattern:|#P")));fl_set_button_shortcut(obj, scex(_("Pattern:|#P")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
-    fl_set_object_resize(obj, FL_RESIZE_X);
-  fdui->List = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 80, 320, 170, "");
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_lalign(obj, FL_ALIGN_TOP);
-    fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
-  fdui->Filename = obj = fl_add_input(FL_NORMAL_INPUT, 100, 300, 330, 30, idex(_("Filename:|#F")));fl_set_button_shortcut(obj, scex(_("Filename:|#F")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
-    fl_set_object_resize(obj, FL_RESIZE_X);
-  fdui->Rescan = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 80, 90, 30, idex(_("Rescan|#R#r")));fl_set_button_shortcut(obj, scex(_("Rescan|#R#r")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-  fdui->Home = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 120, 90, 30, idex(_("Home|#H#h")));fl_set_button_shortcut(obj, scex(_("Home|#H#h")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-  fdui->User1 = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 160, 90, 30, idex(_("User1|#1")));fl_set_button_shortcut(obj, scex(_("User1|#1")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-  fdui->User2 = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 200, 90, 30, idex(_("User2|#2")));fl_set_button_shortcut(obj, scex(_("User2|#2")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-  fdui->Ready = obj = fl_add_button(FL_RETURN_BUTTON, 220, 340, 100, 30, _("OK"));
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-  fdui->Cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 330, 340, 100, 30, idex(_("Cancel|^[")));fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
-    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-  fdui->timer = obj = fl_add_timer(FL_HIDDEN_TIMER, 10, 350, 20, 20, "");
-    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
-  fl_end_form();
-
-  fdui->FileDlg->fdui = fdui;
-
-  return fdui;
-}
-/*---------------------------------------*/
-
index ed1ecd820c32558b826cc2906cf73c396681640c..b713abc5f98d96db7b99f43662c35809901a724d 100644 (file)
@@ -67,26 +67,6 @@ typedef struct {
 } FD_Figure;
 
 extern FD_Figure * create_form_Figure(void);
-typedef struct {
-       FL_FORM *FileDlg;
-       void *vdata;
-       char *cdata;
-       long  ldata;
-       FL_OBJECT *FileInfo;
-       FL_OBJECT *DirBox;
-       FL_OBJECT *PatBox;
-       FL_OBJECT *List;
-       FL_OBJECT *Filename;
-       FL_OBJECT *Rescan;
-       FL_OBJECT *Home;
-       FL_OBJECT *User1;
-       FL_OBJECT *User2;
-       FL_OBJECT *Ready;
-       FL_OBJECT *Cancel;
-       FL_OBJECT *timer;
-} FD_FileDlg;
-
-extern FD_FileDlg * create_form_FileDlg(void);
 typedef struct {
        FL_FORM *form_search;
        void *vdata;
index 910130f8c7773ce5a0d6d3f1235e422450a0beb1..b5d61f7184147f49d12f12330c9da9c3c9cfc938 100644 (file)
@@ -1,3 +1,8 @@
+2001-02-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * Makefile.am
+       * FileDialog.h: new GUII FileDialog
+
 2001-02-23  Edwin Leuven <leuven@fee.uva.nl)
 
        * Dialogs.h: setUserFreeFont, showLayoutCharacter
diff --git a/src/frontends/FileDialog.h b/src/frontends/FileDialog.h
new file mode 100644 (file)
index 0000000..7ed87a9
--- /dev/null
@@ -0,0 +1,96 @@
+/**
+ * \file FileDialog.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon
+ */
+
+#ifndef FILEDIALOG_H
+#define FILEDIALOG_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <config.h>
+#include <utility>
+
+#include "commandtags.h"
+
+#include "LString.h"
+
+class LyXView;
+
+/**
+ * \class FileDialog
+ * \brief GUI-I definition of file dialog interface
+ */
+class FileDialog
+{
+public:
+       /// label, directory path button
+       typedef std::pair<string, string> Button;
+
+       /// result type
+       enum ResultType {
+               Later, /**< modeless chooser, no result */
+               Chosen /**< string contains filename */
+       };
+
+       /// result return
+       typedef std::pair<FileDialog::ResultType, string> Result;
+
+       /**
+        * Constructs a file dialog attached to LyXView \param lv, with
+        * title \param title. If param \a is \const LFUN_SELECT_FILE_SYNC
+        * then a value will be returned immediately upon performing a Select(),
+        * otherwise a callback Dispatch() will be invoked with the filename as
+        * argument, of action \param a.
+        *
+        * Up to two optional extra buttons are allowed for specifying addtional
+        * directories in the navigation.
+        */
+       FileDialog(LyXView * lv, string const & title, kb_action a = LFUN_SELECT_FILE_SYNC,
+               Button b1 = Button(string(), string()),
+               Button b2 = Button(string(), string()));
+                       
+
+       ~FileDialog();
+
+       /**
+        * Choose a file for selection, starting in directory \param path, with the file
+        * selection \param mask. The \param mask string is of the form :
+        *
+        * <regular expression to match> | <description>
+        *
+        * for example, "*.ps | PostScript files (*.ps)".
+        *
+        * FIXME: should support multiple lines of these for different file types.
+        */
+       Result const Select(string const & path = string(),
+               string const & mask = string(),
+               string const & suggested = string());
+
+
+       /* This *has* to be public because there is no way to specify extern "C" functions
+        * as friends of Private implementation for the xforms implementation ... grr
+        */
+       class Private;
+       friend class Private;
+       Private * private_;
+
+private:
+       /// our LyXView
+       LyXView * lv_;
+
+       /// the dialog title
+       string title_;
+
+       /// success action to perform if not synchronous
+       kb_action success_;
+
+};
+
+#endif // FILEDIALOG_H
index 841350c66c093f969b2edbf7468bfa0ac3b6da42..7dc63a1892dae2e72187056be599b1e6bc253d96 100644 (file)
@@ -15,6 +15,7 @@ libfrontends_la_SOURCES=\
        ButtonPolicies.h \
        Dialogs.h \
        DialogBase.h \
+       FileDialog.h \
        GUIRunTime.h \
        Liason.C \
        Liason.h \
index 86a6d05db6676657660030d026e4a1a5b2c2a786..6eaca56be5882897170acb0e2610c27f99624399 100644 (file)
@@ -1,3 +1,15 @@
+2001-02-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * <various>: remove noncopyable (now inherited from DialogBase)
+
+       * Makefile.am:
+       * FileDialog.C:
+       * FileDialog_private.C:
+       * moc/Makefile.am:
+       * FileDialog_private.h: add File Dialog
+
+       * docdlg.C: remove DEFAULT_LANGUAGE stuff
+
 2001-02-26  Dekel Tsur  <dekelts@tau.ac.il>
 
        * FormRef.C (apply): Update bookmark #0 after inserting a reference.
index d2e932df8f2a314a2324a7db17dc99b3f2e357ea..90c6d83dd7fcd9472753118dc4c5d889a1193475 100644 (file)
@@ -46,6 +46,7 @@ Signal0<void> Dialogs::redrawGUI;
 
 Dialogs::Dialogs(LyXView * lv)
 {
+/*
        dialogs_.push_back(new FormBibitem(lv, this));
        dialogs_.push_back(new FormBibtex(lv, this));
        dialogs_.push_back(new FormCitation(lv, this));
@@ -72,6 +73,7 @@ Dialogs::Dialogs(LyXView * lv)
        // reduce the number of connections needed in
        // dialogs by a simple connection here.
        hideAll.connect(hideBufferDependent.slot());
+*/
 }
 
 
diff --git a/src/frontends/kde/FileDialog.C b/src/frontends/kde/FileDialog.C
new file mode 100644 (file)
index 0000000..83bf5ce
--- /dev/null
@@ -0,0 +1,79 @@
+/**
+ * \file FileDialog.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include <gettext.h> 
+#include <utility>
+#include "commandtags.h"
+#include "LString.h"
+
+#include "frontends/FileDialog.h"
+
+#include "FileDialog_private.h" 
+
+#include "debug.h"
+
+using std::make_pair;
+using std::pair;
+using std::endl;
+
+FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
+       : private_(0), lv_(lv), title_(t), success_(s)
+{
+       // FIXME
+}
+
+
+FileDialog::~FileDialog()
+{
+}
+
+
+FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
+{
+       string filter = mask;
+       if (mask.empty())
+               filter = _("*|All files");
+       LyXKFileDialog * dlg = new LyXKFileDialog(lv_, success_, path, filter, title_);
+
+       lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << endl;
+
+       if (!suggested.empty())
+               dlg->setSelection(suggested.c_str());
+       if (success_ == LFUN_SELECT_FILE_SYNC) {
+               FileDialog::Result result;
+
+               lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
+
+               result.first = FileDialog::Chosen;
+
+               int res = dlg->exec();
+
+               lyxerr[Debug::GUI] << "result " << res << endl;
+       
+               if (res == QDialog::Accepted)
+                       result.second = string(dlg->selectedFile().data());
+
+               delete dlg;
+               return result;
+       }
+
+       dlg->show();
+
+       return make_pair(FileDialog::Later, string());
+}
diff --git a/src/frontends/kde/FileDialog_private.C b/src/frontends/kde/FileDialog_private.C
new file mode 100644 (file)
index 0000000..8fec50f
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * \file FileDialog_private.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon
+ */
+
+#include <config.h>
+
+#include "LString.h"
+#include <kapp.h> 
+#include <kfiledialog.h>
+#include "QtLyXView.h"
+#include "debug.h"
+#include "FileDialog_private.h"
+
+LyXKFileDialog::LyXKFileDialog(LyXView * lv, kb_action a, string const & p, string const & m, string const & t)
+       : KFileDialog(p.c_str(), m.c_str(), KApplication::getKApplication()->topWidget(), t.c_str(), a == LFUN_SELECT_FILE_SYNC, false),
+       lv_(lv), action_(a)
+{
+       setCaption(t.c_str());
+}
+
+
+void LyXKFileDialog::done(int what)
+{
+       lyxerr[Debug::GUI] << "Done FileDialog, value " << what << endl;
+       if (action_ == LFUN_SELECT_FILE_SYNC) {
+               QDialog::done(what);
+               return;
+       } else if (what == QDialog::Accepted)
+               lv_->getLyXFunc()->Dispatch(action_, selectedFile().data());
+       delete this;
+}
diff --git a/src/frontends/kde/FileDialog_private.h b/src/frontends/kde/FileDialog_private.h
new file mode 100644 (file)
index 0000000..b055981
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * \file FileDialog_private.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon
+ */
+
+#ifndef FILEDIALOG_PRIVATE_H
+#define FILEDIALOG_PRIVATE_H
+
+#include <config.h>
+
+#include <kfiledialog.h>
+
+#include "LString.h"
+#include "lyxfunc.h" 
+
+#include "frontends/FileDialog.h"
+
+class LyXView;
+
+class LyXKFileDialog : public KFileDialog
+{
+public:
+       LyXKFileDialog(LyXView * lv, kb_action a, string const & p, string const & m, string const & t);
+
+       friend class FileDialog;
+
+protected:
+       virtual void done(int);
+
+private:
+       LyXView * lv_;
+       int action_;
+};
+
+#endif // FILEDIALOG_PRIVATE_H
index 3b7fc4b9d4e0af90d2647ab71d6e0ce7fcf65f90..8c8c11c07112a58b79ee83b09ffb5c3b06527243 100644 (file)
@@ -20,7 +20,7 @@ class Dialogs;
 class LyXView;
 class CitationDialog;
 
-class FormCitation : public DialogBase, public noncopyable {
+class FormCitation : public DialogBase {
 public:
        FormCitation(LyXView *, Dialogs *);
 
index abcecbc0d0d3afed5fb3d5f94201dfb62b0fb1c3..da1a4dea4611f0c5399629381f74b6b84499fb22 100644 (file)
@@ -15,7 +15,7 @@ class Dialogs;
 class LyXView;
 class CopyrightDialog;
 
-class FormCopyright : public DialogBase, public noncopyable {
+class FormCopyright : public DialogBase {
 public: 
        FormCopyright(LyXView *, Dialogs *);
  
index dd0f74710de0215072a717416ce618f95bed364d..921f27a9df81cfaf1cf1f122284edb26aef6121c 100644 (file)
@@ -22,7 +22,7 @@ class BufferParams;
 /**
  * \brief the LyXian side of the complex Document dialog
  */
-class FormDocument : public DialogBase, public noncopyable {
+class FormDocument : public DialogBase {
 public:
        FormDocument(LyXView *, Dialogs *);
  
index f413e2dc81f1a55a1f293fa6823720eb5af9db29..65c15b966d46ab217e4412236b50126601e00d7d 100644 (file)
@@ -18,7 +18,7 @@ class Dialogs;
 class LyXView;
 class IndexDialog;
 
-class FormIndex : public DialogBase, public noncopyable {
+class FormIndex : public DialogBase {
 public: 
        FormIndex(LyXView *, Dialogs *);
 
index 1ca8e5e0b9355ed43e5ec9afdee67b607ea39b4c..eeb9005cc8524373eba3f097d65029319c574716 100644 (file)
@@ -18,7 +18,7 @@ class Dialogs;
 class LyXView;
 class LogDialog;
 
-class FormLog : public DialogBase, public noncopyable {
+class FormLog : public DialogBase {
 public: 
        FormLog(LyXView *, Dialogs *);
 
index b00dde16fe61bf7eea2537f1225e3c36a60347b4..c822b6b92b0c5d26c532a9d2325d259f693a4f20 100644 (file)
@@ -17,7 +17,7 @@ class Dialogs;
 class LyXView;
 class ParaDialog;
 
-class FormParagraph : public DialogBase, public noncopyable {
+class FormParagraph : public DialogBase {
 public: 
        FormParagraph(LyXView *, Dialogs *);
 
index 4d640873e26fadbbcc6d4d2986a7190be858aff5..b27e9518e045210f235b356ced77fca95f34f50e 100644 (file)
@@ -20,7 +20,7 @@ class PrintDialog;
 using SigC::Connection;
 #endif
 
-class FormPrint : public DialogBase, public noncopyable {
+class FormPrint : public DialogBase {
 public: 
        FormPrint(LyXView *, Dialogs *);
 
index 110a8d1ed35efcad093501aa0f68636a69fd3461..969cab5b272789a868a40ac280cfda96235bb244 100644 (file)
@@ -18,7 +18,7 @@ class Dialogs;
 class LyXView;
 class RefDialog;
 
-class FormRef : public DialogBase, public noncopyable {
+class FormRef : public DialogBase {
 public: 
        FormRef(LyXView *, Dialogs *);
 
index d250aaf999b2e1e3f02c76b915025ffa4e366cc0..1339fcebdead87315500247fea6cb932e08d4d72 100644 (file)
@@ -15,7 +15,7 @@ class Dialogs;
 class LyXView; 
 class TabularCreateDialog;
 
-class FormTabularCreate : public DialogBase, public noncopyable {
+class FormTabularCreate : public DialogBase {
 public: 
        FormTabularCreate(LyXView *, Dialogs *);
  
index 426ddfd20365e20de60d0d3001c751236f36dde0..2cc6d6b7a5c7bae5158494da517ff2c523864448 100644 (file)
@@ -18,7 +18,7 @@
 class Dialogs;
 class TocDialog;
 
-class FormToc : public DialogBase, public noncopyable {
+class FormToc : public DialogBase {
 public:
        FormToc(LyXView *, Dialogs *);
  
index c882722d9af6288f1cfaf087603fee1de295ed19..fa91ed977afd95421c5378ff95c830099a21df70 100644 (file)
@@ -18,7 +18,7 @@ class Dialogs;
 class LyXView;
 class UrlDialog;
 
-class FormUrl : public DialogBase, public noncopyable {
+class FormUrl : public DialogBase {
 public: 
        FormUrl(LyXView *, Dialogs *);
 
index 1fc349650ff58eca7c9f8f906a9d0a8df8beda55..193a550e67f5f7799c931495d9f9722601a3197a 100644 (file)
@@ -18,7 +18,7 @@ class Dialogs;
 class LyXView;
 class LogDialog;
 
-class FormVCLog : public DialogBase, public noncopyable {
+class FormVCLog : public DialogBase {
 public: 
        FormVCLog(LyXView *, Dialogs *);
 
index 35adde245c59fdf80fb6c580190bb35e017b932e..804c6222aa599fcffa07054f23b83daa87849dca 100644 (file)
@@ -48,6 +48,9 @@ LDFLAGS= $(libkde_la_OBJADD)
 ETAGS_ARGS = --lang=c++
 libkde_la_SOURCES = \
        Dialogs.C \
+       FileDialog.C \
+       FileDialog_private.C \
+       FileDialog_private.h \
        GUIRunTime.C \
        QtLyXView.h \
        Timeout_pimpl.C \
@@ -103,6 +106,7 @@ libkde_la_SOURCES = \
        urldlg.C \
        urldlg.h
 
+moc/FileDialog_private_moc.C: FileDialog_private.C FileDialog_private.h
 moc/citationdlg_moc.C: citationdlg.C citationdlg.h
 moc/copyrightdlg_moc.C: copyrightdlg.C copyrightdlg.h
 moc/docdlg_moc.C: docdlg.C docdlg.h
index 5d4d0278e4017b689fe3afaaf3e14d5d716f4274..db47b2a4cc7eac8edfdc88f5f8844e9ca0975e04 100644 (file)
@@ -138,9 +138,6 @@ DocDialog::DocDialog(FormDocument * form, QWidget * parent, char const * name, b
        geometry->margins->insertItem(_("A4 very wide margins"));
        setSizeHint(geometry->margins);
        
-#ifdef DO_USE_DEFAULT_LANGUAGE
-       language->language->insertItem(_("default"));
-#endif
        for (Languages::const_iterator cit = languages.begin();
                cit != languages.end(); ++cit)
                language->language->insertItem((*cit).second.lang().c_str());
index 418c2473ac1274e634662c81b364e31fbe342c11..57b76e12e2e43e28a0b90198fb830b0659388173 100644 (file)
@@ -5,7 +5,8 @@ BOOST_INCLUDES = -I$(top_srcdir)/boost
 INCLUDES = -I${top_srcdir}/src/ -I${top_srcdir}/src/frontends/ \
        ${SIGC_CFLAGS} ${FRONTEND_INCLUDES} ${BOOST_INCLUDES}
 
-libkdemoc_la_SOURCES = citationdlg_moc.C \
+libkdemoc_la_SOURCES = FileDialog_private_moc.C \
+               citationdlg_moc.C \
                copyrightdlg_moc.C \
                docdlg_moc.C \
                indexdlg_moc.C \
@@ -24,6 +25,8 @@ DISTCLEANFILES = $(libkdemoc_la_SOURCES) *.orig *.rej *~ *.bak core
 LIBS=
 ETAGS_ARGS = --lang=c++
 
+FileDialog_private_moc.C: ../FileDialog_private.h
+       $(MOC) $< -o $@
 citationdlg_moc.C: ../citationdlg.h
        $(MOC) $< -o $@
 copyrightdlg_moc.C: ../copyrightdlg.h
index 3fc29337b46d482812c05fb5bd0781d08c04b8d5..2dddf0be2a8c995df7244ca29df1a17433e81b94 100644 (file)
@@ -1,3 +1,23 @@
+2001-03-06  John Levon  <moz@compsoc.man.ac.uk>
+
+       * Makefile.am:
+       * FileDialog.C:
+       * FormFiledialog.C:
+       * FormFiledialog.h:
+       * form_filedialog.C:
+       * form_filedialog.h:
+       * FormGraphics.C:
+       * FormInclude.C:
+       * FormPreferences.C:
+       * FormPrint.C:
+       * xforms_helpers.C:
+       * xforms_helpers.h:
+       * forms/fdfix.sh:
+       * forms/makefile:
+       * form/form_filedialog.fd: add File Dialog
+       * Toolbar_pimpl.h:
+       * Toolbar_pimpl.C: move LayoutsCB to here
+
 2001-03-06  Lars Gullik Bjønnes  <larsbj@trylle.birdstep.com>
 
        * FormParagraph.C: changes because of ParagraphParameters.
diff --git a/src/frontends/xforms/FileDialog.C b/src/frontends/xforms/FileDialog.C
new file mode 100644 (file)
index 0000000..d64f0e9
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * \file FileDialog.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include <gettext.h>
+#include <utility>
+
+#include "commandtags.h"
+
+#include "support/lstrings.h" 
+
+// temp. hack until Allow/ProhibitInput is not
+// needed any more in src/ - for now it's simplest
+// to leave it there 
+#include "LyXView.h" 
+#include "bufferview_funcs.h"
+#include "frontends/FileDialog.h"
+
+#include "FormFiledialog.h"
+
+#include "debug.h"
+
+using std::make_pair;
+using std::pair;
+using std::endl;
+
+FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
+       : private_(0), lv_(lv), title_(t), success_(s)
+{
+       private_ = new FileDialog::Private();
+
+       private_->SetButton(0, b1.first, b1.second); 
+       private_->SetButton(1, b2.first, b2.second);
+}
+
+
+FileDialog::~FileDialog()
+{
+       delete private_;
+       private_ = 0;
+}
+
+
+FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
+{
+       string filter = mask;
+
+       if (mask.empty())
+               filter = _("*");
+       else {
+               rsplit(mask, filter, '|');
+               if (filter.empty())
+                       filter = mask;
+       }
+
+       lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
+
+       // no support for asynchronous selection yet
+
+       ProhibitInput(lv_->view());
+
+       FileDialog::Result result;
+
+       result.first = FileDialog::Chosen;
+       result.second = private_->Select(title_, path, filter, suggested);
+       AllowInput(lv_->view());
+       return result;
+}
diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C
new file mode 100644 (file)
index 0000000..c9a9700
--- /dev/null
@@ -0,0 +1,762 @@
+/**
+ * \file FormFiledialog.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon
+ */
+
+#include <config.h>
+
+#include <unistd.h>
+#include <cstdlib>
+#include <pwd.h>
+#include <grp.h>
+#include <cstring>
+#include <map>
+#include <algorithm>
+
+using std::map;
+using std::max;
+using std::sort;
+
+#include "lyx_gui_misc.h" // for WriteFSAlert
+#include "support/FileInfo.h"
+#include "support/lyxlib.h"
+#include "gettext.h"
+#include "frontends/Dialogs.h"
+
+#ifdef HAVE_ERRNO_H
+#include <cerrno>
+#endif
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+#  include <ndir.h>
+# endif
+#endif
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <ctime>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <ctime>
+# endif
+#endif
+
+// FIXME: should be autoconfiscated
+#ifdef BROKEN_HEADERS
+extern "C" int gettimeofday(struct timeval *, struct timezone *);
+#endif
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "support/filetools.h"
+#include "FormFiledialog.h"
+
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::slot;
+#endif
+
+// six months, in seconds
+static const long SIX_MONTH_SEC = 6L * 30L * 24L * 60L * 60L;
+static const long ONE_HOUR_SEC = 60L * 60L;
+
+// *** User cache class implementation
+/// User cache class definition
+class UserCache {
+public:
+       /// seeks user name from group ID
+       string const & find(uid_t ID) const {
+               Users::const_iterator cit = users.find(ID);
+               if (cit == users.end()) {
+                       add(ID);
+                       return users[ID];
+               }
+               return (*cit).second;
+       }
+private:
+       ///
+       void add(uid_t ID) const;
+       ///
+       typedef map<uid_t, string> Users;
+       ///
+       mutable Users users;
+};
+
+
+void UserCache::add(uid_t ID) const
+{
+       string pszNewName;
+       struct passwd * pEntry;
+       
+       // gets user name
+       if ((pEntry = getpwuid(ID)))
+               pszNewName = pEntry->pw_name;
+       else {
+               pszNewName = tostr(ID);
+       }
+       
+       // adds new node
+       users[ID] = pszNewName;
+}      
+
+
+/// Group cache class definition
+class GroupCache {
+public:
+       /// seeks group name from group ID
+       string const & find(gid_t ID) const ;
+private:
+       ///
+       void add(gid_t ID) const;
+       ///
+       typedef map<gid_t, string> Groups;
+       ///
+       mutable Groups groups;
+};
+
+
+string const & GroupCache::find(gid_t ID) const
+{
+       Groups::const_iterator cit = groups.find(ID);
+       if (cit == groups.end()) {
+               add(ID);
+               return groups[ID];
+       }
+       return (*cit).second;
+}
+
+
+void GroupCache::add(gid_t ID) const
+{
+       string pszNewName;
+       struct group * pEntry;
+       
+       // gets user name
+       if ((pEntry = getgrgid(ID))) pszNewName = pEntry->gr_name;
+       else {
+               pszNewName = tostr(ID);
+       }
+       // adds new node
+       groups[ID] = pszNewName;
+}
+
+
+// static instances
+static UserCache lyxUserCache;
+static GroupCache lyxGroupCache;
+
+
+// compares two LyXDirEntry objects content (used for sort)
+class comp_direntry {
+public:
+       int operator()(DirEntry const & r1,
+                      DirEntry const & r2) const ;
+};
+       int comp_direntry::operator()(DirEntry const & r1,
+                      DirEntry const & r2) const {
+               bool r1d = suffixIs(r1.pszName, '/');
+               bool r2d = suffixIs(r2.pszName, '/');
+               if (r1d && !r2d) return 1;
+               if (!r1d && r2d) return 0;
+               return r1.pszName < r2.pszName;
+       }
+
+
+// *** FileDialog::Private class implementation
+
+// static members
+FD_form_filedialog * FileDialog::Private::pFileDlgForm = 0;
+FileDialog::Private * FileDialog::Private::pCurrentDlg = 0;
+
+
+// Reread: updates dialog list to match class directory
+void FileDialog::Private::Reread()
+{
+       // Opens directory
+       DIR * pDirectory = ::opendir(pszDirectory.c_str());
+       if (!pDirectory) {
+               WriteFSAlert(_("Warning! Couldn't open directory."),
+                            pszDirectory);
+               pszDirectory = lyx::getcwd();
+               pDirectory = ::opendir(pszDirectory.c_str());
+       }
+
+       // Clear the present namelist
+       direntries.clear();
+
+       // Updates display
+       fl_hide_object(pFileDlgForm->List);
+       fl_clear_browser(pFileDlgForm->List);
+       fl_set_input(pFileDlgForm->DirBox, pszDirectory.c_str());
+
+       // Splits complete directory name into directories and compute depth
+       iDepth = 0;
+       string line, Temp;
+       char szMode[15];
+       FileInfo fileInfo;
+       string File = pszDirectory;
+       if (File != "/") {
+               File = split(File, Temp, '/');
+       }
+       while (!File.empty() || !Temp.empty()) {
+               string dline = "@b"+line + Temp + '/';          
+               fl_add_browser_line(pFileDlgForm->List, dline.c_str());
+               File = split(File, Temp, '/');
+               line += ' ';
+               ++iDepth;
+       }
+
+       // Parses all entries of the given subdirectory
+       time_t curTime = time(0);
+       rewinddir(pDirectory);
+       struct dirent * pDirEntry;
+       while ((pDirEntry = readdir(pDirectory))) {
+               bool isLink = false, isDir = false;
+
+               // If the pattern doesn't start with a dot, skip hidden files
+               if (!pszMask.empty() && pszMask[0] != '.' &&
+                   pDirEntry->d_name[0] == '.')
+                        continue;
+
+               // Gets filename
+               string fname = pDirEntry->d_name;
+
+               // Under all circumstances, "." and ".." are not wanted
+               if (fname == "." || fname == "..")
+                       continue;
+
+               // gets file status
+               File = AddName(pszDirectory, fname);
+
+               fileInfo.newFile(File, true);
+               fileInfo.modeString(szMode);
+               unsigned int nlink = fileInfo.getNumberOfLinks();
+               string user =   lyxUserCache.find(fileInfo.getUid());
+               string group = lyxGroupCache.find(fileInfo.getGid());
+
+               time_t modtime = fileInfo.getModificationTime();
+               string Time = ctime(&modtime);
+               
+               if (curTime > fileInfo.getModificationTime() + SIX_MONTH_SEC
+                   || curTime < fileInfo.getModificationTime()
+                   + ONE_HOUR_SEC) {
+                       // The file is fairly old or in the future. POSIX says
+                       // the cutoff is 6 months old. Allow a 1 hour slop
+                       // factor for what is considered "the future", to
+                       // allow for NFS server/client clock disagreement.
+                       // Show the year instead of the time of day.
+                       Time.erase(10, 9);
+                       Time.erase(15, string::npos);
+               } else {
+                       Time.erase(16, string::npos);
+               }
+
+               string Buffer = string(szMode) + ' ' +
+                       tostr(nlink) + ' ' +
+                       user + ' ' +
+                       group + ' ' +
+                       Time.substr(4, string::npos) + ' ';
+
+               Buffer += pDirEntry->d_name;
+               Buffer += fileInfo.typeIndicator();
+
+               if ((isLink = fileInfo.isLink())) {
+                       string Link;
+
+                       if (LyXReadLink(File, Link)) {
+                               Buffer += " -> ";
+                               Buffer += Link;
+
+                               // This gives the FileType of the file that
+                               // is really pointed too after resolving all
+                               // symlinks. This is not necessarily the same
+                               // as the type of Link (which could again be a
+                               // link). Is that intended?
+                               //                              JV 199902
+                               fileInfo.newFile(File);
+                               Buffer += fileInfo.typeIndicator();
+                       }
+               }
+
+               // filters files according to pattern and type
+               if (fileInfo.isRegular()
+                   || fileInfo.isChar()
+                   || fileInfo.isBlock()
+                   || fileInfo.isFifo()) {
+                       if (!regexMatch(fname, pszMask))
+                               continue;
+               } else if (!(isDir = fileInfo.isDir()))
+                       continue;
+
+               DirEntry tmp;
+
+               // Note pszLsEntry is an string!
+               tmp.pszLsEntry = Buffer;
+               // creates used name
+               string temp = fname;
+               if (isDir) temp += '/';
+
+               tmp.pszName = temp;
+               // creates displayed name
+               temp = pDirEntry->d_name;
+               if (isLink)
+                       temp += '@';
+               else
+                       temp += fileInfo.typeIndicator();
+               tmp.pszDisplayed = temp;
+
+               direntries.push_back(tmp);
+       }
+
+       closedir(pDirectory);
+
+       // Sort the names
+       sort(direntries.begin(), direntries.end(), comp_direntry());
+       
+       // Add them to directory box
+       for (DirEntries::const_iterator cit = direntries.begin();
+            cit != direntries.end(); ++cit) {
+               string const temp = line + (*cit).pszDisplayed;
+               fl_add_browser_line(pFileDlgForm->List, temp.c_str());
+       }
+       fl_set_browser_topline(pFileDlgForm->List, iDepth);
+       fl_show_object(pFileDlgForm->List);
+       iLastSel = -1;
+}
+
+
+// SetDirectory: sets dialog current directory
+void FileDialog::Private::SetDirectory(string const & Path)
+{
+       if (!pszDirectory.empty()) {
+               string TempPath = ExpandPath(Path); // Expand ~/
+               TempPath = MakeAbsPath(TempPath, pszDirectory);
+               pszDirectory = MakeAbsPath(TempPath);
+       } else pszDirectory = MakeAbsPath(Path);
+}
+
+
+// SetMask: sets dialog file mask
+void FileDialog::Private::SetMask(string const & NewMask)
+{
+       pszMask = NewMask;
+       fl_set_input(pFileDlgForm->PatBox, pszMask.c_str());
+}
+
+
+// SetInfoLine: sets dialog information line
+void FileDialog::Private::SetInfoLine(string const & Line)
+{
+       pszInfoLine = Line;
+       fl_set_object_label(pFileDlgForm->FileInfo, pszInfoLine.c_str());
+}
+
+
+FileDialog::Private::Private()
+{
+       pszDirectory = MakeAbsPath(string("."));
+       pszMask = '*';
+
+       // Creates form if necessary.
+       if (!pFileDlgForm) {
+               pFileDlgForm = build_filedialog();
+               // Set callbacks. This means that we don't need a patch file
+               fl_set_object_callback(pFileDlgForm->DirBox,
+                                      C_LyXFileDlg_FileDlgCB, 0);
+               fl_set_object_callback(pFileDlgForm->PatBox,
+                                      C_LyXFileDlg_FileDlgCB, 1);
+               fl_set_object_callback(pFileDlgForm->List,
+                                      C_LyXFileDlg_FileDlgCB, 2);
+               fl_set_object_callback(pFileDlgForm->Filename,
+                                      C_LyXFileDlg_FileDlgCB, 3);
+               fl_set_object_callback(pFileDlgForm->Rescan,
+                                      C_LyXFileDlg_FileDlgCB, 10);
+               fl_set_object_callback(pFileDlgForm->Home,
+                                      C_LyXFileDlg_FileDlgCB, 11);
+               fl_set_object_callback(pFileDlgForm->User1,
+                                      C_LyXFileDlg_FileDlgCB, 12);
+               fl_set_object_callback(pFileDlgForm->User2,
+                                      C_LyXFileDlg_FileDlgCB, 13);
+               
+               // Make sure pressing the close box doesn't crash LyX. (RvdK)
+               fl_set_form_atclose(pFileDlgForm->form,
+                                   C_LyXFileDlg_CancelCB, 0);
+               // Register doubleclick callback
+               fl_set_browser_dblclick_callback(pFileDlgForm->List,
+                                                C_LyXFileDlg_DoubleClickCB,
+                                                0);
+       }
+       fl_hide_object(pFileDlgForm->User1);
+       fl_hide_object(pFileDlgForm->User2);
+
+       r_ = Dialogs::redrawGUI.connect(slot(this, &FileDialog::Private::redraw));
+}
+
+
+FileDialog::Private::~Private()
+{
+       r_.disconnect();
+}
+
+
+void FileDialog::Private::redraw()
+{
+       if (pFileDlgForm->form && pFileDlgForm->form->visible)
+               fl_redraw_form(pFileDlgForm->form);
+}
+
+
+// SetButton: sets file selector user button action
+void FileDialog::Private::SetButton(int iIndex, string const & pszName,
+                          string const & pszPath)
+{
+       FL_OBJECT * pObject;
+       string * pTemp;
+
+       if (iIndex == 0) {
+               pObject = pFileDlgForm->User1;
+               pTemp = &pszUserPath1;
+       } else if (iIndex == 1) {                       
+               pObject = pFileDlgForm->User2;
+               pTemp = &pszUserPath2;
+       } else return;
+
+       if (!pszName.empty() && !pszPath.empty()) {
+               fl_set_object_label(pObject, pszName.c_str());
+               fl_show_object(pObject);
+               *pTemp = pszPath;
+       } else {
+               fl_hide_object(pObject);
+               (*pTemp).erase();
+       }
+}
+
+
+// GetDirectory: gets last dialog directory
+string const FileDialog::Private::GetDirectory() const
+{
+       if (!pszDirectory.empty())
+               return pszDirectory;
+       else
+               return string(".");
+}
+
+
+// RunDialog: handle dialog during file selection
+bool FileDialog::Private::RunDialog()
+{
+       force_cancel = false;
+       force_ok = false;
+       
+        // event loop
+        while(true) {
+                FL_OBJECT * pObject = fl_do_forms();
+
+                if (pObject == pFileDlgForm->Ready) {
+                       if (HandleOK())
+                               return true;
+               } else if (pObject == pFileDlgForm->Cancel
+                          || force_cancel)
+                       return false;
+               else if (force_ok)
+                       return true;
+       }
+}
+
+
+// XForms objects callback (static)
+void FileDialog::Private::FileDlgCB(FL_OBJECT *, long lArgument)
+{
+       if (!pCurrentDlg) return;
+
+       switch (lArgument) {
+
+       case 0: // get directory
+               pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
+               pCurrentDlg->Reread();
+               break;
+
+       case 1: // get mask
+               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
+               pCurrentDlg->Reread();
+               break;
+
+       case 2: // list
+               pCurrentDlg->HandleListHit();
+               break;  
+
+       case 10: // rescan
+               pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
+               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
+               pCurrentDlg->Reread();
+               break;
+
+       case 11: // home
+               pCurrentDlg->SetDirectory(GetEnvPath("HOME"));
+               pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
+               pCurrentDlg->Reread();
+               break;
+
+       case 12: // user button 1
+               if (!pCurrentDlg->pszUserPath1.empty()) {
+                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1);
+                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
+                                                         ->PatBox));
+                       pCurrentDlg->Reread();
+               }
+               break;
+
+       case 13: // user button 2
+               if (!pCurrentDlg->pszUserPath2.empty()) {
+                       pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2);
+                       pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
+                                                         ->PatBox));
+                       pCurrentDlg->Reread();
+               }
+               break;
+
+       }
+}
+
+
+extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data)
+{
+       FileDialog::Private::FileDlgCB(ob, data);
+}
+
+
+// Handle callback from list
+void FileDialog::Private::HandleListHit()
+{
+       // set info line
+       int const iSelect = fl_get_browser(pFileDlgForm->List);
+       if (iSelect > iDepth)  {
+               SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
+       } else {
+               SetInfoLine(string());
+       }
+}
+
+
+// Callback for double click in list
+void FileDialog::Private::DoubleClickCB(FL_OBJECT *, long)
+{
+       if (pCurrentDlg->HandleDoubleClick())
+               // Simulate click on OK button
+               pCurrentDlg->Force(false);
+}
+
+
+extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
+{
+       FileDialog::Private::DoubleClickCB(ob, data);
+}
+
+
+// Handle double click from list
+bool FileDialog::Private::HandleDoubleClick()
+{
+       string pszTemp;
+
+       // set info line
+       bool isDir = true;
+       int const iSelect = fl_get_browser(pFileDlgForm->List);
+       if (iSelect > iDepth)  {
+               pszTemp = direntries[iSelect - iDepth - 1].pszName;
+               SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
+               if (!suffixIs(pszTemp, '/')) {
+                       isDir = false;
+                       fl_set_input(pFileDlgForm->Filename, pszTemp.c_str());
+               }
+       } else if (iSelect != 0) {
+               SetInfoLine(string());
+       } else
+               return true;
+
+       // executes action
+       if (isDir) {
+               string Temp;
+
+               // builds new directory name
+               if (iSelect > iDepth) {
+                       // Directory deeper down
+                       // First, get directory with trailing /
+                       Temp = fl_get_input(pFileDlgForm->DirBox);
+                       if (!suffixIs(Temp, '/'))
+                               Temp += '/';
+                       Temp += pszTemp;
+               } else {
+                       // Directory higher up
+                       Temp.erase();
+                       for (int i = 0; i < iSelect; ++i) {
+                               string piece = fl_get_browser_line(pFileDlgForm->List, i+1);
+                               // The '+2' is here to count the '@b' (JMarc)
+                               Temp += piece.substr(i + 2);
+                       }
+               }
+
+               // assigns it
+               SetDirectory(Temp);
+               Reread();
+               return false;
+       }
+       return true;
+}
+
+
+// Handle OK button call
+bool FileDialog::Private::HandleOK()
+{
+       // mask was changed
+       string pszTemp = fl_get_input(pFileDlgForm->PatBox);
+       if (pszTemp != pszMask) {
+               SetMask(pszTemp);
+               Reread();
+               return false;
+       }
+
+       // directory was changed
+       pszTemp = fl_get_input(pFileDlgForm->DirBox);
+       if (pszTemp!= pszDirectory) {
+               SetDirectory(pszTemp);
+               Reread();
+               return false;
+       }
+       
+       // Handle return from list
+       int const select = fl_get_browser(pFileDlgForm->List);
+       if (select > iDepth) {
+               string const temp = direntries[select - iDepth - 1].pszName;
+               if (!suffixIs(temp, '/')) {
+                       // If user didn't type anything, use browser
+                       string const name =
+                               fl_get_input(pFileDlgForm->Filename);
+                       if (name.empty()) {
+                               fl_set_input(pFileDlgForm->Filename, temp.c_str());
+                       }
+                       return true;
+               }
+       }
+
+       // Emulate a doubleclick
+       return HandleDoubleClick();
+}
+
+
+// Handle Cancel CB from WM close
+int FileDialog::Private::CancelCB(FL_FORM *, void *)
+{
+       // Simulate a click on the cancel button
+       pCurrentDlg->Force(true);
+       return FL_IGNORE;
+}
+
+
+extern "C" int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev)
+{
+       return FileDialog::Private::CancelCB(fl, xev);
+}
+
+
+// Simulates a click on OK/Cancel
+void FileDialog::Private::Force(bool cancel)
+{
+       if (cancel) {
+               force_cancel = true;
+               fl_set_button(pFileDlgForm->Cancel, 1);
+       } else {
+               force_ok = true;
+               fl_set_button(pFileDlgForm->Ready, 1);
+       }
+       // Start timer to break fl_do_forms loop soon
+       fl_set_timer(pFileDlgForm->timer, 0.1);
+}
+
+
+// Select: launches dialog and returns selected file
+string const FileDialog::Private::Select(string const & title, string const & path,
+                               string const & mask, string const & suggested)
+{
+       // handles new mask and path
+       bool isOk = true;
+       if (!mask.empty()) {
+               SetMask(mask);
+               isOk = false;
+       }
+       if (!path.empty()) {
+               SetDirectory(path);
+               isOk = false;
+       }
+       if (!isOk) Reread();
+
+       // highlight the suggested file in the browser, if it exists.
+       int sel = 0;
+       string const filename = OnlyFilename(suggested);
+       if (!filename.empty()) {
+               for (int i = 0;
+                    i < fl_get_browser_maxline(pFileDlgForm->List); ++i) {
+                       string s =
+                               fl_get_browser_line(pFileDlgForm->List, i + 1);
+                       s = strip(frontStrip(s));
+                       if (s == filename) {
+                               sel = i + 1;
+                               break;
+                       }
+               }
+       }
+       
+       if (sel != 0) fl_select_browser_line(pFileDlgForm->List, sel);
+       int const top = max(sel - 5, 1);
+       fl_set_browser_topline(pFileDlgForm->List, top);
+
+       // checks whether dialog can be started
+       if (pCurrentDlg) return string();
+       pCurrentDlg = this;
+
+       // runs dialog
+       SetInfoLine(string());
+       fl_set_input(pFileDlgForm->Filename, suggested.c_str());
+       fl_set_button(pFileDlgForm->Cancel, 0);
+       fl_set_button(pFileDlgForm->Ready, 0);
+       fl_set_focus_object(pFileDlgForm->form, pFileDlgForm->Filename);
+       fl_deactivate_all_forms();
+       fl_show_form(pFileDlgForm->form,
+                    FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
+                    title.c_str());
+
+       isOk = RunDialog();
+       
+       fl_hide_form(pFileDlgForm->form);
+       fl_activate_all_forms();
+       pCurrentDlg = 0;
+
+       // Returns filename or string() if no valid selection was made
+       if (!isOk || !fl_get_input(pFileDlgForm->Filename)[0]) return string();
+
+       pszFileName = fl_get_input(pFileDlgForm->Filename);
+
+       if (!AbsolutePath(pszFileName)) {
+               pszFileName = AddName(fl_get_input(pFileDlgForm->DirBox),
+                                     pszFileName);
+       }
+       return pszFileName;
+}
diff --git a/src/frontends/xforms/FormFiledialog.h b/src/frontends/xforms/FormFiledialog.h
new file mode 100644 (file)
index 0000000..cae5ab4
--- /dev/null
@@ -0,0 +1,134 @@
+/**
+ * \file FormFiledialog.h
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon
+ */
+
+#ifndef FORMFILEDIALOG_H
+#define FORMFILEDIALOG_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <config.h>
+
+#include <vector>
+#include <sigc++/signal_system.h>
+
+#include "LString.h"
+#include FORMS_H_LOCATION
+#include "form_filedialog.h"
+
+#include "frontends/FileDialog.h"
+
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::Object;
+using SigC::Connection;
+#endif
+
+/// DirEntry internal structure definition
+class DirEntry {
+public:
+       ///
+       string pszName;
+       ///
+       string pszDisplayed;
+       ///
+       string pszLsEntry;
+};
+
+extern "C" void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data);
+extern "C" void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data);
+extern "C" int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev);
+
+class FileDialog::Private : public Object
+{
+public:
+       ///
+       Private();
+       ///
+       ~Private();
+
+       /// sets file selector user button action
+       void SetButton(int iIndex, string const & pszName = string(),
+                      string const & pszPath = string());
+       /// gets last dialog directory
+       string const GetDirectory() const;
+       /// launches dialog and returns selected file
+       string const Select(string const & pszTitle = string(),
+                      string const & pszPath = string(),
+                      string const & pszMask = string(),
+                      string const & pszSuggested = string());
+       /// XForms objects callback (static)
+       static void FileDlgCB(FL_OBJECT *, long);
+       /// Callback for double click in list
+       static void DoubleClickCB(FL_OBJECT *, long);
+       /// Handle Cancel CB from WM close
+       static int CancelCB(FL_FORM *, void *);
+
+private:
+       /// data
+       static FD_form_filedialog * pFileDlgForm;
+       ///
+       static FileDialog::Private * pCurrentDlg;
+       ///
+       string pszUserPath1;
+       ///
+       string pszUserPath2;
+       ///
+       string pszDirectory;
+       ///
+       string pszMask;
+       ///
+       string pszFileName;
+       ///
+       int iDepth;
+       ///
+       int iLastSel;
+       ///
+       long lLastTime;
+       ///
+       string pszInfoLine;
+       ///
+       typedef std::vector<DirEntry> DirEntries;
+       ///
+       DirEntries direntries;
+       ///
+       bool force_cancel;
+       ///
+       bool force_ok;
+
+       /// build the dialog
+       FD_form_filedialog * build_filedialog();
+
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colors have been re-mapped).
+       */
+       void redraw();
+       /// updates dialog list to match class directory
+       void Reread();
+       /// sets dialog current directory
+       void SetDirectory(string const & pszPath);
+       /// sets dialog file mask
+       void SetMask(string const & pszNewMask);
+       /// sets dialog information line
+       void SetInfoLine(string const & pszLine);
+       /// handle dialog during file selection
+       bool RunDialog();
+       /// Handle callback from list
+       void HandleListHit();
+       /// Handle double click from list
+       bool HandleDoubleClick();
+       /// Handle OK button call
+       bool HandleOK();
+       /// Simulates a click on OK/Cancel
+       void Force(bool);
+       /// Redraw connection.
+       Connection r_;
+};
+
+#endif // FORMFILEDIALOG_H
index d37fad399d7ce4ad0831590c0a69edf33431456f..3d781b1b590732a52290d5a477661b1963366134 100644 (file)
@@ -357,7 +357,8 @@ void FormGraphics::browse()
        string const filename = fl_get_input(dialog_->input_filename);
 
        string const title = N_("Graphics");
-       string const pattern = "*(ps|png)";
+       // we need the second '|' to prevent mis-interpretation 
+       string const pattern = "*.(ps|png)|";
 
        // Does user clipart directory exist?
        string clipdir = AddName (user_lyxdir, "clipart");
@@ -369,7 +370,7 @@ void FormGraphics::browse()
        
        // Show the file browser dialog
        string const new_filename =
-               browseFile(filename, title, pattern, dir1,
+               browseFile(lv_, filename, title, pattern, dir1,
                           make_pair(string(), string()));
 
        // Save the filename to the dialog
index 8abf18ccf8569465652d114509004b2fdbb8186b..8389ff38b17702a79f109e9bf96993113f984564 100644 (file)
@@ -8,7 +8,7 @@
  */
 #include <config.h>
 #include <algorithm>
-#include <iostream>
+#include <utility>
 
 #ifdef __GNUG__
 #pragma implementation
@@ -17,9 +17,9 @@
 #include "Dialogs.h"
 #include "FormInclude.h"
 #include "insets/insetinclude.h" 
-#include "filedlg.h"
-#include "support/filetools.C"
-#include "support/lstrings.h" 
+#include "frontends/FileDialog.h"
+#include "support/filetools.h"
+#include "support/lstrings.h"
 #include "LyXView.h"
 #include "buffer.h"
 #include "lyxrc.h" 
  
 #include "form_include.h"
 
-using std::cout;
+using std::make_pair;
+using std::pair;
 
 FormInclude::FormInclude(LyXView * lv, Dialogs * d)
        : FormCommand(lv, d, _("Include file"), new OkCancelPolicy),
          dialog_(0)
 {
-       // let the dialog be shown
-       // These are permanent connections so we won't bother
-       // storing a copy because we won't be disconnecting.
        d->showInclude.connect(slot(this, &FormInclude::showInset));
        d->createInclude.connect(slot(this, &FormInclude::createInset));
 }
@@ -125,7 +123,7 @@ void FormInclude::apply()
        //inset_->setNoLoad(fl_get_button(dialog_->flag1));
  
        params.setContents(fl_get_input(dialog_->filename));
-       cout << params.getContents() << endl; 
+
        if (fl_get_button(dialog_->flag2))
                params.setCmdName("input");
        else if (fl_get_button(dialog_->flag3))
@@ -156,19 +154,19 @@ bool FormInclude::input(FL_OBJECT *, long data)
        switch (state) {
                case BROWSE: {
                        // Should browsing too be disabled in RO-mode?
-                       LyXFileDlg fileDlg;
+                       FileDialog fileDlg(lv_, _("Select document to include"),
+                               LFUN_SELECT_FILE_SYNC,
+                               make_pair(string(_("Documents")), string(lyxrc.document_path)));
  
                        string ext;
                    
-                       fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-
                        /* input TeX, verbatim, or LyX file ? */
                        if (fl_get_button(dialog_->flag2))
-                               ext = "*.tex";
+                               ext = _("*.tex| LaTeX Documents (*.tex)");
                        else if (fl_get_button(dialog_->flag4))
-                               ext = "*";
+                               ext = _("*| All files ");
                        else
-                               ext = "*.lyx";
+                               ext = _("*.lyx| LyX Documents (*.lyx)");
         
                        string mpath;
  
@@ -176,18 +174,16 @@ bool FormInclude::input(FL_OBJECT *, long data)
                        //if (inset_)
                        //      mpath = OnlyPath(inset_->getMasterFilename());
  
-                       string const filename = fileDlg.Select(_("Select Child Document"),
-                                               mpath, ext, fl_get_input(dialog_->filename));
-                       XFlush(fl_get_display());
+                       FileDialog::Result result = fileDlg.Select(mpath, ext, fl_get_input(dialog_->filename));
         
                        // check selected filename
-                       if (filename.empty())
+                       if (result.second.empty())
                                break;
         
-                       string const filename2 = MakeRelPath(filename, mpath);
+                       string const filename2 = MakeRelPath(result.second, mpath);
         
                        if (prefixIs(filename2, ".."))
-                               fl_set_input(dialog_->filename, filename.c_str());
+                               fl_set_input(dialog_->filename, result.second.c_str());
                        else
                                fl_set_input(dialog_->filename, filename2.c_str());
  
@@ -203,8 +199,7 @@ bool FormInclude::input(FL_OBJECT *, long data)
                        break;
         
                case INPUTINCLUDE:
-                       cout << "inputinclude" << endl;
-                       /* huh ? why doesn't this work ? */ 
+                       /* FIXME: huh ? why doesn't this work ? */ 
                        setEnabled(dialog_->flag41, false);
                        fl_set_button(dialog_->flag41, 0);
                        break;
index 783abb3498462754ddba9ca2c1ec6a5f4fc4c225..dbeaae8e332507962d215b7106664703e6c5c1c9 100644 (file)
@@ -2931,7 +2931,7 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(filename, title, pattern, dir1, dir2);
+               browseFile(lv_, filename, title, pattern, dir1, dir2);
 
        // Save the filename to the dialog
        if (new_filename != filename && !new_filename.empty()) {
index e7881bc39da69a51ef462bdf183a8bfa31324e8e..b9d9542b2448d3dea368cfe92dac00337363cf37 100644 (file)
@@ -263,7 +263,7 @@ void FormPrint::browse()
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(filename, title, pattern,
+               browseFile(lv_, filename, title, pattern,
                           make_pair(string(), string()),
                           make_pair(string(), string()));
 
index a4489c52595105a98e27a412bb998e4afe2706bb..95d4205ce79aa85f3f738074ec90a0bac1de65ef 100644 (file)
@@ -17,6 +17,11 @@ libxforms_la_SOURCES = \
        Color.C \
        Color.h \
        Dialogs.C \
+       FileDialog.C \
+       FormFiledialog.h \
+       FormFiledialog.C \
+       form_filedialog.C \
+       form_filedialog.h \
        GUIRunTime.C \
        FormBase.C \
        FormBase.h \
index f86ea7f5ea9ca894b2f78c2be53fcb17203e9ecd..6d18cbdc87670b6b7c4b288f9147821204a3c61f 100644 (file)
 #include "buffer.h"
 #include "LyXAction.h"
 #include "support/filetools.h"
+#include "support/lstrings.h" 
 #include "gettext.h"
 
 using std::endl;
 
-// this one is not "C" because combox callbacks are really C++ %-|
-extern void LayoutsCB(int, void *, Combox *);
 extern char const ** get_pixmap_from_symbol(char const * arg, int, int);
 extern LyXAction lyxaction;
 
@@ -115,7 +114,7 @@ extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
 static
 int BubblePost(FL_OBJECT *ob, int event,
                        FL_Coord /*mx*/, FL_Coord /*my*/,
-                       int /*key*/, void */*xev*/)
+                       int /*key*/, void * /*xev*/)
 {
        FL_OBJECT * bubble_timer = reinterpret_cast<FL_OBJECT *>(ob->u_cdata);
        
@@ -142,6 +141,21 @@ extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
 }
 #endif
 
+// this one is not "C" because combox callbacks are really C++ %-|
+void Toolbar::Pimpl::layoutSelectedCB(int sel, void * arg, Combox *)
+{
+       Toolbar::Pimpl * tb = reinterpret_cast<Toolbar::Pimpl *>(arg);
+
+       tb->layoutSelected(sel);
+}
+
+
+void Toolbar::Pimpl::layoutSelected(int sel)
+{
+       string const tmp = tostr(sel);
+       owner->getLyXFunc()->Dispatch(LFUN_LAYOUTNO, tmp);
+}
 
 void Toolbar::Pimpl::activate()
 {
@@ -361,7 +375,7 @@ void Toolbar::Pimpl::set(bool doingmain)
                        if (!combox)
                                combox = new Combox(FL_COMBOX_DROPLIST);
                        combox->add(xpos, ypos, 135, height, 400);
-                       combox->setcallback(LayoutsCB);
+                       combox->setcallback(layoutSelectedCB, this);
                        combox->resize(FL_RESIZE_ALL);
                        combox->gravity(NorthWestGravity, NorthWestGravity);
                        xpos += 135;
index d9af62d54a28324eb1ec5029c8f0edfa216ac958..bbafe2373ca028bf237149c1917c1fda40f21d9e 100644 (file)
@@ -30,6 +30,8 @@
   */
 struct Toolbar::Pimpl {
 public:
+       /// called when user selects a layout from combox
+       static void layoutSelectedCB(int, void *, Combox *);
        ///
        Pimpl(LyXView * o, int x, int y);
 
@@ -61,6 +63,7 @@ public:
        /// update the state of the icons
        void update();
 
        /// select the right layout in the combox
        void setLayout(int layout);
        /// Populate the layout combox; re-do everything if force is true.
@@ -69,6 +72,8 @@ public:
        void openLayoutList();
        /// Erase the layout list
        void clearLayoutList();
+       /// and the non-static version
+       void layoutSelected(int); 
 
        ///
        struct toolbarItem
diff --git a/src/frontends/xforms/form_filedialog.C b/src/frontends/xforms/form_filedialog.C
new file mode 100644 (file)
index 0000000..3753d00
--- /dev/null
@@ -0,0 +1,108 @@
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+#include <config.h>
+#include "lyx_gui_misc.h"
+#include "gettext.h"
+
+/* Form definition file generated with fdesign. */
+
+#include FORMS_H_LOCATION
+#include <stdlib.h>
+#include "form_filedialog.h"
+#include "FormFiledialog.h"
+
+FD_form_filedialog::~FD_form_filedialog()
+{
+  if ( form->visible ) fl_hide_form( form );
+  fl_free_form( form );
+}
+
+
+FD_form_filedialog * FileDialog::Private::build_filedialog()
+{
+  FL_OBJECT *obj;
+  FD_form_filedialog *fdui = new FD_form_filedialog;
+
+  fdui->form = fl_bgn_form(FL_NO_BOX, 440, 380);
+  fdui->form->u_vdata = this;
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 440, 380, "");
+  fdui->FileInfo = obj = fl_add_text(FL_NORMAL_TEXT, 10, 260, 420, 30, "");
+    fl_set_object_boxtype(obj, FL_SHADOW_BOX);
+    fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
+    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
+    fl_set_object_resize(obj, FL_RESIZE_X);
+  {
+    char const * const dummy = N_("Directory:|#D");
+    fdui->DirBox = obj = fl_add_input(FL_NORMAL_INPUT, 100, 10, 330, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
+    fl_set_object_resize(obj, FL_RESIZE_X);
+  {
+    char const * const dummy = N_("Pattern:|#P");
+    fdui->PatBox = obj = fl_add_input(FL_NORMAL_INPUT, 100, 40, 330, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
+    fl_set_object_resize(obj, FL_RESIZE_X);
+  fdui->List = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 80, 320, 170, "");
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
+  {
+    char const * const dummy = N_("Filename:|#F");
+    fdui->Filename = obj = fl_add_input(FL_NORMAL_INPUT, 100, 300, 330, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
+    fl_set_object_resize(obj, FL_RESIZE_X);
+  {
+    char const * const dummy = N_("Rescan|#R#r");
+    fdui->Rescan = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 80, 90, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+  {
+    char const * const dummy = N_("Home|#H#h");
+    fdui->Home = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 120, 90, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+  {
+    char const * const dummy = N_("User1|#1");
+    fdui->User1 = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 160, 90, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+  {
+    char const * const dummy = N_("User2|#2");
+    fdui->User2 = obj = fl_add_button(FL_NORMAL_BUTTON, 340, 200, 90, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
+  fdui->Ready = obj = fl_add_button(FL_RETURN_BUTTON, 220, 340, 100, 30, _("OK"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+  {
+    char const * const dummy = N_("Cancel|^[");
+    fdui->Cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 330, 340, 100, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
+  fdui->timer = obj = fl_add_timer(FL_HIDDEN_TIMER, 10, 350, 20, 20, "");
+    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
+  fl_end_form();
+
+  fdui->form->fdui = fdui;
+
+  return fdui;
+}
+/*---------------------------------------*/
+
diff --git a/src/frontends/xforms/form_filedialog.h b/src/frontends/xforms/form_filedialog.h
new file mode 100644 (file)
index 0000000..ebb8c5a
--- /dev/null
@@ -0,0 +1,29 @@
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+/** Header file generated with fdesign **/
+
+#ifndef FD_form_filedialog_h_
+#define FD_form_filedialog_h_
+
+/** Callbacks, globals and object handlers **/
+
+
+/**** Forms and Objects ****/
+struct FD_form_filedialog {
+       ~FD_form_filedialog();
+
+       FL_FORM *form;
+       FL_OBJECT *FileInfo;
+       FL_OBJECT *DirBox;
+       FL_OBJECT *PatBox;
+       FL_OBJECT *List;
+       FL_OBJECT *Filename;
+       FL_OBJECT *Rescan;
+       FL_OBJECT *Home;
+       FL_OBJECT *User1;
+       FL_OBJECT *User2;
+       FL_OBJECT *Ready;
+       FL_OBJECT *Cancel;
+       FL_OBJECT *timer;
+};
+
+#endif /* FD_form_filedialog_h_ */
index 294422fba4e4ff4e4939b202f5b5eed77f080ae6..e788b620b4188d7a227750a07655c81a96365243 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/sh -x
 #
 # NOTE: This is NOT the same fdfix.sh as in ${top_srcdir}/forms
 #       It is a modified version to suit use for gui-indep.
@@ -73,6 +73,15 @@ echo >> $COUT
 
 sed -f $FDFIXC_MOD < $CIN >> $COUT
 
+# hack for file dialog
+if [ "$CLASSNAME" = "FormFiledialog" ] ; then
+    ed $COUT >/dev/null 2>/dev/null << EOF
+/FormFiledialog::build_filedialog
+s/FormFiledialog/FileDialog::Private/
+wq
+EOF
+fi
+
 # Patch the .C file if a patch exists
 if [ -f "$COUT.patch" ] ; then
     echo "Patching $COUT with $COUT.patch"
diff --git a/src/frontends/xforms/forms/form_filedialog.fd b/src/frontends/xforms/forms/form_filedialog.fd
new file mode 100644 (file)
index 0000000..541b521
--- /dev/null
@@ -0,0 +1,250 @@
+Magic: 13000
+
+Internal Form Definition File
+    (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_filedialog
+Width: 440
+Height: 380
+Number of Objects: 13
+
+--------------------
+class: FL_BOX
+type: UP_BOX
+box: 0 0 440 380
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_TEXT
+type: NORMAL_TEXT
+box: 10 260 420 30
+boxtype: FL_SHADOW_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_X
+gravity: FL_SouthWest FL_SouthEast
+name: FileInfo
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 100 10 330 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Directory:|#D
+shortcut: 
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: DirBox
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 100 40 330 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Pattern:|#P
+shortcut: 
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: PatBox
+callback: 
+argument: 
+
+--------------------
+class: FL_BROWSER
+type: HOLD_BROWSER
+box: 10 80 320 170
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NorthWest FL_SouthEast
+name: List
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 100 300 330 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Filename:|#F
+shortcut: 
+resize: FL_RESIZE_X
+gravity: FL_SouthWest FL_SouthEast
+name: Filename
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 340 80 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Rescan|#R#r
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: Rescan
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 340 120 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Home|#H#h
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: Home
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 340 160 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: User1|#1
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: User1
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 340 200 90 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: User2|#2
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_NorthEast FL_NorthEast
+name: User2
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: RETURN_BUTTON
+box: 220 340 100 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: OK
+shortcut: ^M
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: Ready
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 330 340 100 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Cancel|^[
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: Cancel
+callback: 
+argument: 
+
+--------------------
+class: FL_TIMER
+type: HIDDEN_TIMER
+box: 10 350 20 20
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_RED
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_SouthWest FL_SouthWest
+name: timer
+callback: 
+argument: 
+
+==============================
+--------------------
index 2d0782e3a7ee49dff919440574d610af2de02dc1..d8cf2eca41116ee1061cc42c2633a04a628a7b7d 100644 (file)
@@ -24,6 +24,7 @@ SRCS := form_bibitem.fd \
        form_copyright.fd \
        form_document.fd \
        form_error.fd \
+       form_filedialog.fd \
        form_graphics.fd \
        form_include.fd \
        form_index.fd \
index 72d346f4ac09604ddce881bba030efeb20922fdd..02d3a69e365cb5de410ccfcddc1fe6c2cd967491 100644 (file)
 #ifdef __GNUG_
 #pragma implementation
 #endif
-
 #include "xforms_helpers.h"
 #include "lyxlex.h"
-#include "filedlg.h" // LyXFileDlg
+#include "frontends/FileDialog.h"
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "lyx_gui_misc.h" // WriteAlert
@@ -83,7 +83,7 @@ string formatted(string const & sin, int w, int size, int style)
 }
 
 
-string const browseFile(string const & filename,
+string const browseFile(LyXView * lv, string const & filename,
                        string const & title,
                        string const & pattern, 
                        pair<string,string> const & dir1,
@@ -92,43 +92,27 @@ string const browseFile(string const & filename,
        string lastPath = ".";
        if (!filename.empty()) lastPath = OnlyPath(filename);
 
-       LyXFileDlg fileDlg;
-
-       if (!dir1.second.empty()) {
-               FileInfo fileInfo(dir1.second);
-               if (fileInfo.isOK() && fileInfo.isDir())
-                       fileDlg.SetButton(0, _(dir1.first), dir1.second);
-       }
-
-       if (!dir2.second.empty()) {
-               FileInfo fileInfo(dir2.second);
-               if (fileInfo.isOK() && fileInfo.isDir())
-                   fileDlg.SetButton(1, _(dir2.first), dir2.second);
-       }
+       FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
 
-       bool error = false;
-       string buf;
-       do {
-               string p = fileDlg.Select(_(title),
-                                         lastPath,
-                                         pattern, OnlyFilename(filename));
+       FileDialog::Result result;
+       while (1) {
+               result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
 
-               if (p.empty()) return p;
+               if (result.second.empty()) 
+                       return result.second;
 
-               lastPath = OnlyPath(p);
+               lastPath = OnlyPath(result.second);
 
-               if (p.find_first_of("#~$% ") != string::npos) {
-                       WriteAlert(_("Filename can't contain any "
-                                    "of these characters:"),
-                                  _("space, '#', '~', '$' or '%'."));
-                       error = true;
-               } else {
-                       error = false;
-                       buf = p;
-               }
-       } while (error);
+               if (result.second.find_first_of("#~$% ") == string::npos)
+                       break; 
+               WriteAlert(_("Filename can't contain any "
+                       "of these characters:"),
+                       _("space, '#', '~', '$' or '%'."));
+       }
 
-       return buf;
+       return result.second;
 }
 
 
index 531b26a724cd0dda3c688ac1db41c388e28e654b..0781cd1c9ef4f37519e82a7a3d66a70d32ce02bd 100644 (file)
@@ -16,13 +16,15 @@ void setEnabled(FL_OBJECT *, bool enable);
 // Take a string and add breaks so that it fits into a desired label width, w
 string formatted(string const &label, int w, int size, int style);
 
+class LyXView;
 /** Launch a file dialog and return the chosen file.
     filename: a suggested filename.
     title: the title of the dialog.
     pattern: *.ps etc.
     dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
 */
-string const browseFile(string const & filename,
+string const browseFile(LyXView *lv, string const & filename,
                        string const & title,
                        string const & pattern, 
                        std::pair<string,string> const & dir1,
index 779456aef00c4a3cecc3f1d0ae5e7cf8991c47e6..971c5960f0fcde1da828f9b87a1aa2328884aa59 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-06  John Levon  <moz@compsoc.man.ac.uk>
+
+       * insetexternal.C:
+       * figinset.C: use new File Dialog
+
 2001-03-06  Lars Gullik Bjønnes  <larsbj@trylle.birdstep.com>
 
        * insettext.C: changes becuase of ParagraphParameters.
index 53405c0ef34fecc43e9c2322b82bc63642c6cfe6..2b8a109d49fbab980d514c3a14755576ec963082 100644 (file)
@@ -33,6 +33,7 @@
 #include <list>
 #include <algorithm>
 #include <vector>
+#include <utility>
 
 #include <unistd.h>
 #include <csignal>
@@ -47,7 +48,7 @@
 #include "lyx.h"
 #include "lyx_main.h"
 #include "buffer.h"
-#include "filedlg.h"
+#include "frontends/FileDialog.h"
 #include "support/filetools.h"
 #include "LyXView.h" // just because of form_main
 #include "debug.h"
@@ -80,6 +81,8 @@ using std::flush;
 using std::endl;
 using std::ostringstream;
 using std::copy;
+using std::pair;
+using std::make_pair;
 
 extern BufferView * current_view;
 extern FL_OBJECT * figinset_canvas;
@@ -1931,7 +1934,6 @@ void InsetFig::BrowseFile()
 {
        static string current_figure_path;
        static int once = 0;
-       LyXFileDlg fileDlg;
 
        if (lyxerr.debugging()) {
                lyxerr << "Filename: "
@@ -1956,23 +1958,21 @@ void InsetFig::BrowseFile()
                bufclip = AddName (system_lyxdir, "clipart");   
 
 
-       fileDlg.SetButton(0, _("Clipart"), bufclip); 
-       fileDlg.SetButton(1, _("Document"), buf); 
+       FileDialog fileDlg(current_view->owner(), _("Select an EPS figure"),
+               LFUN_SELECT_FILE_SYNC,
+               make_pair(string(_("Clip art")), string(bufclip)),
+               make_pair(string(_("Documents")), string(buf)));
 
        bool error = false;
        do {
-               ProhibitInput(current_view);
-               if (once) {
-                       p = fileDlg.Select(_("EPS Figure"),
-                                          current_figure_path,
-                                          "*ps", string());
-               } else {
-                       p = fileDlg.Select(_("EPS Figure"), buf,
-                                          "*ps", string());
-               }
-               AllowInput(current_view);
+               string const path = (once) ? current_figure_path : buf;
+
+               FileDialog::Result result = fileDlg.Select(path, _("*ps| PostScript documents"));
 
-               if (p.empty()) return;
+               string const p = result.second;
+
+               if (p.empty())
+                       return;
 
                buf = MakeRelPath(p, buf2);
                current_figure_path = OnlyPath(p);
index b15178ee38d09734409a76c01bebb4bc2fca47eb..8bddd24839475b7739521ebcb7adee7f3aa7fe70 100644 (file)
 
 #include FORMS_H_LOCATION
 #include <cstdio>
+#include <utility> 
 
 #include "insetexternal.h"
 #include "ExternalTemplate.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 #include "BufferView.h"
 #include "buffer.h"
-#include "filedlg.h"
+#include "frontends/FileDialog.h"
 #include "lyx_main.h"
 #include "LaTeXFeatures.h"
 #include "support/filetools.h"
@@ -36,7 +37,8 @@ using SigC::slot;
 #endif
 
 using std::endl;
-
+using std::pair;
+using std::make_pair; 
 
 InsetExternal::InsetExternal() 
        : form_external(0)
@@ -128,7 +130,6 @@ void InsetExternal::browseCB(FL_OBJECT * ob, long)
 
        static string current_path;
        static int once = 0;
-       LyXFileDlg fileDlg;
        
        string p = inset->filename;
        string buf = MakeAbsPath(holder->view->buffer()->fileName());
@@ -140,7 +141,11 @@ void InsetExternal::browseCB(FL_OBJECT * ob, long)
                buf = OnlyPath(holder->view->buffer()->fileName());
        }
        
-       fileDlg.SetButton(0, _("Document"), buf); 
+       FileDialog fileDlg(holder->view->owner(), _("Select external file"),
+               LFUN_SELECT_FILE_SYNC,
+               make_pair(string(_("Document")), string(buf)));
+       
+       // FIXME: should have "nice name" for file type e.g. "Xfig files"
 
        /// Determine the template file extension
        ExternalTemplate et = inset->getTemplate(inset->getCurrentTemplate());
@@ -149,18 +154,17 @@ void InsetExternal::browseCB(FL_OBJECT * ob, long)
                regexp = "*";
        }
 
+       regexp += "|";
+
        bool error = false;
        do {
-               if (once) {
-                       p = fileDlg.Select(_("External inset file"),
-                                          current_path,
-                                          regexp, string());
-               } else {
-                       p = fileDlg.Select(_("External inset file"), buf,
-                                          regexp, string());
-               }
+               string const path = (once) ? current_path : buf;
+               FileDialog::Result result = fileDlg.Select(path, regexp);
+
+               if (result.second.empty()) 
+                       return;
 
-               if (p.empty()) return;
+               string p = result.second;
 
                buf = MakeRelPath(p, buf2);
                current_path = OnlyPath(p);
index 601f6a6f2a3ab141afa9ece03010fb41af11a03a..1763bb328c9767c4da1a087186dbe77fc04d1980 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <fstream>
 #include <algorithm>
+#include <utility> 
 #include <iostream>
 
 #include FORMS_H_LOCATION
@@ -24,7 +25,7 @@
 #include "minibuffer.h"
 #include "combox.h"
 #include "bufferlist.h"
-#include "filedlg.h"
+#include "frontends/FileDialog.h"
 #include "lyx_gui_misc.h"
 #include "LyXView.h"
 #include "lastfiles.h"
@@ -44,6 +45,7 @@ using std::cout;
 using std::ios;
 using std::istream_iterator;
 using std::pair;
+using std::make_pair;
 using std::vector;
 using std::sort;
 using std::equal;
@@ -146,103 +148,102 @@ void ShowMessage(Buffer const * buf,
 //
 // File menu
 //
-
 // should be moved to lyxfunc.C
 bool MenuWrite(BufferView * bv, Buffer * buffer)
 {
+       // FIXME: needed ?
        XFlush(fl_get_display());
        if (!buffer->save()) {
                string const fname = buffer->fileName();
                string const s = MakeAbsPath(fname);
                if (AskQuestion(_("Save failed. Rename and try again?"),
                                MakeDisplayPath(s, 50),
                                _("(If not, document is not saved.)"))) {
-                       return MenuWriteAs(bv, buffer);
+                       return WriteAs(bv, buffer);
                }
                return false;
-       } else {
+       } else
                lastfiles->newFile(buffer->fileName());
-       }
        return true;
 }
 
 
+
 // should be moved to BufferView.C
 // Half of this func should be in LyXView, the rest in BufferView.
-bool MenuWriteAs(BufferView * bv, Buffer * buffer)
+bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
 {
-       // Why do we require BufferView::text to be able to write a
-       // document? I see no point in that. (Lgb)
-       //if (!bv->text) return;
-
        string fname = buffer->fileName();
        string oldname = fname;
-       LyXFileDlg fileDlg;
 
-       ProhibitInput(bv);
-       fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-       fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
+       if (filename.empty()) {
 
-       if (!IsLyXFilename(fname))
-               fname += ".lyx";
+               FileDialog fileDlg(bv->owner(), _("Choose a filename to save document as"),
+                       LFUN_WRITEAS,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Templates")), string(lyxrc.template_path)));
 
-       fname = fileDlg.Select(_("Enter Filename to Save Document as"), 
-                              OnlyPath(fname),
-                              "*.lyx", 
-                              OnlyFilename(fname));
+               if (!IsLyXFilename(fname))
+                       fname += ".lyx";
 
-       AllowInput(bv);
+               FileDialog::Result result = fileDlg.Select(OnlyPath(fname), _("*.lyx|LyX Documents (*.lyx)"), OnlyFilename(fname));
 
-       if (fname.empty())
-               return false;
+               if (result.first == FileDialog::Later)
+                       return false;
+
+               fname = result.second;
+
+               if (fname.empty())
+                       return false;
+
+               // Make sure the absolute filename ends with appropriate suffix
+               fname = MakeAbsPath(fname);
+               if (!IsLyXFilename(fname))
+                       fname += ".lyx";
+       } else
+               fname = filename;
 
-       // Make sure the absolute filename ends with appropriate suffix
-       string s = MakeAbsPath(fname);
-       if (!IsLyXFilename(s))
-               s += ".lyx";
 
        // Same name as we have already?
-       if (!buffer->isUnnamed() && s == oldname) {
+       if (!buffer->isUnnamed() && fname == oldname) {
                if (!AskQuestion(_("Same name as document already has:"),
-                                MakeDisplayPath(s, 50),
+                                MakeDisplayPath(fname, 50),
                                 _("Save anyway?")))
                        return false;
                // Falls through to name change and save
        } 
        // No, but do we have another file with this name open?
-       else if (!buffer->isUnnamed() && bufferlist.exists(s)) {
+       else if (!buffer->isUnnamed() && bufferlist.exists(fname)) {
                if (AskQuestion(_("Another document with same name open!"),
-                               MakeDisplayPath(s, 50),
+                               MakeDisplayPath(fname, 50),
                                _("Replace with current document?")))
                        {
-                               bufferlist.close(bufferlist.getBuffer(s));
+                               bufferlist.close(bufferlist.getBuffer(fname));
 
                                // Ok, change the name of the buffer, but don't save!
-                               buffer->setFileName(s);
+                               buffer->setFileName(fname);
                                buffer->markDirty();
 
                                ShowMessage(buffer, _("Document renamed to '"),
-                                               MakeDisplayPath(s), _("', but not saved..."));
-                       }
+                                               MakeDisplayPath(fname), _("', but not saved..."));
+               }
                return false;
        } // Check whether the file exists
        else {
-               FileInfo const myfile(s);
+               FileInfo const myfile(fname);
                if (myfile.isOK() && !AskQuestion(_("Document already exists:"), 
-                                                 MakeDisplayPath(s, 50),
+                                                 MakeDisplayPath(fname, 50),
                                                  _("Replace file?")))
                        return false;
        }
 
        // Ok, change the name of the buffer
-       buffer->setFileName(s);
+       buffer->setFileName(fname);
        buffer->markDirty();
        bool unnamed = buffer->isUnnamed();
        buffer->setUnnamed(false);
-       // And save
-       // Small bug: If the save fails, we have irreversible changed the name
-       // of the document.
-       // Hope this is fixed this way! (Jug)
+
        if (!MenuWrite(bv, buffer)) {
            buffer->setFileName(oldname);
            buffer->setUnnamed(unnamed);
@@ -418,17 +419,23 @@ Buffer * NewLyxFile(string const & filename)
 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
 {
        string fname = f;
-       LyXFileDlg fileDlg;
-       if (!bv->available()) return;
+
+       if (!bv->available()) 
+               return;
      
        if (fname.empty()) {
-               ProhibitInput(bv);
-               fname = fileDlg.Select(_("File to Insert"), 
-                                      bv->owner()->buffer()->filepath,
-                                      "*");
-               AllowInput(bv);
-               if (fname.empty()) return;
+               FileDialog fileDlg(bv->owner(), _("Select file to insert"),
+                       (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
+               FileDialog::Result result = fileDlg.Select(bv->owner()->buffer()->filepath);
+
+               if (result.first == FileDialog::Later)
+                       return;
+
+               fname = result.second;
+
+               if (fname.empty()) 
+                       return;
        }
 
        FileInfo fi(fname);
@@ -557,16 +564,6 @@ void MenuInsertLabel(BufferView * bv, string const & arg)
 }
 
 
-// This is _only_ used in Toolbar_pimpl.C, move it there and get rid of
-// current_view. (Lgb)
-void LayoutsCB(int sel, void *, Combox *)
-{
-       string const tmp = tostr(sel);
-       current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
-                                                     tmp);
-}
-
-
 void MenuLayoutSave(BufferView * bv)
 {
        if (!bv->available())
index 362f9b0d1873c297772e639f34e7c3886231e539..619d399e425ffd4ba7a4f63fe5eea3145eccb011 100644 (file)
@@ -25,8 +25,8 @@ void ShowMessage(Buffer const * buf,
                 string const & msg3 = string(), int delay = 6);
 ///
 bool MenuWrite(BufferView * bv, Buffer * buffer);
-///
-bool MenuWriteAs(BufferView * bv, Buffer * buffer);
+/// write the given file, or ask if no name given
+bool WriteAs(BufferView * bv, Buffer * buffer, const string & filename = string());
 ///
 int MenuRunChktex(Buffer * buffer);
 ///
@@ -40,8 +40,6 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph);
 ///
 void MenuInsertLabel(BufferView * bv, string const & arg);
 ///
-void LayoutsCB(int sel, void *, Combox *);
-///
 void MenuLayoutCharacter();
 ///
 void MenuLayoutSave(BufferView * bv);
index 2b1f9e03b649a1e6c1f88b9134ad81184df7a270..ce6ff5a939170fc5a6e67659b84cf5a706708404 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <time.h>
 #include <locale.h>
+#include <utility> 
+#include <algorithm> 
 
 #include <cstdlib>
 #include <cctype>
@@ -60,7 +62,6 @@
 #include "minibuffer.h"
 #include "vspace.h"
 #include "LyXView.h"
-#include "filedlg.h"
 #include "lyx_gui_misc.h"
 #include "support/filetools.h"
 #include "support/FileInfo.h"
@@ -76,6 +77,7 @@
 #include "layout.h"
 #include "WorkArea.h"
 #include "bufferview_funcs.h"
+#include "frontends/FileDialog.h"
 #include "frontends/Dialogs.h"
 #include "frontends/Toolbar.h"
 #include "frontends/Menubar.h"
@@ -88,6 +90,7 @@
 #include "lyxfind.h"
 
 using std::pair;
+using std::make_pair; 
 using std::endl;
 using std::find_if;
 
@@ -692,6 +695,8 @@ string const LyXFunc::Dispatch(int ac,
                }
        }
 
+       Assert(action != LFUN_SELECT_FILE_SYNC);
+
        switch (action) {
                // --- Misc -------------------------------------------
        case LFUN_WORDFINDFORWARD  : 
@@ -793,10 +798,6 @@ string const LyXFunc::Dispatch(int ac,
                MenuNew(true);
                break;
                
-       case LFUN_MENUOPEN:
-               MenuOpen();
-               break;
-               
        case LFUN_CLOSEBUFFER:
                CloseBuffer();
                break;
@@ -807,19 +808,12 @@ string const LyXFunc::Dispatch(int ac,
                                                    MakeDisplayPath(owner->buffer()->fileName()),
                                                    "...");
                        MenuWrite(owner->view(), owner->buffer());
-                       //owner->getMiniBuffer()-> {
-                       //      Set(_("Document saved as"),
-                       //          MakeDisplayPath(owner->buffer()->fileName()));
-                       //} else {
-                       //owner->getMiniBuffer()->Set(_("Save failed!"));
-                       //}
-               } else {
-                       MenuWriteAs(owner->view(), owner->buffer());
-               }
+               } else
+                       WriteAs(owner->view(), owner->buffer());
                break;
                
-       case LFUN_MENUWRITEAS:
-               MenuWriteAs(owner->view(), owner->buffer());
+       case LFUN_WRITEAS:
+               WriteAs(owner->view(), owner->buffer(), argument);
                break;
                
        case LFUN_MENURELOAD:
@@ -1114,7 +1108,7 @@ string const LyXFunc::Dispatch(int ac,
        break;
                        
        case LFUN_FILE_OPEN:
-               owner->view()->buffer(bufferlist.loadLyXFile(argument));
+               Open(argument);
                break;
 
        case LFUN_LATEX_LOG:
@@ -1146,11 +1140,7 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_LAYOUT_PARAGRAPH:
-#ifdef USE_OLD_PARAGRAPH_LAYOUT
-               MenuLayoutParagraph();
-#else
                owner->getDialogs()->showLayoutParagraph();
-#endif
                break;
                
        case LFUN_LAYOUT_CHARACTER:
@@ -1537,7 +1527,6 @@ void LyXFunc::setupLocalKeymap()
 void LyXFunc::MenuNew(bool fromTemplate)
 {
        string initpath = lyxrc.document_path;
-       LyXFileDlg fileDlg;
 
        if (owner->view()->available()) {
                string const trypath = owner->buffer()->filepath;
@@ -1550,14 +1539,14 @@ void LyXFunc::MenuNew(bool fromTemplate)
        string s;
        
        if (lyxrc.new_ask_filename) {
-               ProhibitInput(owner->view());
-               fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-               fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
-               string fname = fileDlg.Select(_("Enter Filename for new document"), 
-                                      initpath, "*.lyx", _("newfile"));
-               AllowInput(owner->view());
+               FileDialog fileDlg(owner, _("Enter filename for new document"),
+                       LFUN_SELECT_FILE_SYNC,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Templates")), string(lyxrc.template_path)));
+
+               FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx|LyX Documents (*.lyx)"), _("newfile"));
        
-               if (fname.empty()) {
+               if (result.second.empty()) {
                        owner->getMiniBuffer()->Set(_("Canceled."));
                        lyxerr.debug() << "New Document Cancelled." << endl;
                        return;
@@ -1565,7 +1554,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
        
                // get absolute path of file and make sure the filename ends
                // with .lyx
-               s = MakeAbsPath(fname);
+               s = MakeAbsPath(result.second);
                if (!IsLyXFilename(s))
                        s += ".lyx";
 
@@ -1624,12 +1613,20 @@ void LyXFunc::MenuNew(bool fromTemplate)
        // The template stuff
        string templname;
        if (fromTemplate) {
-               ProhibitInput(owner->view());
-               string const fname = fileDlg.Select(_("Choose template"),
-                                                   lyxrc.template_path,
-                                                   "*.lyx");
-               AllowInput(owner->view());
-               if (fname.empty()) return;
+               FileDialog fileDlg(owner, _("Select template file"),
+                       LFUN_SELECT_FILE_SYNC,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Templates")), string(lyxrc.template_path)));
+
+               FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx|LyX Documents (*.lyx)"));
+       
+               if (result.first == FileDialog::Later)
+                       return;
+
+               string const fname = result.second;
+
+               if (fname.empty()) 
+                       return;
                 templname = fname;
        }
   
@@ -1639,10 +1636,9 @@ void LyXFunc::MenuNew(bool fromTemplate)
 }
 
 
-void LyXFunc::MenuOpen()
+void LyXFunc::Open(string const & fname)
 {
        string initpath = lyxrc.document_path;
-       LyXFileDlg fileDlg;
   
        if (owner->view()->available()) {
                string const trypath = owner->buffer()->filepath;
@@ -1651,20 +1647,28 @@ void LyXFunc::MenuOpen()
                        initpath = trypath;
        }
 
-       // launches dialog
-       ProhibitInput(owner->view());
-       fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-       fileDlg.SetButton(1, _("Examples"), 
-                         AddPath(system_lyxdir, "examples"));
-       string filename = fileDlg.Select(_("Select Document to Open"),
-                                        initpath, "*.lyx");
-       AllowInput(owner->view());
+       string filename;
  
-       // check selected filename
-       if (filename.empty()) {
-               owner->getMiniBuffer()->Set(_("Canceled."));
-               return;
-       }
+       if (fname.empty()) {
+               FileDialog fileDlg(owner, _("Select document to open"),
+                       LFUN_FILE_OPEN,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
+
+               FileDialog::Result result = fileDlg.Select(initpath, "*.lyx|LyX Documents (*.lyx)");
+       
+               if (result.first == FileDialog::Later)
+                       return;
+
+               filename = result.second;
+               // check selected filename
+               if (filename.empty()) {
+                       owner->getMiniBuffer()->Set(_("Canceled."));
+                       return;
+               }
+       } else
+               filename = fname;
 
        // get absolute path of file and make sure the filename ends
        // with .lyx
@@ -1698,7 +1702,6 @@ void LyXFunc::doImport(string const & argument)
 
        if (filename.empty()) { // need user interaction
                string initpath = lyxrc.document_path;
-               LyXFileDlg fileDlg;
                
                if (owner->view()->available()) {
                        string const trypath = owner->buffer()->filepath;
@@ -1707,16 +1710,23 @@ void LyXFunc::doImport(string const & argument)
                                initpath = trypath;
                }
 
-               // launches dialog
-               ProhibitInput(owner->view());
-               fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-               fileDlg.SetButton(1, _("Examples"), 
-                                       AddPath(system_lyxdir, "examples"));
                string const text = _("Select ") + formats.PrettyName(format)
                        + _(" file to import");
-               string const extension = "*." + formats.Extension(format);
-               filename = fileDlg.Select(text, initpath, extension);
-               AllowInput(owner->view());
+
+               FileDialog fileDlg(owner, text, 
+                       LFUN_IMPORT,
+                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
+                       make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
+                       
+               string const extension = "*." + formats.Extension(format) + "| " +
+                       formats.PrettyName(format) + " (*." + formats.Extension(format) + ")";
+
+               FileDialog::Result result = fileDlg.Select(initpath, extension);
+
+               if (result.first == FileDialog::Later)
+                       return;
+
+               filename = result.second;
  
                // check selected filename
                if (filename.empty()) 
index 0f796b768e48c9b3365b4a4ee58d574bb5bbf4b4..b4948a56c720c4aac5653e87a7e8a12242e6d404 100644 (file)
@@ -118,7 +118,7 @@ private:
        void MenuNew(bool fromTemplate);
 
        ///
-       void MenuOpen();
+       void Open(string const &);
 
        ///
        void doImport(string const &);