diff --git a/lib/ChangeLog b/lib/ChangeLog index bb14ef8005..2d3301b7af 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-04-09 John Levon + + * ui/default.ui: add a name for the toolbar + 2003-04-08 John Levon * ui/default.ui: add tooltips for toolbar items, diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 9bfaff6dc9..1fe6bf6134 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -411,7 +411,7 @@ End # # This is the default toolbar: -Toolbar +Toolbar "Standard" Layouts Item "Open document" "file-open" Item "Save document" "buffer-write" diff --git a/po/ChangeLog b/po/ChangeLog index 23ab5b1502..fe3ec4b4be 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2003-04-09 John Levon + + * Makefile.in.in: translate the toolbar name + 2003-03-30 John Levon * Makefile.in.in: fix escaping of " for qt UI files diff --git a/po/Makefile.in.in b/po/Makefile.in.in index 3b69603746..6d96a66631 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -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); \ diff --git a/src/ChangeLog b/src/ChangeLog index 54a3d25b7a..916913c5a2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-04-09 John Levon + + * ToolbarBackend.h: + * ToolbarBackend.C: allow multiple toolbars + 2003-04-09 Lars Gullik Bjønnes * undo_funcs.C (setCursorParUndo): adjust diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index 263efeb198..cd6b22123b 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -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); } } diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h index 0819908ee2..ba2bfa4c9a 100644 --- a/src/ToolbarBackend.h +++ b/src/ToolbarBackend.h @@ -38,28 +38,30 @@ public: /// the toolbar items typedef std::vector > Items; - typedef Items::iterator iterator; + /// a toolbar + struct Toolbar { + /// toolbar UI name + string name; + /// toolbar contents + Items items; + }; + + typedef std::vector Toolbars; + + typedef Items::const_iterator item_iterator; - typedef Items::const_iterator const_iterator; - /// ToolbarBackend(); - /// - iterator begin() { - return items.begin(); + + /// iterator for all toolbars + Toolbars::const_iterator begin() const { + return toolbars.begin(); } - /// - const_iterator begin() const { - return items.begin(); + + Toolbars::const_iterator end() const { + return toolbars.end(); } - /// - iterator end() { - return items.end(); - } - /// - const_iterator end() const { - return items.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 diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 24d131de53..dd9f5b356d 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2003-04-09 John Levon + + * Toolbar.C: handle multiple toolbars + 2003-04-08 John Levon * Toolbar.C: handle tooltip diff --git a/src/frontends/Toolbar.C b/src/frontends/Toolbar.C index c19f215149..836e40ce83 100644 --- a/src/frontends/Toolbar.C +++ b/src/frontends/Toolbar.C @@ -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); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 49bbc50d04..130257b784 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,9 @@ +2003-04-09 John Levon + + * Toolbar_pimpl.h: + * Toolbar_pimpl.C: handle API change for multiple + toolbars + 2003-04-08 John Levon * Toolbar_pimpl.C: move xpm code into ToolbarBackend, diff --git a/src/frontends/qt2/Toolbar_pimpl.C b/src/frontends/qt2/Toolbar_pimpl.C index fcc866c07f..f00d776f3a 100644 --- a/src/frontends/qt2/Toolbar_pimpl.C +++ b/src/frontends/qt2/Toolbar_pimpl.C @@ -12,7 +12,6 @@ #include -#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; } } diff --git a/src/frontends/qt2/Toolbar_pimpl.h b/src/frontends/qt2/Toolbar_pimpl.h index fe8769e35d..0f4d87934e 100644 --- a/src/frontends/qt2/Toolbar_pimpl.h +++ b/src/frontends/qt2/Toolbar_pimpl.h @@ -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(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 11656457ac..14404a7655 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2003-04-09 John Levon + + * Toolbar_pimpl.C: + * Toolbar_pimpl.h: ignore every toolbar after the first one + 2003-04-09 Angus Leeming Enable "proper" tooltips in browser widgets if your version of diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 8ae85cb9c0..7f0a9f4290 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -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; diff --git a/src/frontends/xforms/Toolbar_pimpl.h b/src/frontends/xforms/Toolbar_pimpl.h index 73b8a0ba1d..5c97ccceff 100644 --- a/src/frontends/xforms/Toolbar_pimpl.h +++ b/src/frontends/xforms/Toolbar_pimpl.h @@ -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