From 7d978a119f332cecea05f0e0d74c4040e6923ada Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Wed, 27 Jul 2005 15:22:08 +0000 Subject: [PATCH] Do not use localized strings internally (bug 1870) Someone please check the gtk TOC dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10363 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/frontends/controllers/ChangeLog | 5 +++++ src/frontends/controllers/ControlToc.C | 9 +++++++-- src/frontends/controllers/ControlToc.h | 2 +- src/frontends/gtk/ChangeLog | 6 ++++++ src/frontends/gtk/GToc.C | 9 ++++++--- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QToc.C | 11 +++++++---- src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/FormToc.C | 22 +++++++++++++--------- src/insets/ChangeLog | 6 ++++++ src/insets/insetfloat.C | 6 +++--- src/insets/insetwrap.C | 6 +++--- src/toc.C | 13 ++++++------- src/toc.h | 5 +++-- 15 files changed, 80 insertions(+), 34 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 720581cf4f..2566c7779c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2005-07-27 Jürgen Spitzmüller + + * toc.[Ch]: Do not use translatable strings (bug 1870). + 2005-07-20 John Levon * tabular.C: fix 1748 - setting multicolumn adds diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 1e73f493e0..a35e0e9b4b 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2005-07-27 Jürgen Spitzmüller + + * ControlToc.[Ch]: getGuiName takes a type argument now. + * ControlToc.C (getGuiName): Do all guiname translations here (bug 1870) + 2005-07-16 José Matos * ControlTabular.C (set): use a single papersize variable. diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C index 36d8d77795..f64cb4ad62 100644 --- a/src/frontends/controllers/ControlToc.C +++ b/src/frontends/controllers/ControlToc.C @@ -11,6 +11,7 @@ #include #include "ControlToc.h" +#include "gettext.h" using std::vector; using std::string; @@ -21,6 +22,7 @@ class Buffer; namespace lyx { namespace frontend { + ControlToc::ControlToc(Dialog & d) : ControlCommand(d, "toc") {} @@ -38,9 +40,12 @@ vector const ControlToc::getTypes() const } -string const ControlToc::getGuiName() const +string const ControlToc::getGuiName(string const & type) const { - return toc::getGuiName(params().getCmdName(), kernel().buffer()); + if (type == "TOC") + return _("Table of Contents"); + else + return _(toc::getGuiName(type, kernel().buffer())); } diff --git a/src/frontends/controllers/ControlToc.h b/src/frontends/controllers/ControlToc.h index bec48d93d1..f71751c2fe 100644 --- a/src/frontends/controllers/ControlToc.h +++ b/src/frontends/controllers/ControlToc.h @@ -34,7 +34,7 @@ public: std::vector const getTypes() const; /// Return the guiname from a given cmdName of the TOC param - std::string const getGuiName() const; + std::string const getGuiName(std::string const & type) const; /// Given a type, returns the contents toc::Toc const getContents(std::string const & type) const; diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 1b095fde43..19453e8c75 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,9 @@ +2005-07-27 Jürgen Spitzmüller + + * GToc.C (update, updateContents): Do not compare against + translatable strings (bug 1870). + Someone who can actually compile against gtk should verify this. + 2005-07-24 Georg Baum * GDocument.[Ch], glade/document.glade: remove remaining diff --git a/src/frontends/gtk/GToc.C b/src/frontends/gtk/GToc.C index 949303af83..8d473fccf8 100644 --- a/src/frontends/gtk/GToc.C +++ b/src/frontends/gtk/GToc.C @@ -88,7 +88,8 @@ void GToc::update() void GToc::updateType() { changing_views_ = true; - string const targettype = controller().getGuiName(); + string const targettype = + toc::getType(controller().params().getCmdName()); typestore_->clear(); vector types = controller().getTypes(); @@ -100,8 +101,9 @@ void GToc::updateType() vector::iterator it = types.begin(); vector::iterator end = types.end(); for(;it != end; ++it) { + string const & guiname = controller().getGuiName(*it); Gtk::TreeModel::iterator row = typestore_->append(); - (*row)[listCol_] = *it; + (*row)[listCol_] = guiname; if (*it == targettype) typecombo_->set_active(row); } @@ -119,7 +121,8 @@ void GToc::updateContents() } Gtk::TreeModel::iterator it = typecombo_->get_active(); - Glib::ustring const type = (*it)[listCol_]; + vector const & choice = controller().getTypes(); + string const type = choice[(*it)[listColIndex_]]; toc::Toc const contents = controller().getContents(type); // Check if all elements are the same. diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 2aab567170..f291daf809 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2005-07-27 Jürgen Spitzmüller + + * QToc.C (updateType, update_contents): Do not compare against + translatable strings (bug 1870). + 2005-07-23 Angus Leeming * QRefDialogBase.ui: disconnect two refsLB signals to the diff --git a/src/frontends/qt2/QToc.C b/src/frontends/qt2/QToc.C index be70e5f757..ff4c41e3b9 100644 --- a/src/frontends/qt2/QToc.C +++ b/src/frontends/qt2/QToc.C @@ -56,12 +56,13 @@ void QToc::updateType() dialog_->typeCO->clear(); vector const & choice = controller().getTypes(); - string const & guiname = controller().getGuiName(); + string const & type = toc::getType(controller().params().getCmdName()); for (vector::const_iterator it = choice.begin(); it != choice.end(); ++it) { - dialog_->typeCO->insertItem(toqstr(*it)); - if (*it == guiname) { + string const & guiname = controller().getGuiName(*it); + dialog_->typeCO->insertItem(toqstr(guiname)); + if (*it == type) { dialog_->typeCO->setCurrentItem(it - choice.begin()); setTitle(guiname); } @@ -78,7 +79,8 @@ void QToc::update_contents() void QToc::updateToc(int newdepth) { - string type = fromqstr(dialog_->typeCO->currentText()); + vector const & choice = controller().getTypes(); + string const & type = choice[dialog_->typeCO->currentItem()]; toc::Toc const & contents = controller().getContents(type); @@ -157,6 +159,7 @@ void QToc::updateToc(int newdepth) dialog_->tocLV->setUpdatesEnabled(true); dialog_->tocLV->update(); + setTitle(dialog_->typeCO->currentText()); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 0e6097bf28..666a6a1ba1 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2005-07-27 Jürgen Spitzmüller + + * FormToc.C (updateType, update_contents): Do not compare against + translatable strings (bug 1870). + 2005-07-22 Angus Leeming * FormSearch.C (input): do not trim the find and replace strings. diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index ccc1e37dca..7feec7f18e 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -43,9 +43,8 @@ void FormToc::build() vector types = controller().getTypes(); - string const choice = - ' ' + getStringFromVector(controller().getTypes(), " | ") + ' '; + ' ' + getStringFromVector(types, " | ") + ' '; fl_addto_choice(dialog_->choice_toc_type, choice.c_str()); // Manage the cancel/close button @@ -85,18 +84,23 @@ void FormToc::updateType() { // Update the choice list from scratch fl_clear_choice(dialog_->choice_toc_type); - string const choice = getStringFromVector(controller().getTypes(), "|"); - fl_addto_choice(dialog_->choice_toc_type, choice.c_str()); - - // And select the correct one - string const guiname = controller().getGuiName(); - fl_set_choice_text(dialog_->choice_toc_type, guiname.c_str()); + vector const & choice = controller().getTypes(); + string const & type = toc::getType(controller().params().getCmdName()); + for (vector::const_iterator it = choice.begin(); + it != choice.end(); ++it) { + string const & guiname = controller().getGuiName(*it); + fl_addto_choice(dialog_->choice_toc_type, guiname.c_str()); + // And select the correct one + if (*it == type) + fl_set_choice(dialog_->choice_toc_type, it - choice.begin() + 1); + } } void FormToc::updateContents() { - string const type = getString(dialog_->choice_toc_type); + vector types = controller().getTypes(); + string const type = types[fl_get_choice(dialog_->choice_toc_type) - 1]; if (type.empty()) { fl_clear_browser(dialog_->browser_toc); fl_add_browser_line(dialog_->browser_toc, diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 655d47b5b6..f6d4646741 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2005-07-27 Jürgen Spitzmüller + + * insetfloat.C: + * insetwrap.C: Do not use translatable strings as internal identifier + (bug 1870). + 2005-07-18 Lars Gullik Bjønnes * insetbase.C: include boost/current_function.hpp diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index a68d8a6774..e2121a3402 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -434,12 +434,12 @@ void InsetFloat::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const // Find a caption layout in one of the (child inset's) pars for (; pit != end; ++pit) { if (pit->layout()->labeltype == LABEL_SENSITIVE) { - string const name = floatname(params_.type, buf.params()); + string const type = params_.type; string const str = - convert(toclist[name].size() + 1) + convert(toclist[type].size() + 1) + ". " + pit->asString(buf, false); lyx::toc::TocItem const item(pit->id(), 0 , str); - toclist[name].push_back(item); + toclist[type].push_back(item); } } } diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 1ac102ba36..7d41b6df86 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -242,12 +242,12 @@ void InsetWrap::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const // Find a caption layout in one of the (child inset's) pars for (; pit != end; ++pit) { if (pit->layout()->labeltype == LABEL_SENSITIVE) { - string const name = floatname(params_.type, buf.params()); + string const type = params_.type; string const str = - convert(toclist[name].size() + 1) + convert(toclist[type].size() + 1) + ". " + pit->asString(buf, false); lyx::toc::TocItem const item(pit->id(), 0 , str); - toclist[name].push_back(item); + toclist[type].push_back(item); } } } diff --git a/src/toc.C b/src/toc.C index d207636526..0a17d5a2c1 100644 --- a/src/toc.C +++ b/src/toc.C @@ -17,7 +17,6 @@ #include "bufferparams.h" #include "FloatList.h" #include "funcrequest.h" -#include "gettext.h" #include "LyXAction.h" #include "paragraph.h" #include "pariterator.h" @@ -61,20 +60,20 @@ string const getType(string const & cmdName) { // special case if (cmdName == "tableofcontents") - return _("TOC"); + return "TOC"; else return cmdName; } -string const getGuiName(string const & cmdName, Buffer const & buffer) +string const getGuiName(string const & type, Buffer const & buffer) { FloatList const & floats = buffer.params().getLyXTextClass().floats(); - if (floats.typeExist(cmdName)) - return _(floats.getType(cmdName).name()); + if (floats.typeExist(type)) + return floats.getType(type).name(); else - return getType(cmdName); + return type; } @@ -130,7 +129,7 @@ TocList const getTocList(Buffer const & buf) tocstring = pit->asString(buf, true); TocItem const item(pit->id(), toclevel - min_toclevel, tocstring); - toclist[_("TOC")].push_back(item); + toclist["TOC"].push_back(item); } } return toclist; diff --git a/src/toc.h b/src/toc.h index 75cdcbaadd..f0f2f80262 100644 --- a/src/toc.h +++ b/src/toc.h @@ -65,8 +65,9 @@ void asciiTocList(std::string const &, Buffer const &, std::ostream &); by ControlToc::getContents() */ std::string const getType(std::string const & cmdName); -/// Returns the guiname from a given CmdName -std::string const getGuiName(std::string const & cmdName, Buffer const &); +/** Returns the guiname from a given @c type + The localization of the names will be done in the frontends */ +std::string const getGuiName(std::string const & type, Buffer const &); inline bool operator==(TocItem const & a, TocItem const & b) -- 2.39.2