Jean-Marc Lasgouttes wrote:

>>
>> thanks, this did it. The one from John maybe the
>> cleaner solution, but I don't know ...
> 
> 
> 
> Except that you do not have access to the buffer at this point.
> 
> 
>> Here is a small patch for the above problem from
>> Michael's buglist.
>>
> 
> 
> The patch is malformed:
> 
> ginette: patch -p0 <~/include.diff
> patching file src/frontends/controllers/ChangeLog
> patch: **** malformed patch at line 14: Index:
> src/frontends/controllers/ControlInclude.C


I suppose that I got confused with the changlogs.

here is the next try against cvs from 0.30am


HErbert


-- 
http://www.lyx.org/help/
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.122
diff -u -r1.122 ChangeLog
--- src/frontends/controllers/ChangeLog 2002/01/20 16:07:42     1.122
+++ src/frontends/controllers/ChangeLog 2002/01/20 23:33:01
@@ -1,5 +1,8 @@
 2002-01-20  Herbert Voss  <[EMAIL PROTECTED]>
 
+       * ControlInclude.[Ch]: better control of unexistings files
+       when entered without the browser
+
        * ControlGraphic.C (Browse): add extension "ps" when browsing for
        a filename
 
Index: src/frontends/controllers/ControlInclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlInclude.C,v
retrieving revision 1.13
diff -u -r1.13 ControlInclude.C
--- src/frontends/controllers/ControlInclude.C  2002/01/16 22:17:38     1.13
+++ src/frontends/controllers/ControlInclude.C  2002/01/20 23:33:01
@@ -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 @@
 {
        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;
+}
+
Index: src/frontends/controllers/ControlInclude.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlInclude.h,v
retrieving revision 1.5
diff -u -r1.5 ControlInclude.h
--- src/frontends/controllers/ControlInclude.h  2001/07/25 12:37:43     1.5
+++ src/frontends/controllers/ControlInclude.h  2002/01/20 23:33:01
@@ -43,6 +43,9 @@
        /// 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();
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.257
diff -u -r1.257 ChangeLog
--- src/frontends/xforms/ChangeLog      2002/01/20 23:17:17     1.257
+++ src/frontends/xforms/ChangeLog      2002/01/20 23:33:02
@@ -1,3 +1,8 @@
+2002-01-20  Herbert Voss  <[EMAIL PROTECTED]>
+
+       * FormInclude.[C]: better control of unexistings files
+       when entered without the browser
+
 2002-01-20  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
        * Toolbar_pimpl.C (update): disable layout combox when LFUN_LAYOUT
Index: src/frontends/xforms/FormInclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormInclude.C,v
retrieving revision 1.15
diff -u -r1.15 FormInclude.C
--- src/frontends/xforms/FormInclude.C  2001/07/25 12:37:43     1.15
+++ src/frontends/xforms/FormInclude.C  2002/01/20 23:33:02
@@ -90,8 +90,11 @@
 {
        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 @@
 
        } 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;
                }

Reply via email to