On Fri, Jun 21, 2002 at 12:09:34PM -0700, Matt Brennan wrote:

> 
> As I recal, in v.1.1, you were able to create a new file by typing its
> name in the File->Open... popup.  Now in v. 1.2 this is no longer
> possible.  Hopefully, it should be easy to carry this feature forward to
> v.1.2.1

JMarc, OK for 1.2 branch ?

regards
john

Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.314.2.3
diff -u -r1.314.2.3 lyxfunc.C
--- lyxfunc.C   26 Jul 2002 10:19:09 -0000      1.314.2.3
+++ lyxfunc.C   1 Aug 2002 02:12:20 -0000
@@ -1887,15 +1887,26 @@
        // get absolute path of file and add ".lyx" to the filename if
        // necessary
        string const fullpath = FileSearch(string(), filename, "lyx");
-       if (fullpath.empty()) {
-               Alert::alert(_("Error"), _("Could not find file"), filename);
-               return;
+       if (!fullpath.empty()) {
+               filename = fullpath;
        }
 
-       filename = fullpath;
-
-       // loads document
        string const disp_fn(MakeDisplayPath(filename));
+
+       // if the file doesn't exist, let the user create one
+       FileInfo const f(filename, true);
+       if (!f.exist()) {
+               if (!Alert::askQuestion(_("No such file"), disp_fn, 
+                       _("Start a new document with this filename ?"))) {
+                       owner->message(_("Canceled"));
+                       return;
+               }
+               Buffer * buffer =  bufferlist.newFile(filename, "");
+               // the user specifically chose this name. Believe them.
+               buffer->setUnnamed(false);
+               owner->view()->buffer(buffer);
+               return;
+       }
 
        ostringstream str;
        str << _("Opening document") << ' ' << disp_fn << "...";
-- 
"The simpler it is, the harder it is." 
        - Tim Van Holder

Reply via email to