]> git.lyx.org Git - lyx.git/commitdiff
* Use JMarc's browseRelFiles rather than browseFiles.
authorAngus Leeming <leeming@lyx.org>
Fri, 22 Mar 2002 15:24:32 +0000 (15:24 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 22 Mar 2002 15:24:32 +0000 (15:24 +0000)
* Prevent activation of Ok,Apply in graphics dialog when file is not found
* Partial fix for bug 229. Still need to emit updateParagraph when leaving
  an inset.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3814 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlGraphics.h
src/frontends/controllers/ControlPrint.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormParagraph.C
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPrint.C
src/insets/ChangeLog
src/insets/insettext.C

index 6a3423d8a91bba1ac9baa6cf1a5aa7bd9fabe976..8cb33a37b03f88fb432033dd9955e2b9e1d0aa26 100644 (file)
@@ -1,3 +1,11 @@
+2002-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlBibtex.C (Browse):
+       * ControlGraphics.C (Browse):
+       * ControlPrint.C (Browse):  use Jean-Marc's browseRelFile.
+
+       * ControlGraphics.[Ch]: replace checkFilename with isFilenameValid.
+
 2002-03-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * most files: ws cleanup
index 0175c942a3044d350b9e5b67759e011e867d5281..a920c66e2fe30c485416a900d1161f5533e69b41 100644 (file)
@@ -66,5 +66,6 @@ string const ControlBibtex::Browse(string const & in_name,
                                   string const & pattern)
 {
        pair<string, string> dir1(N_("Documents|#o#O"), string(lyxrc.document_path));
-       return browseFile(&lv_, in_name, title, pattern, dir1);
+       return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
+                            title, pattern, dir1);
 }
index c488988803efff0a7113e5fed30e2bba7ea562cb..b1de9231ad39bbedf71bc4f6dfd806e4603419c1 100644 (file)
@@ -24,6 +24,7 @@
 #include "ControlGraphics.h"
 #include "ControlInset.tmpl"
 #include "buffer.h"
+#include "BufferView.h"
 #include "Dialogs.h"
 #include "LyXView.h"
 #include "gettext.h"
 #include "insets/insetgraphicsParams.h" // need operator!=()
 
 #include "support/FileInfo.h"  // for FileInfo
-#include "helper_funcs.h"      // for browseFile
+#include "helper_funcs.h"
 #include "support/lstrings.h"
 #include "support/filetools.h" // for AddName, zippedFile
-#include "frontends/Alert.h"
-#include "BufferView.h"
 
 using std::pair;
 using std::make_pair;
@@ -98,7 +97,8 @@ string const ControlGraphics::Browse(string const & in_name)
        pair<string, string> dir1(N_("Clipart|#C#c"), clipdir);
        pair<string, string> dir2(N_("Documents|#o#O"), string(lyxrc.document_path));
        // Show the file browser dialog
-       return browseFile(&lv_, in_name, title, pattern, dir1, dir2);
+       return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
+                            title, pattern, dir1, dir2);
 }
 
 
@@ -135,10 +135,9 @@ string const ControlGraphics::readBB(string const & file)
 }
 
 
-void ControlGraphics::checkFilename(string const & fname) {
-       if (!IsFileReadable(fname))
-               Alert::alert(_("Warning!"),
-                            _("Filename") + ' '
-                            + fname + _(" does not exist!"));
-
+bool ControlGraphics::isFilenameValid(string const & fname) const
+{
+       // It may be that the filename is relative.
+       string const name = MakeAbsPath(fname, lv_.buffer()->filePath());
+       return IsFileReadable(name);
 }
index f9c2cc74fc277a9df4bff79d057d971eef5cdf6d..9a6cc481d90df7bbaa01deeeccc846ed18106394 100644 (file)
@@ -41,7 +41,7 @@ public:
        /// Control the bb
        bool bbChanged;
        /// test if file exist
-       void checkFilename(string const & fname);
+       bool isFilenameValid(string const & fname) const;
 private:
        /// Dispatch the changed parameters to the kernel.
        virtual void applyParamsToInset();
index 112afe0f52119b56bf161a4438cdf1d3ebd793c2..3ab0c6bff9c9ae34c7052ff02a959167dc086f4d 100644 (file)
 #include "buffer.h"
 #include "Dialogs.h"
 #include "LyXView.h"
-#include "lyxrc.h"
 #include "PrinterParams.h"
 #include "Liason.h"
-#include "helper_funcs.h" // browseFile
+#include "helper_funcs.h"
 #include "frontends/Alert.h"
 #include "gettext.h"
 #include "BufferView.h"
@@ -91,5 +90,6 @@ string const ControlPrint::Browse(string const & in_name)
        string const pattern = "*.ps";
 
        // Show the file browser dialog
-       return browseFile(&lv_, in_name, title, pattern);
+       return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
+                            title, pattern);
 }
index 55ccd02564be9eebb5a2714a0d67407c7da2f9dc..cf92b7237675e67343ea02804d83ca587f44fa37 100644 (file)
@@ -1,5 +1,13 @@
 2002-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
 
+       * FormGraphics.C (input): don't activate the Ok, Apply buttons if the
+       file can't be found.
+
+       * FormParagraph.C (changedParagraph): activate the Ok, Apply buttons
+       only if the underlying paragraph will accept changes.
+
+       * FormPreferences.C (browse): use Jean-Marc's browseRelFile.
+
        * xforms_helper.C (updateWidgetsFromLength): fix crash when trying to
        set the choice to a unit that isn't present in the choice!
        Also remove #if 0 sections of code.
index c27db20180bdb45ce6121ea09be140656792751f..75112a4f85f40a81e5581e97eb2ff07b8923d29d 100644 (file)
@@ -199,7 +199,6 @@ void FormGraphics::apply()
 
        // the file section
        igp.filename = getStringFromInput(file_->input_filename);
-       controller().checkFilename(igp.filename);
        igp.subcaption = fl_get_button(file_->check_subcaption);
        igp.subcaptionText = getStringFromInput(file_->input_subcaption);
        igp.rotate = fl_get_button(file_->check_rotate);
@@ -484,6 +483,14 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT * ob, long)
                if (out_name != in_name && !out_name.empty()) {
                        fl_set_input(file_->input_filename, out_name.c_str());
                }
+               if (!controller().isFilenameValid(out_name))
+                       return ButtonPolicy::SMI_INVALID;
+
+       } else if (ob == file_->input_filename) {
+               string name = getStringFromInput(file_->input_filename);
+               if (!controller().isFilenameValid(name))
+                       return ButtonPolicy::SMI_INVALID;
+
        } else if (ob == file_->check_subcaption) {
                setEnabled(file_->input_subcaption,
                           fl_get_button(file_->check_subcaption));
index f7d38a1d0cc3e426e33b5a04c01a77319f03c03a..87a30e4cda6834d0a62484cee70b967474c978d0 100644 (file)
@@ -80,15 +80,17 @@ void FormParagraph::changedParagraph()
        if (p == 0 || p == par_)
                return;
 
-       // OBS FIX LOOK HERE
+       // For now, don't bother checking if the params are different.
 
-       // shouldn't we chage the par_ pointer too?
-       // anyway for me the below function does just nothing!
-       // (Jug 20020108)
+       // Will the underlying paragraph accept our changes?
+       Inset * const inset = p->inInset();
+       bool const accept = !(inset && inset->forceDefaultParagraphs(inset));
+       bc().valid(accept);
+
+       if (!accept) {
+               postWarning(_("Cannot apply paragraph settings to this inset!"));
+       }
 
-       // For now don't bother checking if the params are different,
-       // just activate the Apply button
-       bc().valid();
 }
 
 
index bea4d64bc7d3a46248bb84a45df87a6e28f6b2e7..bd3e22d0f4165f12962fb9252c73a3d83b747649 100644 (file)
@@ -8,35 +8,31 @@
 
 #include <config.h>
 
-#include <utility>
-#include <iomanip>
-#include <X11/Xlib.h>
-
-#include FORMS_H_LOCATION
-
 #ifdef __GNUG_
 #pragma implementation
 #endif
 
-#include "Color.h"
-#include "LColor.h"
-#include "Lsstream.h"
 #include "FormPreferences.h"
 #include "form_preferences.h"
 #include "ButtonController.tmpl"
-#include "input_validators.h"
+#include "Dialogs.h"
+
+#include "buffer.h"
+#include "converter.h"
+#include "debug.h"
 #include "LyXView.h"
 #include "language.h"
 #include "lyxfunc.h"
-#include "Dialogs.h"
+#include "lyxlex.h"
 #include "lyxrc.h"
+#include "LColor.h"
+#include "Lsstream.h"
+
 #include "combox.h"
-#include "debug.h"
-#include "lyxlex.h"
+#include "Color.h"
 #include "input_validators.h"
 #include "xforms_helpers.h"
 #include "helper_funcs.h"
-#include "converter.h"
 
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
 
 #include "graphics/GraphicsCache.h"
 
+#include <utility>
+#include <iomanip>
+#include <X11/Xlib.h>
+
 using std::endl;
 using std::pair;
 using std::make_pair;
@@ -2999,7 +2999,8 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(lv_, filename, title, pattern, dir1, dir2);
+               browseRelFile(lv_, filename, lv_->buffer()->filePath(),
+                             title, pattern, dir1, dir2);
 
        // Save the filename to the dialog
        if (new_filename != filename && !new_filename.empty()) {
index f9d82aca0d6ffb6609d2d6d70b98cd0751035f29..5343c22d4f8fc4edc24bd48e775caeb0180cf8cc 100644 (file)
 #include "ControlPrint.h"
 #include "FormPrint.h"
 #include "form_print.h"
-#include "input_validators.h"
-#include "support/lstrings.h"
 
-#include "lyxrc.h" // needed by PrinterParams
+#include "LyXView.h"
+
 #include "PrinterParams.h"
 
-#include "LyXView.h"
-#include "xforms_helpers.h"     // for browseFile
+#include "input_validators.h"
+#include "xforms_helpers.h"
+
+#include "support/lstrings.h"
 
-/*
-#include "LyXView.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "debug.h"
-#include "BufferView.h"
-*/
-
-//using Liason::printBuffer;
-//using Liason::getPrinterParams;
 using std::make_pair;
 
 typedef FormCB<ControlPrint, FormDB<FD_form_print> > base_class;
index ead8bef6be9ab80108aed718161dde6160b83a13..0df2aa9414533f933b297c043a378454c6de1624 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insettext.C (edit): emit an updateParagraph signal on entering a text
+       inset. Needs to be emitted when leaving the inset also.
+
 2002-03-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * all files: ws cleanup
index 15fb20da4257521e3ea947f27a6f7ea0e4349c82..b0e85b677eaff165305f293a48f2d51f0b571164 100644 (file)
@@ -43,6 +43,7 @@
 #include "lyxfind.h"
 
 #include "frontends/Alert.h"
+#include "frontends/Dialogs.h"
 
 #include "support/textutils.h"
 #include "support/LAssert.h"
@@ -684,6 +685,9 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
        if (drawFrame_ == LOCKED)
                code = CURSOR|DRAW_FRAME;
        updateLocal(bv, code, false);
+
+       // Tell the paragraph dialog that we've entered an insettext.
+       bv->owner()->getDialogs()->updateParagraph();
 }