diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 6a3423d8a9..8cb33a37b0 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2002-03-22 Angus Leeming + + * 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 * most files: ws cleanup diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 0175c942a3..a920c66e2f 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -66,5 +66,6 @@ string const ControlBibtex::Browse(string const & in_name, string const & pattern) { pair 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); } diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index c488988803..b1de9231ad 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -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" @@ -33,11 +34,9 @@ #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 dir1(N_("Clipart|#C#c"), clipdir); pair 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); } diff --git a/src/frontends/controllers/ControlGraphics.h b/src/frontends/controllers/ControlGraphics.h index f9c2cc74fc..9a6cc481d9 100644 --- a/src/frontends/controllers/ControlGraphics.h +++ b/src/frontends/controllers/ControlGraphics.h @@ -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(); diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index 112afe0f52..3ab0c6bff9 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -24,10 +24,9 @@ #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); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 55ccd02564..cf92b72376 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,5 +1,13 @@ 2002-03-22 Angus Leeming + * 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. diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index c27db20180..75112a4f85 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -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)); diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index f7d38a1d0c..87a30e4cda 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -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(); } diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index bea4d64bc7..bd3e22d0f4 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -8,35 +8,31 @@ #include -#include -#include -#include - -#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 "lyxrc.h" -#include "combox.h" -#include "debug.h" #include "lyxlex.h" +#include "lyxrc.h" +#include "LColor.h" +#include "Lsstream.h" + +#include "combox.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" @@ -45,6 +41,10 @@ #include "graphics/GraphicsCache.h" +#include +#include +#include + 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()) { diff --git a/src/frontends/xforms/FormPrint.C b/src/frontends/xforms/FormPrint.C index f9d82aca0d..5343c22d4f 100644 --- a/src/frontends/xforms/FormPrint.C +++ b/src/frontends/xforms/FormPrint.C @@ -17,25 +17,16 @@ #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 "LyXView.h" -#include "Dialogs.h" -#include "Liason.h" -#include "debug.h" -#include "BufferView.h" -*/ +#include "support/lstrings.h" -//using Liason::printBuffer; -//using Liason::getPrinterParams; using std::make_pair; typedef FormCB > base_class; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ead8bef6be..0df2aa9414 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-03-22 Angus Leeming + + * 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 * all files: ws cleanup diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 15fb20da42..b0e85b677e 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(); }