From 80db139a76ca67d6b12edfd07ec88256230280d3 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 21 Feb 2003 12:22:25 +0000 Subject: [PATCH] The file dialog browser doesn't need a LyXView... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6223 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 3 +-- src/ChangeLog | 7 +++++++ src/frontends/ChangeLog | 3 +++ src/frontends/FileDialog.h | 13 ++++--------- src/frontends/controllers/ChangeLog | 13 +++++++++++++ src/frontends/controllers/ControlBibtex.C | 2 +- src/frontends/controllers/ControlExternal.C | 2 +- src/frontends/controllers/ControlGraphics.C | 2 +- src/frontends/controllers/ControlInclude.C | 2 +- src/frontends/controllers/ControlPrefs.C | 12 ++++++------ src/frontends/controllers/ControlPrint.C | 2 +- src/frontends/controllers/helper_funcs.C | 12 ++++++------ src/frontends/controllers/helper_funcs.h | 8 +++----- src/frontends/gnome/ChangeLog | 4 ++++ src/frontends/gnome/FileDialog.C | 4 ++-- src/frontends/qt2/ChangeLog | 4 ++++ src/frontends/qt2/FileDialog.C | 6 +++--- src/frontends/xforms/ChangeLog | 8 ++++++++ src/frontends/xforms/FileDialog.C | 6 +++--- src/frontends/xforms/FormFiledialog.C | 4 ++-- src/frontends/xforms/FormFiledialog.h | 2 +- src/lyx_cb.C | 5 ++--- src/lyxfunc.C | 6 +++--- 23 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index b974d55d47..734dcebeb6 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -872,8 +872,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) initpath = trypath; } - FileDialog fileDlg(bv_->owner(), - _("Select LyX document to insert"), + FileDialog fileDlg(_("Select LyX document to insert"), LFUN_FILE_INSERT, make_pair(string(_("Documents|#o#O")), string(lyxrc.document_path)), diff --git a/src/ChangeLog b/src/ChangeLog index 954c50d7d7..ca3329bcba 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-02-21 Angus Leeming + + * BufferView_pimpl.C (MenuInsertLyXFile): + * lyx_cb.C (WriteAs, getContentsOfAsciiFile): + * lyxfunc.C (menuNew, open, doImport): + no longer pass a LyXView & to fileDlg. + 2003-02-21 Angus Leeming * BufferView_pimpl.C: replace insetbib.h with insetbibtex.h. diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index a95b92dea1..10084e0146 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -2,6 +2,9 @@ * Dialogs.h: remove forward declarations of InsetBibKey, InsetBibtex. + * FileDialog.h: don't pass LyXView to the c-tor. + Don't store a LyXView &. + 2003-02-14 John Levon * LyXView.h: prohibit/allowInput() -> busy(bool) diff --git a/src/frontends/FileDialog.h b/src/frontends/FileDialog.h index 06397a848e..6355bd39cf 100644 --- a/src/frontends/FileDialog.h +++ b/src/frontends/FileDialog.h @@ -20,8 +20,6 @@ #include "LString.h" -class LyXView; - /** * \class FileDialog * \brief GUI-I definition of file dialog interface @@ -42,9 +40,9 @@ public: typedef std::pair 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 open(), + * Constructs a file dialog with title \param title. + * If \param a is \const LFUN_SELECT_FILE_SYNC then a value + * will be returned immediately upon performing a open(), * otherwise a callback Dispatch() will be invoked with the filename as * argument, of action \param a. * @@ -52,7 +50,7 @@ public: * additional directories in the navigation (an empty * directory is interpreted as getcwd()) */ - FileDialog(LyXView * lv, string const & title, + FileDialog(string const & title, kb_action a = LFUN_SELECT_FILE_SYNC, Button b1 = Button(string(), string()), Button b2 = Button(string(), string())); @@ -104,9 +102,6 @@ public: Private * private_; private: - /// our LyXView - LyXView * lv_; - /// the dialog title string title_; diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index ab544de3b2..3e6ee386ce 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,16 @@ +2003-02-21 Angus Leeming + + * ControlBibtex.C (Browse): + * ControlExternal.C (Browse): + * ControlGraphics.C (Browse): + * ControlInclude.C (Browse): + * ControlPrefs.C (browsebind, browseUI, browsekbmap, browsedict, + browse, browsedir): + * ControlPrint.C (Browse): + don't pass a LyXView & to browseFile et al. + * helper_funcs.[Ch] (browseFile, browseRelFile, browseDir): + don't pass a LyXView & to fileDlg. + 2003-02-17 John Levon * ControlDialog.tmpl: build dialog before calling setParams diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 4fb819857e..e29ff0bc20 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -59,7 +59,7 @@ string const ControlBibtex::Browse(string const & in_name, { pair dir1(_("Documents|#o#O"), string(lyxrc.document_path)); - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(in_name, buffer()->filePath(), title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 07d5d3e6bb..3572b00320 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -151,5 +151,5 @@ string const ControlExternal::Browse(string const & input) const std::pair dir1(N_("Documents|#o#O"), string(lyxrc.document_path)); - return browseRelFile(&lv_, input, bufpath, title, pattern, false, dir1); + return browseRelFile(input, bufpath, title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index ba9d275790..146980e0ca 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -89,7 +89,7 @@ string const ControlGraphics::Browse(string const & in_name) pair dir1(_("Clipart|#C#c"), clipdir); pair dir2(_("Documents|#o#O"), string(lyxrc.document_path)); // Show the file browser dialog - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(in_name, buffer()->filePath(), title, "*.*", false, dir1, dir2); } diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 2530b7b7f3..4e6282c677 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -69,7 +69,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type) string const docpath = OnlyPath(params().masterFilename_); - return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1); + return browseRelFile(in_name, docpath, title, pattern, false, dir1); } diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index ec142632d0..74888b16d4 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -69,7 +69,7 @@ string const ControlPrefs::browsebind(string const & file) name = _("User Bind|#U#u"); pair dir2(name, dir); - return browseFile(&lv_, file, _("Choose bind file"), "*.bind", false, dir1, dir2); + return browseFile(file, _("Choose bind file"), "*.bind", false, dir1, dir2); } @@ -85,7 +85,7 @@ string const ControlPrefs::browseUI(string const & file) name = _("User UI|#U#u"); pair dir2(name, dir); - return browseFile(&lv_, file, _("Choose UI file"), "*.ui", false, dir1, dir2); + return browseFile(file, _("Choose UI file"), "*.ui", false, dir1, dir2); } @@ -95,25 +95,25 @@ string const ControlPrefs::browsekbmap(string const & file) string const name = _("Key maps|#K#k"); pair dir1(name, dir); - return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", false, dir1); + return browseFile(file, _("Choose keyboard map"), "*.kmap", false, dir1); } string const ControlPrefs::browsedict(string const & file) { - return browseFile(&lv_, file, _("Choose personal dictionary"), "*.ispell"); + return browseFile(file, _("Choose personal dictionary"), "*.ispell"); } string const ControlPrefs::browse(string const & file, string const & title) { - return browseFile(&lv_, file, title, "*", true); + return browseFile(file, title, "*", true); } string const ControlPrefs::browsedir(string const & path, string const & title) { - return browseDir(&lv_, path, title); + return browseDir(path, title); } diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index 7ad3d926a3..d6fb502749 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -76,7 +76,7 @@ string const ControlPrint::Browse(string const & in_name) string const pattern = "*.ps"; // Show the file browser dialog - return browseRelFile(&lv_, in_name, buffer()->filePath(), + return browseRelFile(in_name, buffer()->filePath(), title, pattern, true); } diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index 4d3f6e683e..34ac0f1207 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -26,7 +26,7 @@ using std::vector; using std::make_pair; -string const browseFile(LyXView * lv, string const & filename, +string const browseFile(string const & filename, string const & title, string const & pattern, bool save, @@ -37,7 +37,7 @@ string const browseFile(LyXView * lv, string const & filename, if (!filename.empty()) lastPath = OnlyPath(filename); - FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2); + FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2); FileDialog::Result result; @@ -66,7 +66,7 @@ string const browseFile(LyXView * lv, string const & filename, } -string const browseRelFile(LyXView * lv, string const & filename, +string const browseRelFile(string const & filename, string const & refpath, string const & title, string const & pattern, @@ -76,7 +76,7 @@ string const browseRelFile(LyXView * lv, string const & filename, { string const fname = MakeAbsPath(filename, refpath); - string const outname = browseFile(lv, fname, title, pattern, save, + string const outname = browseFile(fname, title, pattern, save, dir1, dir2); string const reloutname = MakeRelPath(outname, refpath); if (prefixIs(reloutname, "../")) @@ -86,7 +86,7 @@ string const browseRelFile(LyXView * lv, string const & filename, } -string const browseDir(LyXView * lv, string const & pathname, +string const browseDir(string const & pathname, string const & title, pair const & dir1, pair const & dir2) @@ -95,7 +95,7 @@ string const browseDir(LyXView * lv, string const & pathname, if (!pathname.empty()) lastPath = OnlyPath(pathname); - FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2); + FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2); FileDialog::Result result; diff --git a/src/frontends/controllers/helper_funcs.h b/src/frontends/controllers/helper_funcs.h index 556595482f..6288ef1eea 100644 --- a/src/frontends/controllers/helper_funcs.h +++ b/src/frontends/controllers/helper_funcs.h @@ -18,8 +18,6 @@ #include // pair #include // pair -class LyXView; - /** Launch a file dialog and return the chosen file. filename: a suggested filename. title: the title of the dialog. @@ -27,7 +25,7 @@ class LyXView; dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog. */ string const -browseFile(LyXView * lv, string const & filename, +browseFile(string const & filename, string const & title, string const & pattern, bool save = false, @@ -44,7 +42,7 @@ browseFile(LyXView * lv, string const & filename, intended to be useful for insets which encapsulate files/ */ string const -browseRelFile(LyXView * lv, string const & filename, +browseRelFile(string const & filename, string const & refpath, string const & title, string const & pattern, @@ -61,7 +59,7 @@ browseRelFile(LyXView * lv, string const & filename, dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog. */ string const -browseDir(LyXView * lv, string const & pathname, +browseDir(string const & pathname, string const & title, std::pair const & dir1 = std::make_pair(string(), string()), diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index 1ae6db7cbc..9b33c9939f 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,7 @@ +2003-02-21 Angus Leeming + + * FileDialog.C (FileDialog): no need for LyXView *. + 2003-02-14 John Levon * FileDialog.C: remove spurious allow/prohibitInput() diff --git a/src/frontends/gnome/FileDialog.C b/src/frontends/gnome/FileDialog.C index c9c2a65380..f8494d0389 100644 --- a/src/frontends/gnome/FileDialog.C +++ b/src/frontends/gnome/FileDialog.C @@ -72,10 +72,10 @@ void FileDialog::Private::button_clicked(bool canceled) // FileDialog -FileDialog::FileDialog(LyXView * lv, string const & title, kb_action a, +FileDialog::FileDialog(string const & title, kb_action a, Button /*b1*/, Button /*b2*/) : private_(new Private(title)) - , lv_(lv), title_(title), success_(a) + , title_(title), success_(a) { private_->set_modal(LFUN_SELECT_FILE_SYNC == a); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 09336bbd69..8a192aefcd 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-02-21 Angus Leeming + + * FileDialog.C (FileDialog): no need for LyXView *. + 2003-02-17 John Levon * QSpellchecker.h: diff --git a/src/frontends/qt2/FileDialog.C b/src/frontends/qt2/FileDialog.C index a5a5ba95f1..50c531c77f 100644 --- a/src/frontends/qt2/FileDialog.C +++ b/src/frontends/qt2/FileDialog.C @@ -34,9 +34,9 @@ struct FileDialog::Private { }; -FileDialog::FileDialog(LyXView * lv, string const & t, +FileDialog::FileDialog(string const & t, kb_action s, Button b1, Button b2) - : private_(new FileDialog::Private), lv_(lv), title_(t), success_(s) + : private_(new FileDialog::Private), title_(t), success_(s) { private_->b1 = b1; private_->b2 = b2; @@ -130,4 +130,4 @@ FileDialog::Result const FileDialog::opendir(string const & path, result.second = string(dlg.selectedFile().data()); dlg.hide(); return result; -} \ No newline at end of file +} diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6bb61d7fab..8605a20ed5 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2003-02-21 Angus Leeming + + * FileFialog.C (c-tor): no longer receives a LyXView &, nor passes + it to the Provate c-tor. + * FormFiledialog.[Ch] (c-tor): no longer receives a LyXView &. + Dialogs::redrawGUI is a static member, so can reference it without + a specific instance. + 2003-02-17 John Levon * FormSpellchecker.h: diff --git a/src/frontends/xforms/FileDialog.C b/src/frontends/xforms/FileDialog.C index 0cb76e10c0..807476c191 100644 --- a/src/frontends/xforms/FileDialog.C +++ b/src/frontends/xforms/FileDialog.C @@ -26,10 +26,10 @@ 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) +FileDialog::FileDialog(string const &t, kb_action s, Button b1, Button b2) + : private_(0), title_(t), success_(s) { - private_ = new FileDialog::Private(lv->getDialogs()); + private_ = new FileDialog::Private(); private_->SetButton(0, b1.first, b1.second); private_->SetButton(1, b2.first, b2.second); diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index 2fea4dae90..0e9120de3e 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -381,7 +381,7 @@ void FileDialog::Private::SetInfoLine(string const & line) } -FileDialog::Private::Private(Dialogs & dia) +FileDialog::Private::Private() { directory_ = MakeAbsPath(string(".")); mask_ = '*'; @@ -420,7 +420,7 @@ FileDialog::Private::Private(Dialogs & dia) fl_hide_object(file_dlg_form_->User1); fl_hide_object(file_dlg_form_->User2); - r_ = dia.redrawGUI().connect(boost::bind(&FileDialog::Private::redraw, this)); + r_ = Dialogs::redrawGUI().connect(boost::bind(&FileDialog::Private::redraw, this)); } diff --git a/src/frontends/xforms/FormFiledialog.h b/src/frontends/xforms/FormFiledialog.h index 6467603892..c670f3d05b 100644 --- a/src/frontends/xforms/FormFiledialog.h +++ b/src/frontends/xforms/FormFiledialog.h @@ -52,7 +52,7 @@ class FD_filedialog; class FileDialog::Private : public boost::signals::trackable { public: /// - Private(Dialogs &); + Private(); /// ~Private(); diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 4451fba912..e357831411 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -104,8 +104,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename) if (filename.empty()) { - FileDialog fileDlg(bv->owner(), - _("Choose a filename to save document as"), + FileDialog fileDlg(_("Choose a filename to save document as"), LFUN_WRITEAS, make_pair(string(_("Documents|#o#O")), string(lyxrc.document_path)), @@ -420,7 +419,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap string fname = f; if (fname.empty()) { - FileDialog fileDlg(bv->owner(), _("Select file to insert"), + FileDialog fileDlg(_("Select file to insert"), (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII); FileDialog::Result result = fileDlg.open(bv->owner()->buffer()->filePath()); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9cdd982fab..2b0a43513a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1644,7 +1644,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate) // The template stuff string templname; if (fromTemplate) { - FileDialog fileDlg(owner, _("Select template file"), + FileDialog fileDlg(_("Select template file"), LFUN_SELECT_FILE_SYNC, make_pair(string(_("Documents|#o#O")), string(lyxrc.document_path)), @@ -1683,7 +1683,7 @@ void LyXFunc::open(string const & fname) string filename; if (fname.empty()) { - FileDialog fileDlg(owner, _("Select document to open"), + FileDialog fileDlg(_("Select document to open"), LFUN_FILE_OPEN, make_pair(string(_("Documents|#o#O")), string(lyxrc.document_path)), @@ -1788,7 +1788,7 @@ void LyXFunc::doImport(string const & argument) + _(" file to import");; #endif - FileDialog fileDlg(owner, text, + FileDialog fileDlg(text, LFUN_IMPORT, make_pair(string(_("Documents|#o#O")), string(lyxrc.document_path)),