mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
fix the "save defaults" problems
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2973 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2f858329df
commit
f38f4b1dee
@ -1,3 +1,12 @@
|
||||
2001-11-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* buffer.C (saveParamsAsDefaults):
|
||||
* lyx_cb.C (MenuLayoutSave): remove
|
||||
|
||||
* LyXAction.C (init):
|
||||
* commandtags.h:
|
||||
* lyxfunc.C (dispatch): remove LFUN_LAYOUT_SAVE_DEFAULT.
|
||||
|
||||
2001-11-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* buffer.C (setPaperStuff): removed from here...
|
||||
|
@ -257,8 +257,6 @@ void LyXAction::init()
|
||||
{ LFUN_LAYOUT_PASTE, "layout-paste",
|
||||
N_("Paste paragraph environment type"), Noop },
|
||||
{ LFUN_LAYOUT_PREAMBLE, "layout-preamble", "", ReadOnly },
|
||||
{ LFUN_LAYOUT_SAVE_DEFAULT, "layout-save-default", "",
|
||||
ReadOnly },
|
||||
{ LFUN_LAYOUT_TABULAR, "layout-tabular",
|
||||
N_("Open the tabular layout"), Noop },
|
||||
{ LFUN_HOME, "line-begin",
|
||||
|
16
src/buffer.C
16
src/buffer.C
@ -240,22 +240,6 @@ void Buffer::setReadonly(bool flag)
|
||||
}
|
||||
|
||||
|
||||
bool Buffer::saveParamsAsDefaults() // const
|
||||
{
|
||||
string const fname = AddName(AddPath(user_lyxdir, "templates/"),
|
||||
"defaults.lyx");
|
||||
Buffer defaults = Buffer(fname);
|
||||
|
||||
// Use the current buffer's parameters as default
|
||||
defaults.params = params;
|
||||
|
||||
// add an empty paragraph. Is this enough?
|
||||
defaults.paragraph = new Paragraph;
|
||||
|
||||
return defaults.writeFile(defaults.filename, false);
|
||||
}
|
||||
|
||||
|
||||
/// Update window titles of all users
|
||||
// Should work on a list
|
||||
void Buffer::updateTitles() const
|
||||
|
@ -70,14 +70,6 @@ public:
|
||||
/// Destructor
|
||||
~Buffer();
|
||||
|
||||
/** Save the buffer's parameters as user default.
|
||||
This function saves a file \c user_lyxdir/templates/defaults.lyx
|
||||
which parameters are those of the current buffer. This file
|
||||
is used as a default template when creating a new
|
||||
file. Returns \c true on success.
|
||||
*/
|
||||
bool saveParamsAsDefaults();
|
||||
|
||||
/** High-level interface to buffer functionality.
|
||||
This function parses a command string and executes it
|
||||
*/
|
||||
|
@ -163,7 +163,6 @@ enum kb_action {
|
||||
LFUN_LAYOUT_PARAGRAPH,
|
||||
LFUN_LAYOUT_DOCUMENT,
|
||||
LFUN_LAYOUT_PREAMBLE,
|
||||
LFUN_LAYOUT_SAVE_DEFAULT,
|
||||
LFUN_DROP_LAYOUTS_CHOICE,
|
||||
LFUN_CODE,
|
||||
LFUN_SANS,
|
||||
|
@ -1,3 +1,15 @@
|
||||
2001-11-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* FormDocument.C (class_apply):
|
||||
(paper_apply):
|
||||
(language_apply):
|
||||
(options_apply):
|
||||
(bullets_apply): add a version of these methods taking a
|
||||
BufferParams& parameters. The original versions are now wrappers
|
||||
around these.
|
||||
(saveParamsAsDefault): new function, moved from old
|
||||
LFUN_LAYOUT_SAVE_DEFAULT code.
|
||||
|
||||
2001-11-03 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* Makefile.am:
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "debug.h"
|
||||
#include "input_validators.h" // fl_unsigned_float_filter
|
||||
#include "helper_funcs.h"
|
||||
#include "lyx_main.h" // for user_lyxdir
|
||||
|
||||
using Liason::setMinibuffer;
|
||||
using SigC::slot;
|
||||
@ -370,6 +371,34 @@ void FormDocument::update()
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
// should this go elsewhere? Maybe a ControllerDocument? (JMarc)
|
||||
/** Save the buffer's parameters as user default.
|
||||
This function saves a file \c user_lyxdir/templates/defaults.lyx
|
||||
which parameters are those of the current buffer. This file
|
||||
is used as a default template when creating a new
|
||||
file. Returns \c true on success.
|
||||
*/
|
||||
bool saveParamsAsDefault(BufferParams const ¶ms)
|
||||
{
|
||||
if (!AskQuestion(_("Do you want to save the current settings"),
|
||||
_("for document layout"),
|
||||
_("as default for new documents?")))
|
||||
return false;
|
||||
|
||||
string const fname = AddName(AddPath(user_lyxdir, "templates/"),
|
||||
"defaults.lyx");
|
||||
Buffer defaults = Buffer(fname);
|
||||
defaults.params = params;
|
||||
|
||||
// add an empty paragraph. Is this enough?
|
||||
defaults.paragraph = new Paragraph;
|
||||
|
||||
return defaults.writeFile(defaults.fileName(), false);
|
||||
}
|
||||
|
||||
} //namespace
|
||||
|
||||
bool FormDocument::input( FL_OBJECT * ob, long data )
|
||||
{
|
||||
State cb = static_cast<State>( data );
|
||||
@ -438,7 +467,13 @@ bool FormDocument::input( FL_OBJECT * ob, long data )
|
||||
}
|
||||
|
||||
if (ob == dialog_->button_save_defaults) {
|
||||
lv_->getLyXFunc()->dispatch(LFUN_LAYOUT_SAVE_DEFAULT);
|
||||
BufferParams params;
|
||||
class_apply(params);
|
||||
paper_apply(params);
|
||||
language_apply(params);
|
||||
options_apply(params);
|
||||
bullets_apply(params);
|
||||
saveParamsAsDefault(params);
|
||||
}
|
||||
|
||||
if (ob == dialog_->button_reset_defaults) {
|
||||
@ -899,13 +934,13 @@ bool FormDocument::options_apply()
|
||||
void FormDocument::bullets_apply(BufferParams & params)
|
||||
{
|
||||
/* update the bullet settings */
|
||||
BufferParams & params_doc = lv_->buffer()->params;
|
||||
BufferParams & buf_params = lv_->buffer()->params;
|
||||
|
||||
// a little bit of loop unrolling
|
||||
params.user_defined_bullets[0] = params_doc.temp_bullets[0];
|
||||
params.user_defined_bullets[1] = params_doc.temp_bullets[1];
|
||||
params.user_defined_bullets[2] = params_doc.temp_bullets[2];
|
||||
params.user_defined_bullets[3] = params_doc.temp_bullets[3];
|
||||
params.user_defined_bullets[0] = buf_params.temp_bullets[0];
|
||||
params.user_defined_bullets[1] = buf_params.temp_bullets[1];
|
||||
params.user_defined_bullets[2] = buf_params.temp_bullets[2];
|
||||
params.user_defined_bullets[3] = buf_params.temp_bullets[3];
|
||||
}
|
||||
|
||||
|
||||
|
12
src/lyx_cb.C
12
src/lyx_cb.C
@ -526,18 +526,6 @@ void MenuInsertLabel(BufferView * bv, string const & arg)
|
||||
}
|
||||
|
||||
|
||||
void MenuLayoutSave(BufferView * bv)
|
||||
{
|
||||
if (!bv->available())
|
||||
return;
|
||||
|
||||
if (AskQuestion(_("Do you want to save the current settings"),
|
||||
_("for document layout"),
|
||||
_("as default for new documents?")))
|
||||
bv->buffer()->saveParamsAsDefaults();
|
||||
}
|
||||
|
||||
|
||||
// This function runs "configure" and then rereads lyx.defaults to
|
||||
// reconfigure the automatic settings.
|
||||
void Reconfigure(BufferView * bv)
|
||||
|
@ -33,8 +33,6 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph);
|
||||
///
|
||||
void MenuInsertLabel(BufferView * bv, string const & arg);
|
||||
///
|
||||
void MenuLayoutSave(BufferView * bv);
|
||||
///
|
||||
void Reconfigure(BufferView * bv);
|
||||
#endif
|
||||
|
||||
|
@ -1350,10 +1350,6 @@ string const LyXFunc::dispatch(int ac,
|
||||
owner->getDialogs()->showPreamble();
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_SAVE_DEFAULT:
|
||||
MenuLayoutSave(owner->view());
|
||||
break;
|
||||
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
owner->getToolbar()->openLayoutList();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user