]> git.lyx.org Git - features.git/commitdiff
fix the "save defaults" problems
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Nov 2001 11:39:58 +0000 (11:39 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Nov 2001 11:39:58 +0000 (11:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2973 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LyXAction.C
src/buffer.C
src/buffer.h
src/commandtags.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormDocument.C
src/lyx_cb.C
src/lyx_cb.h
src/lyxfunc.C

index 3a26ccc8bf1d6a98c02472b01927c84471e1825c..6c9856c8960bf66271ef0f8b4320e0ea71bf1a82 100644 (file)
@@ -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...
index 58095e2e60d962c2dc77edd1e5aec7c81d81c8d1..6986dab36bc8aafd699f846cfc4d3e174b4198e4 100644 (file)
@@ -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",
index 49f15e40f195b8f712b4956dfc3859fba0791f65..edefcb7cdd168348e9ce7785b71377d703278696 100644 (file)
@@ -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
index 59beaa1ac8344a2b8632f4deb76a5b9833d6bcb2..bcdef34b198384b48221cd4d9b6faf881066b559 100644 (file)
@@ -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
        */
index 5445872c0671bdab4fd17988a167cf96d65ea66b..640577c5853d2555506c8bc9337508f1dde54b24 100644 (file)
@@ -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,
index a3bf185b26ea5b5f4b27e6c2a90cf73b7e3186fb..5cba603be8546ba03b0239105e8b8f1e3f7d249f 100644 (file)
@@ -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:
index 04a516bb1121eb84329874faa5e05ee9b6220d8e..18cff16143953339fd01136d980ea9d9e17d3f77 100644 (file)
@@ -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 &params)
+{
+       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];
 }
 
 
index 4d5787a354f6d20e26a0fd01f6e7cbd1db671668..739a7447353d6677f9b34c57c7e57a3433494da6 100644 (file)
@@ -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)
index 5a39ffa23de1dab75c1231fd4acac88f3437fafb..f5e4111663c18e1bbc250d182bdb1d47c420927e 100644 (file)
@@ -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
 
index 3ac2af1e92a285e7246df6d0efb82faf96e08ac3..529038d8b7149c997ad5408eaaacb4ca0385292a 100644 (file)
@@ -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;