* Use JMarc's browseRelFiles rather than browseFiles.

* 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
This commit is contained in:
Angus Leeming 2002-03-22 15:24:32 +00:00
parent e4b8d67f26
commit b97138d0e8
12 changed files with 79 additions and 53 deletions

View 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> 2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
* most files: ws cleanup * most files: ws cleanup

View File

@ -66,5 +66,6 @@ string const ControlBibtex::Browse(string const & in_name,
string const & pattern) string const & pattern)
{ {
pair<string, string> dir1(N_("Documents|#o#O"), string(lyxrc.document_path)); 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);
} }

View File

@ -24,6 +24,7 @@
#include "ControlGraphics.h" #include "ControlGraphics.h"
#include "ControlInset.tmpl" #include "ControlInset.tmpl"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h"
#include "Dialogs.h" #include "Dialogs.h"
#include "LyXView.h" #include "LyXView.h"
#include "gettext.h" #include "gettext.h"
@ -33,11 +34,9 @@
#include "insets/insetgraphicsParams.h" // need operator!=() #include "insets/insetgraphicsParams.h" // need operator!=()
#include "support/FileInfo.h" // for FileInfo #include "support/FileInfo.h" // for FileInfo
#include "helper_funcs.h" // for browseFile #include "helper_funcs.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/filetools.h" // for AddName, zippedFile #include "support/filetools.h" // for AddName, zippedFile
#include "frontends/Alert.h"
#include "BufferView.h"
using std::pair; using std::pair;
using std::make_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> dir1(N_("Clipart|#C#c"), clipdir);
pair<string, string> dir2(N_("Documents|#o#O"), string(lyxrc.document_path)); pair<string, string> dir2(N_("Documents|#o#O"), string(lyxrc.document_path));
// Show the file browser dialog // 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) { bool ControlGraphics::isFilenameValid(string const & fname) const
if (!IsFileReadable(fname)) {
Alert::alert(_("Warning!"), // It may be that the filename is relative.
_("Filename") + ' ' string const name = MakeAbsPath(fname, lv_.buffer()->filePath());
+ fname + _(" does not exist!")); return IsFileReadable(name);
} }

View File

@ -41,7 +41,7 @@ public:
/// Control the bb /// Control the bb
bool bbChanged; bool bbChanged;
/// test if file exist /// test if file exist
void checkFilename(string const & fname); bool isFilenameValid(string const & fname) const;
private: private:
/// Dispatch the changed parameters to the kernel. /// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset(); virtual void applyParamsToInset();

View File

@ -24,10 +24,9 @@
#include "buffer.h" #include "buffer.h"
#include "Dialogs.h" #include "Dialogs.h"
#include "LyXView.h" #include "LyXView.h"
#include "lyxrc.h"
#include "PrinterParams.h" #include "PrinterParams.h"
#include "Liason.h" #include "Liason.h"
#include "helper_funcs.h" // browseFile #include "helper_funcs.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
#include "BufferView.h" #include "BufferView.h"
@ -91,5 +90,6 @@ string const ControlPrint::Browse(string const & in_name)
string const pattern = "*.ps"; string const pattern = "*.ps";
// Show the file browser dialog // Show the file browser dialog
return browseFile(&lv_, in_name, title, pattern); return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
title, pattern);
} }

View File

@ -1,5 +1,13 @@
2002-03-22 Angus Leeming <a.leeming@ic.ac.uk> 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 * xforms_helper.C (updateWidgetsFromLength): fix crash when trying to
set the choice to a unit that isn't present in the choice! set the choice to a unit that isn't present in the choice!
Also remove #if 0 sections of code. Also remove #if 0 sections of code.

View File

@ -199,7 +199,6 @@ void FormGraphics::apply()
// the file section // the file section
igp.filename = getStringFromInput(file_->input_filename); igp.filename = getStringFromInput(file_->input_filename);
controller().checkFilename(igp.filename);
igp.subcaption = fl_get_button(file_->check_subcaption); igp.subcaption = fl_get_button(file_->check_subcaption);
igp.subcaptionText = getStringFromInput(file_->input_subcaption); igp.subcaptionText = getStringFromInput(file_->input_subcaption);
igp.rotate = fl_get_button(file_->check_rotate); 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()) { if (out_name != in_name && !out_name.empty()) {
fl_set_input(file_->input_filename, out_name.c_str()); 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) { } else if (ob == file_->check_subcaption) {
setEnabled(file_->input_subcaption, setEnabled(file_->input_subcaption,
fl_get_button(file_->check_subcaption)); fl_get_button(file_->check_subcaption));

View File

@ -80,15 +80,17 @@ void FormParagraph::changedParagraph()
if (p == 0 || p == par_) if (p == 0 || p == par_)
return; return;
// OBS FIX LOOK HERE // For now, don't bother checking if the params are different.
// shouldn't we chage the par_ pointer too? // Will the underlying paragraph accept our changes?
// anyway for me the below function does just nothing! Inset * const inset = p->inInset();
// (Jug 20020108) 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();
} }

View File

@ -8,35 +8,31 @@
#include <config.h> #include <config.h>
#include <utility>
#include <iomanip>
#include <X11/Xlib.h>
#include FORMS_H_LOCATION
#ifdef __GNUG_ #ifdef __GNUG_
#pragma implementation #pragma implementation
#endif #endif
#include "Color.h"
#include "LColor.h"
#include "Lsstream.h"
#include "FormPreferences.h" #include "FormPreferences.h"
#include "form_preferences.h" #include "form_preferences.h"
#include "ButtonController.tmpl" #include "ButtonController.tmpl"
#include "input_validators.h" #include "Dialogs.h"
#include "buffer.h"
#include "converter.h"
#include "debug.h"
#include "LyXView.h" #include "LyXView.h"
#include "language.h" #include "language.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "Dialogs.h"
#include "lyxrc.h"
#include "combox.h"
#include "debug.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "lyxrc.h"
#include "LColor.h"
#include "Lsstream.h"
#include "combox.h"
#include "Color.h"
#include "input_validators.h" #include "input_validators.h"
#include "xforms_helpers.h" #include "xforms_helpers.h"
#include "helper_funcs.h" #include "helper_funcs.h"
#include "converter.h"
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include "support/lyxmanip.h" #include "support/lyxmanip.h"
@ -45,6 +41,10 @@
#include "graphics/GraphicsCache.h" #include "graphics/GraphicsCache.h"
#include <utility>
#include <iomanip>
#include <X11/Xlib.h>
using std::endl; using std::endl;
using std::pair; using std::pair;
using std::make_pair; using std::make_pair;
@ -2999,7 +2999,8 @@ void FormPreferences::browse(FL_OBJECT * inpt,
// Show the file browser dialog // Show the file browser dialog
string const new_filename = 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 // Save the filename to the dialog
if (new_filename != filename && !new_filename.empty()) { if (new_filename != filename && !new_filename.empty()) {

View File

@ -17,25 +17,16 @@
#include "ControlPrint.h" #include "ControlPrint.h"
#include "FormPrint.h" #include "FormPrint.h"
#include "form_print.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 "PrinterParams.h"
#include "LyXView.h" #include "input_validators.h"
#include "xforms_helpers.h" // for browseFile #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; using std::make_pair;
typedef FormCB<ControlPrint, FormDB<FD_form_print> > base_class; typedef FormCB<ControlPrint, FormDB<FD_form_print> > base_class;

View 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> 2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
* all files: ws cleanup * all files: ws cleanup

View File

@ -43,6 +43,7 @@
#include "lyxfind.h" #include "lyxfind.h"
#include "frontends/Alert.h" #include "frontends/Alert.h"
#include "frontends/Dialogs.h"
#include "support/textutils.h" #include "support/textutils.h"
#include "support/LAssert.h" #include "support/LAssert.h"
@ -684,6 +685,9 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
if (drawFrame_ == LOCKED) if (drawFrame_ == LOCKED)
code = CURSOR|DRAW_FRAME; code = CURSOR|DRAW_FRAME;
updateLocal(bv, code, false); updateLocal(bv, code, false);
// Tell the paragraph dialog that we've entered an insettext.
bv->owner()->getDialogs()->updateParagraph();
} }