From d6dd467219b45efee31c7597256460921768212c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 21 Jan 2002 10:47:19 +0000 Subject: [PATCH] forminclude patch from herbert git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3428 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 2 +- src/frontends/controllers/ChangeLog | 3 +++ src/frontends/controllers/ControlInclude.C | 13 +++++++++++++ src/frontends/controllers/ControlInclude.h | 3 +++ src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/FormInclude.C | 12 ++++++++---- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index c99cc6e07c..92d85d025c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,7 +9,6 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C -src/ext_l10n.h src/figure_form.C src/figureForm.C src/FontLoader.C @@ -64,6 +63,7 @@ src/frontends/qt2/QRef.C src/frontends/qt2/QSearch.C src/frontends/qt2/QSpellchecker.C src/frontends/qt2/QTabularCreate.C +src/frontends/qt2/QTexinfo.C src/frontends/qt2/QThesaurus.C src/frontends/qt2/QToc.C src/frontends/qt2/QURL.C diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 9d25518941..f105fbea13 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,5 +1,8 @@ 2002-01-20 Herbert Voss + * ControlInclude.[Ch]: better control of unexistings files + when entered without the browser + * ControlGraphic.C (Browse): add extension "ps" when browsing for a filename diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 4d018f0916..ea92ebed1c 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -20,6 +20,7 @@ #include "ControlInclude.h" #include "ControlInset.tmpl" #include "buffer.h" +#include "Alert.h" #include "BufferView.h" #include "Dialogs.h" #include "LyXView.h" @@ -80,3 +81,15 @@ void ControlInclude::load(string const & file) { lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file); } + + +bool const ControlInclude::fileExists(string const & file) +{ + string const fileWithAbsPath = MakeAbsPath(file, OnlyPath(params().masterFilename_)); + if (IsFileReadable(fileWithAbsPath)) + return true; + else + Alert::alert(_("File doesn't exists!")); + return false; +} + diff --git a/src/frontends/controllers/ControlInclude.h b/src/frontends/controllers/ControlInclude.h index 57a52a7d87..566f35f4cd 100644 --- a/src/frontends/controllers/ControlInclude.h +++ b/src/frontends/controllers/ControlInclude.h @@ -43,6 +43,9 @@ public: /// load a file void load(string const & file); + /// test if file exist + bool const fileExists(string const & file); + private: /// Dispatch the changed parameters to the kernel. virtual void applyParamsToInset(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index bd3873e536..69c4fec606 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-01-20 Herbert Voss + + * FormInclude.[C]: better control of unexistings files + when entered without the browser + 2002-01-20 Jean-Marc Lasgouttes * Toolbar_pimpl.C (update): disable layout combox when LFUN_LAYOUT diff --git a/src/frontends/xforms/FormInclude.C b/src/frontends/xforms/FormInclude.C index 4387b41262..636574b121 100644 --- a/src/frontends/xforms/FormInclude.C +++ b/src/frontends/xforms/FormInclude.C @@ -90,8 +90,11 @@ void FormInclude::apply() { controller().params().noload = fl_get_button(dialog_->check_typeset); - controller().params().cparams. - setContents(fl_get_input(dialog_->input_filename)); + string const file = fl_get_input(dialog_->input_filename); + if (controller().fileExists(file)) + controller().params().cparams.setContents(file); + else + controller().params().cparams.setContents(""); if (fl_get_button(dialog_->check_useinput)) controller().params().flag = InsetInclude::INPUT; @@ -127,8 +130,9 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long) } else if (ob == dialog_->button_load) { string const in_name = fl_get_input(dialog_->input_filename); - if (!strip(in_name).empty()) { - ApplyButton(); + if (!strip(in_name).empty() && controller().fileExists(in_name)) { +// ApplyButton(); + OKButton(); controller().load(strip(in_name)); action = ButtonPolicy::SMI_NOOP; } -- 2.39.2