]> git.lyx.org Git - features.git/commitdiff
Move the toolbar flags setting into a separate section to allow the
authorJohn Levon <levon@movementarian.org>
Wed, 11 Jun 2003 19:21:46 +0000 (19:21 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 11 Jun 2003 19:21:46 +0000 (19:21 +0000)
user to set them easily, as discussed

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

lib/ChangeLog
lib/ui/default.ui
lib/ui/stdtoolbars.ui
src/ChangeLog
src/ToolbarBackend.C
src/ToolbarBackend.h
src/lyx_main.C

index 0173e2175b4ae1a49de8a264c71231eeb40fad3c..1e56d08515816b39bb666ea86608f8f9adf6f00c 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-11  John Levon  <levon@movementarian.org>
+
+       * ui/stdtoolbars.ui: move flags to ...
+
+       * ui/default.ui: ... Toolbars section here
+
 2003-06-11  John Levon  <levon@movementarian.org>
 
        * ui/stdtoolbars.ui: show Extra toolbar by default
index 821d183f43f7e3c71c84b75386909aebc021119b..412ac8f5f8e226fa72af211c710285a8760e94be 100644 (file)
@@ -4,3 +4,24 @@
 Include "stdmenus.ui"
 
 Include "stdtoolbars.ui"
+
+# Which toolbars to use.
+#
+# The second parameter are the flags :
+#
+# on: the toolbar is visible
+# off: the toolbar is not visible
+# math: the toolbar is visible only when in math
+# table: the toolbar is visible only when in a table
+# top: the toolbar should be at the top of the window
+# bottom: the toolbar should be at the bottom of the window
+# left: the toolbar should be at the left of the window
+# right: the toolbar should be at the right of the window
+#
+Toolbars
+       "Standard" "on,top"
+       "Extra" "on,top"
+       "Table" "off,bottom"
+       "Math" "off,bottom"
+       "Command Buffer" "off,bottom"
+End
index c40ca152c218e3ca744c40beb78bb6ee4f1f7aae..4cadcc909d417976999e4e2be31f9dc0aa983c7d 100644 (file)
@@ -1,17 +1,6 @@
 # A Toolbar starts like :
 #
-# Toolbar "Name" "on" 
-#
-# The second parameter are the flags :
-#
-# on: the toolbar is visible
-# off: the toolbar is not visible
-# math: the toolbar is visible only when in math
-# table: the toolbar is visible only when in a table
-# top: the toolbar should be at the top of the window
-# bottom: the toolbar should be at the bottom of the window
-# left: the toolbar should be at the left of the window
-# right: the toolbar should be at the right of the window
+# Toolbar "Name"
 #
 # Only four commands are allowed inside the begin_toolbar and end_toolbar
 # directives: 
@@ -36,8 +25,6 @@
 #
 # This is the default toolbar:
 
-# slight rationalisations here
-
 Toolbar "Standard" "on,top"
        Layouts
        Item "New document" "buffer-new"
index 0578d83184f91453d6cbbdbed82924cee63a8478..dad0094c64e15498824d908e43fff47beead9ac7 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-11  John Levon  <levon@movementarian.org>
+
+       * lyx_main.C:
+       * ToolbarBackend.h:
+       * ToolbarBackend.C: add "Toolbars" section and
+       put the flags there
+
 2003-06-10  Angus Leeming  <leeming@lyx.org>
 
        * lfuns.h:
index 0d15ccc091ab9cf1b11ee6d14e2105a7e2af0949..756c49b510daa4dc8c7d64314d91de097fc130d9 100644 (file)
@@ -71,38 +71,6 @@ void ToolbarBackend::read(LyXLex & lex)
        tb.name = lex.getString();
        lex.next(true);
        
-       tb.flags = static_cast<Flags>(0);
-       string flagstr = lex.getString();
-       vector<string> flags = getVectorFromString(flagstr);
-
-       vector<string>::const_iterator cit = flags.begin();
-       vector<string>::const_iterator end = flags.end();
-
-       for (; cit != end; ++cit) {
-               int flag = 0;
-               if (!compare_ascii_no_case(*cit, "off"))
-                       flag = OFF;
-               else if (!compare_ascii_no_case(*cit, "on"))
-                       flag = ON;
-               else if (!compare_ascii_no_case(*cit, "math"))
-                       flag = MATH;
-               else if (!compare_ascii_no_case(*cit, "table"))
-                       flag = TABLE;
-               else if (!compare_ascii_no_case(*cit, "top"))
-                       flag = TOP;
-               else if (!compare_ascii_no_case(*cit, "bottom"))
-                       flag = BOTTOM;
-               else if (!compare_ascii_no_case(*cit, "left"))
-                       flag = LEFT;
-               else if (!compare_ascii_no_case(*cit, "right"))
-                       flag = RIGHT;
-               else {
-                       lyxerr << "ToolbarBackend::read: unrecognised token:`"
-                              << *cit << '\'' << endl;
-               }
-               tb.flags = static_cast<Flags>(tb.flags | flag);
-       }
-
        bool quit = false;
 
        lex.pushTable(toolTags, TO_LAST - 1);
@@ -152,6 +120,74 @@ void ToolbarBackend::read(LyXLex & lex)
 }
 
 
+void ToolbarBackend::readToolbars(LyXLex & lex)
+{
+       //consistency check
+       if (compare_ascii_no_case(lex.getString(), "toolbars")) {
+               lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
+                      << lex.getString() << '\'' << endl;
+       }
+
+       lex.next(true);
+
+       while (lex.isOK()) {
+               string name = lex.getString();
+               lex.next(true);
+
+               if (!compare_ascii_no_case(name, "end"))
+                       return;
+
+               Toolbars::iterator tcit = toolbars.begin();
+               Toolbars::iterator tend = toolbars.end();
+               for (; tcit != tend; ++tcit) {
+                       if (tcit->name == name)
+                               break;
+               }
+
+               if (tcit == tend) {
+                       lyxerr << "ToolbarBackend: undefined toolbar "
+                               << name << endl;
+                       return;
+               }
+
+               tcit->flags = static_cast<Flags>(0);
+               string flagstr = lex.getString();
+               lex.next(true);
+               vector<string> flags = getVectorFromString(flagstr);
+
+               vector<string>::const_iterator cit = flags.begin();
+               vector<string>::const_iterator end = flags.end();
+
+               for (; cit != end; ++cit) {
+                       int flag = 0;
+                       if (!compare_ascii_no_case(*cit, "off"))
+                               flag = OFF;
+                       else if (!compare_ascii_no_case(*cit, "on"))
+                               flag = ON;
+                       else if (!compare_ascii_no_case(*cit, "math"))
+                               flag = MATH;
+                       else if (!compare_ascii_no_case(*cit, "table"))
+                               flag = TABLE;
+                       else if (!compare_ascii_no_case(*cit, "top"))
+                               flag = TOP;
+                       else if (!compare_ascii_no_case(*cit, "bottom"))
+                               flag = BOTTOM;
+                       else if (!compare_ascii_no_case(*cit, "left"))
+                               flag = LEFT;
+                       else if (!compare_ascii_no_case(*cit, "right"))
+                               flag = RIGHT;
+                       else {
+                               lyxerr << "ToolbarBackend::read: unrecognised token:`"
+                                      << *cit << '\'' << endl;
+                       }
+                       tcit->flags = static_cast<Flags>(tcit->flags | flag);
+               }
+
+               usedtoolbars.push_back(*tcit);
+       }
+}
+
+
 void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
 {
        tb.items.push_back(make_pair(action, tooltip));
index bbc3498f5ebd6c01e287fe3744940318948502d7..9a84eee9bc0b6a97cf48b1fc485025453bfbd37a 100644 (file)
@@ -68,16 +68,19 @@ public:
 
        /// iterator for all toolbars
        Toolbars::const_iterator begin() const {
-               return toolbars.begin();
+               return usedtoolbars.begin();
        }
 
        Toolbars::const_iterator end() const {
-               return toolbars.end();
+               return usedtoolbars.end();
        }
 
        /// read a toolbar from the file
        void read(LyXLex &);
 
+       /// read the used toolbars
+       void readToolbars(LyXLex &);
+
        /// return a full path of an XPM for the given action
        static string const getIcon(int action);
 
@@ -90,6 +93,9 @@ private:
 
        /// all the toolbars
        Toolbars toolbars;
+
+       /// toolbars listed
+       Toolbars usedtoolbars;
 };
 
 /// The global instance
index 5f1a44cfc0f579203689423e99ab253327b117b1..f323a19069e7b52177e7380761f5a3267e131388 100644 (file)
@@ -635,6 +635,7 @@ void LyX::readUIFile(string const & name)
        enum Uitags {
                ui_menuset = 1,
                ui_toolbar,
+               ui_toolbars,
                ui_include,
                ui_last
        };
@@ -642,7 +643,8 @@ void LyX::readUIFile(string const & name)
        struct keyword_item uitags[ui_last - 1] = {
                { "include", ui_include },
                { "menuset", ui_menuset },
-               { "toolbar", ui_toolbar }
+               { "toolbar", ui_toolbar },
+               { "toolbars", ui_toolbars }
        };
 
        // Ensure that a file is read only once (prevents include loops)
@@ -697,6 +699,10 @@ void LyX::readUIFile(string const & name)
                        toolbarbackend.read(lex);
                        break;
 
+               case ui_toolbars:
+                       toolbarbackend.readToolbars(lex);
+                       break;
+
                default:
                        if (!rtrim(lex.getString()).empty())
                                lex.printError("LyX::ReadUIFile: "