]> git.lyx.org Git - features.git/commitdiff
toolbar2.diff
authorJohn Levon <levon@movementarian.org>
Wed, 9 Apr 2003 19:53:10 +0000 (19:53 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 9 Apr 2003 19:53:10 +0000 (19:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6746 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
lib/ChangeLog
lib/ui/default.ui
po/ChangeLog
po/Makefile.in.in
src/ChangeLog
src/ToolbarBackend.C
src/ToolbarBackend.h
src/frontends/ChangeLog
src/frontends/Toolbar.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/Toolbar_pimpl.C
src/frontends/qt2/Toolbar_pimpl.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Toolbar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.h

index bb14ef8005330ee906b6ab61507800030d0cb162..2d3301b7af7fb4859a2e2b2986b64595b1d5f889 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * ui/default.ui: add a name for the toolbar
+
 2003-04-08  John Levon  <levon@movementarian.org>
 
        * ui/default.ui: add tooltips for toolbar items,
index 9bfaff6dc98aac7288e86082bea93d9c48bf53ce..1fe6bf61342f598413e712f07ba51fe51da90164 100644 (file)
@@ -411,7 +411,7 @@ End
 #
 # This is the default toolbar:
 
-Toolbar
+Toolbar "Standard"
     Layouts
     Item "Open document" "file-open"
     Item "Save document" "buffer-write"
index 23ab5b1502d1b2cdf56328f07eaac0fd16887e64..fe3ec4b4be2a5f371d4a55f6c4b2908fec389dd0 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * Makefile.in.in: translate the toolbar name
+
 2003-03-30  John Levon  <levon@movementarian.org>
 
        * Makefile.in.in: fix escaping of " for qt UI files
index 3b696037465f570b9c0cb8a621ca98ecf1a4872a..6d96a6663107fa4fa090cbda78cc6e9092031f85 100644 (file)
@@ -282,6 +282,13 @@ $(srcdir)/default_ui_l10n.pot: $(top_srcdir)/lib/ui/default.ui
                printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
                        FILENAME, FNR, line); \
             } \
+           /^[^#]*Toolbar/ { \
+               line=$$0; \
+                sub(/[^"]*"/, "", line); \
+                sub(/".*/, "", line); \
+               printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
+                       FILENAME, FNR, line); \
+            } \
             /^[^#]*Item/ { \
                line=$$0; \
                 sub(/[^"]*"/, "", line); \
index 54a3d25b7a58708d8f2e38bc1e4787e35c3ebb49..916913c5a2ee871fb877675a25d2e82563fc08c9 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * ToolbarBackend.h:
+       * ToolbarBackend.C: allow multiple toolbars
+
 2003-04-09  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * undo_funcs.C (setCursorParUndo): adjust
index 263efeb1981581417661146c9c4bf5117bb8729d..cd6b22123b602ad808ce19d11cb9cb1ee2ac2d0e 100644 (file)
@@ -28,12 +28,11 @@ ToolbarBackend toolbarbackend;
 
 namespace {
 
-enum _tooltags {
+enum tooltags {
        TO_ADD = 1,
        TO_ENDTOOLBAR,
        TO_SEPARATOR,
        TO_LAYOUTS,
-       TO_NEWLINE,
        TO_LAST
 };
 
@@ -42,7 +41,6 @@ struct keyword_item toolTags[TO_LAST - 1] = {
        { "end", TO_ENDTOOLBAR },
        { "item", TO_ADD },
        { "layouts", TO_LAYOUTS },
-       { "newline", TO_NEWLINE },
        { "separator", TO_SEPARATOR }
 };
 
@@ -54,12 +52,6 @@ ToolbarBackend::ToolbarBackend()
 }
 
 
-void ToolbarBackend::add(int action, string const & tooltip)
-{
-       items.push_back(make_pair(action, tooltip));
-}
-
-
 void ToolbarBackend::read(LyXLex & lex)
 {
        //consistency check
@@ -68,6 +60,11 @@ void ToolbarBackend::read(LyXLex & lex)
                       << lex.getString() << '\'' << endl;
        }
 
+       lex.next(true);
+
+       Toolbar tb;
+       tb.name = lex.getString();
+
        bool quit = false;
 
        lex.pushTable(toolTags, TO_LAST - 1);
@@ -85,20 +82,16 @@ void ToolbarBackend::read(LyXLex & lex)
                                lyxerr[Debug::PARSER]
                                        << "ToolbarBackend::read TO_ADD func: `"
                                        << func << '\'' << endl;
-                               add(func, tooltip);
+                               add(tb, func, tooltip);
                        }
                        break;
 
                case TO_SEPARATOR:
-                       add(SEPARATOR);
+                       add(tb, SEPARATOR);
                        break;
 
                case TO_LAYOUTS:
-                       add(LAYOUTS);
-                       break;
-
-               case TO_NEWLINE:
-                       add(NEWLINE);
+                       add(tb, LAYOUTS);
                        break;
 
                case TO_ENDTOOLBAR:
@@ -110,11 +103,20 @@ void ToolbarBackend::read(LyXLex & lex)
                        break;
                }
        }
+
+       toolbars.push_back(tb);
+
        lex.popTable();
 }
 
 
-void ToolbarBackend::add(string const & func, string const & tooltip)
+void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
+{
+       tb.items.push_back(make_pair(action, tooltip));
+}
+
+
+void ToolbarBackend::add(Toolbar & tb, string const & func, string const & tooltip)
 {
        int const tf = lyxaction.LookupFunc(func);
 
@@ -122,7 +124,7 @@ void ToolbarBackend::add(string const & func, string const & tooltip)
                lyxerr << "ToolbarBackend::add: no LyX command called `"
                       << func << "' exists!" << endl;
        } else {
-               add(tf, tooltip);
+               add(tb, tf, tooltip);
        }
 }
 
index 0819908ee2be04c23a0bddeedae78aa9286ba2b7..ba2bfa4c9a7c48107abeb328a85f2c49e84e289a 100644 (file)
@@ -38,28 +38,30 @@ public:
        /// the toolbar items
        typedef std::vector<std::pair<int, string> > Items;
 
-       typedef Items::iterator iterator;
+       /// a toolbar
+       struct Toolbar {
+               /// toolbar UI name
+               string name;
+               /// toolbar contents
+               Items items;
+       };
+
+       typedef std::vector<Toolbar> Toolbars;
+
+       typedef Items::const_iterator item_iterator;
 
-       typedef Items::const_iterator const_iterator;
-       ///
        ToolbarBackend();
-       ///
-       iterator begin() {
-               return items.begin();
-       }
-       ///
-       const_iterator begin() const {
-               return items.begin();
-       }
-       ///
-       iterator end() {
-               return items.end();
+
+       /// iterator for all toolbars
+       Toolbars::const_iterator begin() const {
+               return toolbars.begin();
        }
-       ///
-       const_iterator end() const {
-               return items.end();
+
+       Toolbars::const_iterator end() const {
+               return toolbars.end();
        }
-       ///
+
+       /// read a toolbar from the file
        void read(LyXLex &);
 
        /// return a full path of an XPM for the given action
@@ -67,11 +69,13 @@ public:
 
 private:
        /// add the given lfun with tooltip if relevant
-       void add(int, string const & tooltip = string());
+       void add(Toolbar & tb, int, string const & tooltip = string());
+
        /// add the given lfun with tooltip if relevant
-       void add(string const &, string const & tooltip);
-       /// all the items
-       Items items;
+       void add(Toolbar & tb, string const &, string const & tooltip);
+
+       /// all the toolbars
+       Toolbars toolbars;
 };
 
 /// The global instance
index 24d131de53ff17523d1ff3714da098ff78841464..dd9f5b356d955ae0035dbda9e1daf86c97af1426 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * Toolbar.C: handle multiple toolbars
+
 2003-04-08  John Levon  <levon@movementarian.org>
 
        * Toolbar.C: handle tooltip
index c19f215149186604532fb15cebe6f54aaf96554a..836e40ce83fde0ff15a67d0087f5393405d25c60 100644 (file)
@@ -24,11 +24,12 @@ Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend)
 {
        pimpl_ = new Pimpl(o, x, y);
 
-       // extracts the toolbar actions from  the backend
-       for (ToolbarBackend::const_iterator cit = backend.begin();
-            cit != backend.end(); ++cit) {
-               pimpl_->add(cit->first, cit->second);
-       }
+       // extracts the toolbars from the backend
+       ToolbarBackend::Toolbars::const_iterator cit = backend.begin();
+       ToolbarBackend::Toolbars::const_iterator end = backend.end();
+
+       for (; cit != end; ++cit)
+               pimpl_->add(*cit);
 }
 
 
index 49bbc50d043ec7305da27c042d9665fd5fdcd205..130257b7849eefb0fc10c07a0c9504e506958a83 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * Toolbar_pimpl.h:
+       * Toolbar_pimpl.C: handle API change for multiple
+       toolbars
+
 2003-04-08  John Levon  <levon@movementarian.org>
 
        * Toolbar_pimpl.C: move xpm code into ToolbarBackend,
index fcc866c07f2efbbbd283a4276ccc408be3a43344..f00d776f3ac1fb7d2ceef87ffa225315f8986cab 100644 (file)
@@ -12,7 +12,6 @@
 #include <config.h>
 
 
-#include "ToolbarBackend.h"
 #include "debug.h"
 #include "gettext.h"
 #include "lyxfunc.h"
@@ -193,21 +192,27 @@ void Toolbar::Pimpl::openLayoutList()
 }
 
 
-void Toolbar::Pimpl::add(int action, string const & tooltip)
+void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
 {
-       if (!toolbars_.size()) {
-               toolbars_.push_back(new QToolBar(owner_));
-       }
+       QToolBar * qtb = new QToolBar(qt_(tb.name), owner_);
+
+       ToolbarBackend::item_iterator it = tb.items.begin();
+       ToolbarBackend::item_iterator end = tb.items.end();
+       for (; it != end; ++it)
+               add(qtb, it->first, it->second);
+
+       toolbars_.push_back(qtb);
+}
 
+
+void Toolbar::Pimpl::add(QToolBar * tb, int action, string const & tooltip)
+{
        switch (action) {
        case ToolbarBackend::SEPARATOR:
-               toolbars_.back()->addSeparator();
-               break;
-       case ToolbarBackend::NEWLINE:
-               toolbars_.push_back(new QToolBar(owner_));
+               tb->addSeparator();
                break;
        case ToolbarBackend::LAYOUTS: {
-               combo_ = new QLComboBox(toolbars_.back());
+               combo_ = new QLComboBox(tb);
                QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed);
                combo_->setSizePolicy(p);
                combo_->setFocusPolicy(QWidget::ClickFocus);
@@ -219,11 +224,11 @@ void Toolbar::Pimpl::add(int action, string const & tooltip)
        }
        default: {
                QPixmap p = QPixmap(toolbarbackend.getIcon(action).c_str());
-               QToolButton * tb =
+               QToolButton * button =
                        new QToolButton(p, toqstr(tooltip), "",
-                       proxy_.get(), SLOT(button_selected()), toolbars_.back());
+                       proxy_.get(), SLOT(button_selected()), tb);
 
-               map_[tb] = action;
+               map_[button] = action;
                break;
        }
        }
index fe8769e35dd5bc5b21a07e9869e5c9cc7119af22..0f4d87934ef7e8c79d763b90bc40280dd78f9f39 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #include "frontends/Toolbar.h"
+#include "ToolbarBackend.h"
 
 #include "qt_helpers.h"
 
@@ -37,8 +38,11 @@ public:
 
        ~Pimpl();
 
-       /// add a new button to the toolbar.
-       void add(int action, string const & tooltip);
+       /// add a new toolbar
+       void add(ToolbarBackend::Toolbar const & tb);
+
+       /// add an item to a toolbar
+       void add(QToolBar * tb, int action, string const & tooltip);
 
        /// update the state of the icons
        void update();
index 11656457ac40c18b08ce212530ac7eecd1f25ade..14404a76554bee67fd19d3d00325a74a558fb275 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-09  John Levon  <levon@movementarian.org>
+
+       * Toolbar_pimpl.C:
+       * Toolbar_pimpl.h: ignore every toolbar after the first one
+
 2003-04-09  Angus Leeming  <leeming@lyx.org>
 
        Enable "proper" tooltips in browser widgets if your version of
index 8ae85cb9c02c4fcf46b98b74cce31cf99bf32d47..7f0a9f4290f3322355748dcce74816387a3166ab 100644 (file)
@@ -26,7 +26,6 @@
 #include "Tooltips.h"
 #include FORMS_H_LOCATION
 #include "combox.h"
-#include "ToolbarBackend.h"
 #include "xforms_helpers.h"
 
 #include "LyXAction.h"
@@ -266,6 +265,19 @@ void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
 } // namespace anon
 
 
+void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
+{
+       // we can only handle one toolbar
+       if (!toollist_.empty())
+               return;
+
+       ToolbarBackend::item_iterator it = tb.items.begin();
+       ToolbarBackend::item_iterator end = tb.items.end();
+       for (; it != end; ++it)
+               add(it->first, it->second);
+}
+
+
 void Toolbar::Pimpl::add(int action, string const & tooltip)
 {
        toolbarItem item;
index 73b8a0ba1dd3ddcb2bb8b1ea3e5c3b686c9dd6d9..5c97ccceff2f69ba9e9c217c3aa5091329a2b07c 100644 (file)
@@ -17,6 +17,7 @@
 #include "forms_fwd.h"
 
 #include "frontends/Toolbar.h"
+#include "ToolbarBackend.h"
 
 
 class XFormsView;
@@ -31,7 +32,10 @@ public:
 
        ~Pimpl();
 
-       /// add a new button to the toolbar.
+       /// add a new toolbar
+       void add(ToolbarBackend::Toolbar const & tb);
+
+       /// add an item to a toolbar
        void add(int action, string const & tooltip);
 
        /// update the state of the icons