From fff4456dee29e675d7f2ed3490db39bcb7e10e53 Mon Sep 17 00:00:00 2001 From: rathnor Date: Mon, 7 Jun 2004 11:46:05 +0000 Subject: update NLS string handling... --- ChangeLog | 13 ++++ nls/Makefile.am | 5 +- src/Ewmh.cc | 9 +-- src/FbCommandFactory.cc | 3 +- src/FbTk/Color.cc | 6 +- src/FbTk/EventManager.cc | 5 +- src/FbTk/Font.cc | 9 ++- src/FbTk/I18n.cc | 153 ++++++++++++++++++++++++++++++++++++++++++++++ src/FbTk/I18n.hh | 112 +++++++++++++++++++++++++++++++++ src/FbTk/ImageControl.cc | 6 +- src/FbTk/Makefile.am | 1 + src/FbTk/Menu.cc | 6 +- src/FbTk/Resource.cc | 8 ++- src/FbTk/TextureRender.cc | 31 ++++++---- src/FbTk/Theme.cc | 11 ++-- src/FbTk/Transparent.cc | 27 +++++--- src/FbTk/XFontImp.cc | 11 ++-- src/Gnome.cc | 6 +- src/I18n.cc | 140 ------------------------------------------ src/I18n.hh | 83 ------------------------- src/IconMenu.cc | 8 +-- src/IconbarTool.cc | 66 +++++++++++++------- src/Keys.cc | 14 +++-- src/Makefile.am | 4 +- src/MenuCreator.cc | 58 ++++++------------ src/RegExp.cc | 8 ++- src/Remember.cc | 50 +++++++-------- src/Screen.cc | 143 +++++++++++++++++++++++-------------------- src/Slit.cc | 146 +++++++++++++++++++++---------------------- src/Slit.hh | 6 +- src/Toolbar.cc | 116 +++++++++++++++++------------------ src/WinClient.cc | 7 ++- src/Window.cc | 4 +- src/Workspace.cc | 13 ++-- src/WorkspaceMenu.cc | 19 +++--- src/Xutil.cc | 14 ++--- src/fluxbox.cc | 73 +++++++++++----------- src/main.cc | 92 +++++++++++++++------------- 38 files changed, 800 insertions(+), 686 deletions(-) create mode 100644 src/FbTk/I18n.cc create mode 100644 src/FbTk/I18n.hh delete mode 100644 src/I18n.cc delete mode 100644 src/I18n.hh diff --git a/ChangeLog b/ChangeLog index 3b0eef9..49825b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ (Format: Year/Month/Day) Changes for 0.9.10: +*04/06/07: + * Initial NLS update (Simon) + - use _FBTEXT, or _FBTKTEXT for all strings that go to the user + - regenerate fluxbox-nls.hh when adding new strings + - This patch doesn't convert old translations, so for the mo, + translations are broken, sorry. Thats next. + {nls,src,FbTk}/Makefile.am fluxbox-nls.hh nls/nlsinfo -src/I18n.hh/cc + +FbTk/I18n.hh/cc Color.cc EventManager.cc Font.cc ImageControl.cc + Menu.cc Resource.cc TextureRender.cc Theme.cc Transparent.cc + XFontImp.cc Gnome.cc Ewmh.cc FbCommandFactory.cc IconMenu.cc + IconbarTool.cc Keys.cc MenuCreator.cc RegExp.cc Remember.cc Screen.cc + Slit.hh/cc Toolbar.cc WinClient.cc Window.cc Workspace.cc + WorkspaceMenu.cc Xutil.cc fluxbox.cc main.cc *04/05/24: * Fix handling alpha value of zero (Simon) - also fix up defaulting of missing alpha theme items to 255 diff --git a/nls/Makefile.am b/nls/Makefile.am index 747665e..6e9bb02 100644 --- a/nls/Makefile.am +++ b/nls/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = C da_DK es_ES et_EE fr_FR pt_BR ru_RU sv_SE \ sl_SI pl_PL MAINTAINERCLEANFILES = Makefile.in fluxbox-nls.hh -EXTRA_DIST=fluxbox-nls.hh convert.awk +EXTRA_DIST=fluxbox-nls.hh convert.awk nlsinfo uninstall-local: @if test x$(NLSTEST) = "x-DNLS"; then \ @@ -14,3 +14,6 @@ uninstall-local: fi distclean-local: rm -f *\~ + +fluxbox-nls.hh: + ./nlsinfo -H -N FBNLS $(top_srcdir)/src > fluxbox-nls.hh diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 64583cc..ff09588 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Ewmh.cc,v 1.45 2004/03/07 23:37:39 rathnor Exp $ +// $Id: Ewmh.cc,v 1.46 2004/06/07 11:46:04 rathnor Exp $ #include "Ewmh.hh" @@ -30,6 +30,7 @@ #include "fluxbox.hh" #include "FbTk/FbWindow.hh" +#include "FbTk/I18n.hh" #include #include @@ -244,10 +245,11 @@ void Ewmh::updateClientList(BScreen &screen) { for (; icon_it != icon_it_end; ++icon_it) { num += (*icon_it)->numClients(); } - + Window *wl = new (nothrow) Window[num]; if (wl == 0) { - cerr<<"Fatal: Out of memory, can't allocate for Ewmh client list"<sendClose(); return true; diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index 1a17be7..db9c4d6 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommandFactory.cc,v 1.31 2004/05/02 21:13:08 fluxgen Exp $ +// $Id: FbCommandFactory.cc,v 1.32 2004/06/07 11:46:04 rathnor Exp $ #include "FbCommandFactory.hh" @@ -180,7 +180,6 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, // i.e so users can set space before workspace name and so on string value = name.substr(pos + 1); name = name.substr(0, pos); - cerr<<"Creating SetResourceValue "< using namespace std; @@ -155,7 +156,8 @@ void Color::allocate(unsigned short red, unsigned short green, unsigned short bl if (!XAllocColor(disp, DefaultColormap(disp, screen), &color)) { - cerr<<"FbTk::Color: Allocation error."< using namespace std; @@ -36,8 +37,10 @@ EventManager *EventManager::instance() { } EventManager::~EventManager() { +#ifdef DEBUG if (m_eventhandlers.size() != 0) cerr<<"FbTk::EventManager: Warning: unregistered eventhandlers!"<loaded() != loaded) { // if the new font failed to load, fall back to 'fixed' - if (!m_fontimp->load("fixed")) // if that failes too, output warning - cerr<<"Warning: can't load fallback font 'fixed'."<load("fixed")) {// if that failes too, output warning + _FB_USES_NLS; + cerr<<_FBTKTEXT(Error, CantFallbackFont, "Warning: can't load fallback font", "Attempt to load the last-resort default font failed")<<" 'fixed'."< + +#include +#include +#include + +#include + +// TODO: FIXME: the LOCALEPATH from this file should be ./configure-ed into config.h +#include "../defaults.hh" + +using std::cerr; +using std::endl; +using std::string; + +namespace FbTk { + +void NLSInit(const char *catalog) { + I18n *i18n = I18n::instance(); + i18n->openCatalog(catalog); +} + + +I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { +#ifdef HAVE_SETLOCALE + //make sure we don't get 0 to m_locale string + char *temp = setlocale(LC_ALL, ""); + m_locale = ( temp ? temp : ""); + if (m_locale.empty()) { + cerr<<"Warning: Failed to set locale, reverting to \"C\""< 1) + m_multibyte = true; + + // truncate any encoding off the end of the locale + + // remove everything after @ + string::size_type index = m_locale.find('@'); + if (index != string::npos) + m_locale.erase(index); //erase all characters starting at index + // remove everything after . + index = m_locale.find('.'); + if (index != string::npos) + m_locale.erase(index); //erase all characters starting at index + // remove everything before = + index = m_locale.find('='); + if (index != string::npos) + m_locale.erase(0,index+1); //erase all characters starting up to index + } +#endif // HAVE_SETLOCALE +} + + +I18n::~I18n() { + +#if defined(NLS) && defined(HAVE_CATCLOSE) + if (m_catalog_fd != (nl_catd)-1) + catclose(m_catalog_fd); +#endif // HAVE_CATCLOSE +} + +I18n *I18n::instance() { + static I18n singleton; //singleton object + return &singleton; +} + +void I18n::openCatalog(const char *catalog) { +#if defined(NLS) && defined(HAVE_CATOPEN) + + string catalog_filename = LOCALEPATH; + catalog_filename += '/'; + catalog_filename += m_locale; + catalog_filename += '/'; + catalog_filename += catalog; + +#ifdef MCLoadBySet + m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); +#else // !MCLoadBySet + m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); +#endif // MCLoadBySet + + if (m_catalog_fd == (nl_catd)-1) { + cerr<<"Warning: Failed to open file("< +#endif // HAVE_LOCALE_H + +#ifdef HAVE_NL_TYPES_H +// this is needed for linux libc5 systems +extern "C" { +#include +} +#elif defined(__CYGWIN__) +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus +typedef int nl_catd; +char *catgets(nl_catd cat, int set_number, int message_number, char *message); +nl_catd catopen(char *name, int flag); +void catclose(nl_catd cat); +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // HAVE_NL_TYPES_H + +#include + +// Some defines to help out +#ifdef NLS +#define _FB_USES_NLS \ + FbTk::I18n &i18n = *FbTk::I18n::instance() + +// ignore the description, it's for helping translators +#define _FBTEXT(msgset, msgid, default_text, description) \ + i18n.getMessage(FBNLS::msgset ## Set, FBNLS::msgset ## msgid, default_text) + +// This ensure that FbTk nls stuff is in a kind of namespace of its own +#define _FBTKTEXT( msgset, msgid, default_text, description) \ + i18n.getMessage(FBNLS::FbTk ## msgset ## Set, FBNLS::FbTk ## msgset ## msgid, default_text) + +#else // no NLS + +#define _FB_USES_NLS +#define _FBTEXT(msgset, msgid, default_text, description) \ + default_text + +#define _FBTKTEXT(msgset, msgid, default_text, description) \ + default_text + +#endif // defined NLS + +namespace FbTk { + +class I18n { +public: + static I18n *instance(); + inline const char *getLocale() const { return m_locale.c_str(); } + inline bool multibyte() const { return m_multibyte; } + inline const nl_catd &getCatalogFd() const { return m_catalog_fd; } + + const char *getMessage(int set_number, int message_number, + const char *default_messsage = 0) const; + void openCatalog(const char *catalog); +private: + I18n(); + ~I18n(); + std::string m_locale; + bool m_multibyte; + nl_catd m_catalog_fd; + +}; + +void NLSInit(const char *); + +}; // end namespace FbTk + +#endif // I18N_HH diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index b9c5029..9e4f2df 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -22,13 +22,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ImageControl.cc,v 1.12 2004/01/21 14:15:29 fluxgen Exp $ +// $Id: ImageControl.cc,v 1.13 2004/06/07 11:46:05 rathnor Exp $ #include "ImageControl.hh" #include "TextureRender.hh" #include "App.hh" #include "SimpleCommand.hh" +#include "I18n.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -638,7 +639,8 @@ void ImageControl::createColorTable() { } default: - cerr<<"FbTk::ImageControl: Unsupported visual"< #include @@ -495,7 +496,8 @@ void Menu::update(int active_index) { menu.frame.depth()); if (m_frame_pm.drawable() == 0) { - cerr<<"FbTk::Menu: Warning: Failed to create pixmap ("<< + _FB_USES_NLS; + cerr<<"FbTk::Menu: "<<_FBTKTEXT(Error, CreatePixmap, "Error creating pixmap", "Couldn't create a pixmap - image - for some reason")<<" ("<< menu.frame.window()<<", "< #include @@ -81,8 +82,9 @@ bool ResourceManager::load(const char *filename) { resource->altName().c_str(), &value_type, &value)) resource->setFromString(value.addr); else { - cerr<<"Failed to read: "<name()<name()<setDefaultValue(); } } diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 3e56e88..6f496d7 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.cc,v 1.8 2004/01/21 20:19:50 fluxgen Exp $ +// $Id: TextureRender.cc,v 1.9 2004/06/07 11:46:05 rathnor Exp $ #include "TextureRender.hh" @@ -30,6 +30,7 @@ #include "App.hh" #include "FbPixmap.hh" #include "GContext.hh" +#include "I18n.hh" #include #include @@ -46,16 +47,17 @@ TextureRender::TextureRender(ImageControl &imgctrl, ncolors(ncolors), xtable(0), ytable(0) { + _FB_USES_NLS; width = ((signed) w > 0) ? w : 1; height = ((signed) h > 0) ? h : 1; // clamp to "normal" size if (width > 3200) { - cerr<<"TextureRender: Warning! Width > 3200 setting Width = 3200"< 3200 setting Width = 3200", "Image width seems too big, clamping")< 3200) { - cerr<<"TextureRender: Warning! Height > 3200 setting Height = 3200"< 3200 setting Height = 3200", "Image height seems too big, clamping")< #include @@ -140,9 +141,11 @@ void ThemeManager::loadTheme(Theme &tm) { if (!loadItem(*resource)) { // try fallback resource in theme if (!tm.fallback(*resource)) { - if (verbose()) - cerr<<"Failed to read theme item: "<name()<setDefaultValue(); + if (verbose()) { + _FB_USES_NLS; + cerr<<_FBTKTEXT(Error, ThemeItem, "Failed to read theme item", "When reading a style, couldn't read a specific item (following)")<<": "<name()<setDefaultValue(); } } } diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc index ed50e9e..ab6b4d9 100644 --- a/src/FbTk/Transparent.cc +++ b/src/FbTk/Transparent.cc @@ -19,10 +19,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Transparent.cc,v 1.5 2003/05/13 20:50:56 fluxgen Exp $ +// $Id: Transparent.cc,v 1.6 2004/06/07 11:46:05 rathnor Exp $ #include "Transparent.hh" #include "App.hh" +#include "I18n.hh" #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,12 +34,14 @@ #endif // HAVE_XRENDER #include +#include using namespace std; namespace { #ifdef HAVE_XRENDER Picture createAlphaPic(Window drawable, unsigned char alpha) { Display *disp = FbTk::App::instance()->display(); + _FB_USES_NLS; // try to find a specific render format XRenderPictFormat pic_format; @@ -49,7 +52,7 @@ Picture createAlphaPic(Window drawable, unsigned char alpha) { PictFormatDepth | PictFormatAlphaMask, &pic_format, 0); if (format == 0) { - cerr<<"Warning! FbTk::Transparent: Failed to find valid format for alpha."< @@ -121,6 +122,8 @@ void XFontImp::rotate(float angle) { return; } + _FB_USES_NLS; + //get positive angle while (angle < 0) angle += 360; @@ -157,7 +160,7 @@ void XFontImp::rotate(float angle) { m_rotfont = new(nothrow) XRotFontStruct; if (m_rotfont == 0) { - cerr<<"RotFont: out of memory"< #include @@ -149,7 +150,8 @@ void Gnome::updateClientList(BScreen &screen) { Window *wl = new Window[num]; if (wl == 0) { - cerr<<"Fatal: Out of memory, can't allocate ("< - -#include -#include -#include - -#include - -#include "defaults.hh" - -using std::cerr; -using std::endl; -using std::string; - -void NLSInit(const char *catalog) { - I18n *i18n = I18n::instance(); - i18n->openCatalog(catalog); -} - - -I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { -#ifdef HAVE_SETLOCALE - //make sure we don't get 0 to m_locale string - char *temp = setlocale(LC_ALL, ""); - m_locale = ( temp ? temp : ""); - if (m_locale.empty()) { - cerr<<"Warning: Failed to set locale, reverting to \"C\""< 1) - m_multibyte = true; - - // truncate any encoding off the end of the locale - - // remove everything after @ - string::size_type index = m_locale.find('@'); - if (index != string::npos) - m_locale.erase(index); //erase all characters starting at index - // remove everything after . - index = m_locale.find('.'); - if (index != string::npos) - m_locale.erase(index); //erase all characters starting at index - // remove everything before = - index = m_locale.find('='); - if (index != string::npos) - m_locale.erase(0,index+1); //erase all characters starting up to index - } -#endif // HAVE_SETLOCALE -} - - -I18n::~I18n() { - -#if defined(NLS) && defined(HAVE_CATCLOSE) - if (m_catalog_fd != (nl_catd)-1) - catclose(m_catalog_fd); -#endif // HAVE_CATCLOSE -} - -I18n *I18n::instance() { - static I18n singleton; //singleton object - return &singleton; -} - -void I18n::openCatalog(const char *catalog) { -#if defined(NLS) && defined(HAVE_CATOPEN) - - string catalog_filename = LOCALEPATH; - catalog_filename += '/'; - catalog_filename += m_locale; - catalog_filename += '/'; - catalog_filename += catalog; - -#ifdef MCLoadBySet - m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); -#else // !MCLoadBySet - m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); -#endif // MCLoadBySet - - if (m_catalog_fd == (nl_catd)-1) { - cerr<<"Warning: Failed to open file("< -#endif // HAVE_LOCALE_H - -#ifdef HAVE_NL_TYPES_H -// this is needed for linux libc5 systems -extern "C" { -#include -} -#elif defined(__CYGWIN__) -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus -typedef int nl_catd; -char *catgets(nl_catd cat, int set_number, int message_number, char *message); -nl_catd catopen(char *name, int flag); -void catclose(nl_catd cat); -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // HAVE_NL_TYPES_H - -#include - -class I18n { -public: - static I18n *instance(); - inline const char *getLocale() const { return m_locale.c_str(); } - inline bool multibyte() const { return m_multibyte; } - inline const nl_catd &getCatalogFd() const { return m_catalog_fd; } - - const char *getMessage(int set_number, int message_number, - const char *default_messsage = 0) const; - void openCatalog(const char *catalog); -private: - I18n(); - ~I18n(); - std::string m_locale; - bool m_multibyte; - nl_catd m_catalog_fd; - -}; - -void NLSInit(const char *); - -#endif // I18N_HH diff --git a/src/IconMenu.cc b/src/IconMenu.cc index 16d7b27..f631b3a 100644 --- a/src/IconMenu.cc +++ b/src/IconMenu.cc @@ -19,14 +19,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconMenu.cc,v 1.1 2004/05/02 20:51:36 fluxgen Exp $ +// $Id: IconMenu.cc,v 1.2 2004/06/07 11:46:04 rathnor Exp $ #include "IconMenu.hh" #include "Screen.hh" #include "IconMenuItem.hh" #include "fluxbox.hh" -#include "I18n.hh" +#include "FbTk/I18n.hh" static void updateItems(FbTk::Menu &menu, BScreen &screen) { menu.removeAll(); @@ -47,8 +47,8 @@ IconMenu::IconMenu(BScreen &screen): *screen.layerManager(). getLayer(Fluxbox::instance()->getMenuLayer())) { - setLabel(I18n::instance()->getMessage(FBNLS::IconSet, - FBNLS::IconIcons, "Icons")); + _FB_USES_NLS; + setLabel(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title")); screen.iconListSig().attach(this); updateItems(*this, screen); } diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index ae14fc3..502117a 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.cc,v 1.36 2004/04/26 15:04:37 rathnor Exp $ +// $Id: IconbarTool.cc,v 1.37 2004/06/07 11:46:04 rathnor Exp $ #include "IconbarTool.hh" @@ -35,6 +35,7 @@ #include "CommandParser.hh" #include "WinClient.hh" +#include "FbTk/I18n.hh" #include "FbTk/Menu.hh" #include "FbTk/MenuItem.hh" #include "FbTk/RefCount.hh" @@ -87,7 +88,7 @@ void FbTk::Resource::setFromString(const char *str) { m_value = Container::LEFT; else if (strcasecmp(str, "Right") == 0) m_value = Container::RIGHT; - else if (strcasecmp(str, "RELATIVE") == 0) + else if (strcasecmp(str, "Relative") == 0) m_value = Container::RELATIVE; else setDefaultValue(); @@ -157,32 +158,55 @@ private: void setupModeMenu(FbTk::Menu &menu, IconbarTool &handler) { using namespace FbTk; + _FB_USES_NLS; - // TODO: nls - menu.setLabel("Iconbar Mode"); + menu.setLabel(_FBTEXT(Toolbar, IconbarMode, "Iconbar Mode", "Menu title - chooses which set of icons are shown in the iconbar")); RefCount saverc_cmd(new SimpleCommand( *Fluxbox::instance(), &Fluxbox::save_rc)); - //TODO: nls - menu.insert(new ToolbarModeMenuItem("None", handler, - IconbarTool::NONE, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Icons", handler, - IconbarTool::ICONS, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Workspace Icons", handler, - IconbarTool::WORKSPACEICONS, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Workspace", handler, - IconbarTool::WORKSPACE, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("All Windows", handler, - IconbarTool::ALLWINDOWS, saverc_cmd)); + menu.insert(new ToolbarModeMenuItem(_FBTEXT(Toolbar, IconbarModeNone, "None", "No icons are shown in the iconbar"), + handler, + IconbarTool::NONE, saverc_cmd)); + + menu.insert(new ToolbarModeMenuItem( + _FBTEXT(Toolbar, IconbarModeIcons, "Icons", "Iconified windows from all workspaces are shown"), + handler, + IconbarTool::ICONS, saverc_cmd)); + + menu.insert(new ToolbarModeMenuItem( + _FBTEXT(Toolbar, IconbarModeWorkspaceIcons, "WorkspaceIcons", "Iconified windows from this workspace are shown"), + handler, + IconbarTool::WORKSPACEICONS, saverc_cmd)); + + menu.insert(new ToolbarModeMenuItem( + _FBTEXT(Toolbar, IconbarModeWorkspace, "Workspace", "Normal and iconified windows from this workspace are shown"), + handler, + IconbarTool::WORKSPACE, saverc_cmd)); + + menu.insert(new ToolbarModeMenuItem( + _FBTEXT(Toolbar, IconbarModeAllWindows, "All Windows", "All windows are shown"), + handler, + IconbarTool::ALLWINDOWS, saverc_cmd)); + menu.insert("---"); // separator line - menu.insert(new ToolbarAlignMenuItem("Left", handler, - Container::LEFT, saverc_cmd)); - menu.insert(new ToolbarAlignMenuItem("Relative", handler, - Container::RELATIVE, saverc_cmd)); - menu.insert(new ToolbarAlignMenuItem("Right", handler, - Container::RIGHT, saverc_cmd)); + + menu.insert(new ToolbarAlignMenuItem( + _FBTEXT(Align, Left, "Left", "Align to the left"), + handler, + Container::LEFT, saverc_cmd)); + + menu.insert(new ToolbarAlignMenuItem( + _FBTEXT(Align, Relative, "Relative", "Align relative to the width"), + handler, + Container::RELATIVE, saverc_cmd)); + + menu.insert(new ToolbarAlignMenuItem( + _FBTEXT(Align, Right, "Right", "Align to the right"), + handler, + Container::RIGHT, saverc_cmd)); + menu.insert("---"); // separator line menu.update(); } diff --git a/src/Keys.cc b/src/Keys.cc index 41af901..aef2b8f 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Keys.cc,v 1.42 2004/02/20 09:29:07 fluxgen Exp $ +//$Id: Keys.cc,v 1.43 2004/06/07 11:46:04 rathnor Exp $ #include "Keys.hh" @@ -30,6 +30,7 @@ #include "FbTk/KeyUtil.hh" #include "CommandParser.hh" +#include "FbTk/I18n.hh" #ifdef HAVE_CONFIG_H #include "config.h" @@ -165,6 +166,7 @@ bool Keys::addBinding(const std::string &linebuffer) { char keyarg = 0; t_key *current_key=0, *last_key=0; + _FB_USES_NLS; // for each argument for (unsigned int argc=0; argc "< "<m_command = CommandParser::instance().parseLine(str); if (*last_key->m_command == 0) { - cerr<<"Keys: Error on line: "< "<> defaults.hh echo '#define LOCALEPATH "$(pkgdatadir)/nls"' >> defaults.hh -# some extra deps for I18n and fluxbox +# an extra dep for fluxbox -I18n.$(OBJEXT): defaults.hh fluxbox.$(OBJEXT): defaults.hh if NEWWMSPEC @@ -78,7 +77,6 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ FbAtoms.hh FbAtoms.cc FbWinFrame.hh FbWinFrame.cc \ FbWinFrameTheme.hh FbWinFrameTheme.cc \ fluxbox.cc fluxbox.hh \ - I18n.cc I18n.hh \ Keys.cc Keys.hh main.cc \ Netizen.cc Netizen.hh \ RootTheme.hh RootTheme.cc \ diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 970b799..90a4386 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuCreator.cc,v 1.5 2004/05/03 21:37:01 fluxgen Exp $ +// $Id: MenuCreator.cc,v 1.6 2004/06/07 11:46:04 rathnor Exp $ #include "MenuCreator.hh" @@ -29,7 +29,6 @@ #include "fluxbox.hh" #include "CommandParser.hh" #include "Window.hh" -#include "I18n.hh" #include "FbMenu.hh" #include "IconMenu.hh" @@ -40,6 +39,7 @@ #include "FbMenuParser.hh" #include "StyleMenuItem.hh" +#include "FbTk/I18n.hh" #include "FbTk/MultiButtonMenuItem.hh" #include "FbTk/RefCount.hh" #include "FbTk/MacroCommand.hh" @@ -119,10 +119,7 @@ static void translateMenuItem(Parser &parse, FbTk::Menu &menu) { const int screen_number = menu.screenNumber(); - static I18n &i18n = *I18n::instance(); - using namespace FBNLS; - -#define SCREENNLS(a, b) i18n.getMessage(ScreenSet, a, b) + _FB_USES_NLS; if (str_key == "end") { return; @@ -133,13 +130,13 @@ static void translateMenuItem(Parser &parse, if (submenu == 0) return; if (str_label.empty()) - menu.insert(i18n.getMessage(IconSet, IconIcons, "Icons")); + menu.insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title")); else menu.insert(str_label.c_str(), submenu); } else if (str_key == "exit") { // exit FbTk::RefCount exit_cmd(CommandParser::instance().parseLine("exit")); if (str_label.empty()) - menu.insert(SCREENNLS(ScreenExit, "Exit"), exit_cmd); + menu.insert(_FBTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); else menu.insert(str_label.c_str(), exit_cmd); } else if (str_key == "exec") { @@ -191,18 +188,18 @@ static void translateMenuItem(Parser &parse, FbTk::RefCount restart_fb(CommandParser::instance(). parseLine("restart")); if (str_label.empty()) - menu.insert(SCREENNLS(ScreenRestart, "Restart"), restart_fb); + menu.insert(_FBTEXT(Menu, Restart, "Restart", "Restart Command"), restart_fb); else menu.insert(str_label.c_str(), restart_fb); } // end of restart else if (str_key == "reconfig") { // reconf - // - //!! TODO: NLS - // FbTk::RefCount reconfig_fb_cmd(CommandParser::instance(). parseLine("reconfigure")); - menu.insert(str_label.c_str(), reconfig_fb_cmd); + if (str_label.empty()) + menu.insert(_FBTEXT(Menu, Reconfigure, "Reload Config", "Reload all the configs"), reconfig_fb_cmd); + else + menu.insert(str_label.c_str(), reconfig_fb_cmd); } else if (str_key == "stylesdir" || str_key == "stylesmenu") { createStyleMenu(menu, str_label, @@ -223,8 +220,6 @@ static void translateMenuItem(Parser &parse, if (*command != 0) menu.insert(str_label.c_str(), command); } -#undef SCREENNLS - } @@ -347,23 +342,18 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, const std::string &label, FbTk::Menu &menu, FluxboxWindow &win) { - static I18n &i18n = *I18n::instance(); typedef FbTk::RefCount RefCmd; typedef FbTk::SimpleCommand WindowCmd; - using namespace FBNLS; - -#define WINDOWNLS(a, b) std::string real_label = label; if (label.empty()) real_label = i18n.getMessage(FBNLS::WindowmenuSet, a, b) + _FB_USES_NLS; if (type == "shade") { - WINDOWNLS(WindowmenuShade, "Shade"); RefCmd shade_cmd(new WindowCmd(win, &FluxboxWindow::shade)); - menu.insert(real_label.c_str(), shade_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label.c_str(), shade_cmd); } else if (type == "maximize") { - WINDOWNLS(WindowmenuMaximize, "Maximize"); RefCmd maximize_cmd(new WindowCmd(win, &FluxboxWindow::maximizeFull)); RefCmd maximize_vert_cmd(new WindowCmd(win, &FluxboxWindow::maximizeVertical)); RefCmd maximize_horiz_cmd(new WindowCmd(win, &FluxboxWindow::maximizeHorizontal)); - FbTk::MultiButtonMenuItem *maximize_item = new FbTk::MultiButtonMenuItem(3, real_label.c_str()); + FbTk::MultiButtonMenuItem *maximize_item = new FbTk::MultiButtonMenuItem(3, label.empty()?_FBTEXT(Windowmenu, Maximize, "Maximize", "Maximize the window"):label.c_str()); // create maximize item with: // button1: Maximize normal // button2: Maximize Vertical @@ -373,25 +363,20 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, maximize_item->setCommand(3, maximize_horiz_cmd); menu.insert(maximize_item); } else if (type == "iconify") { - WINDOWNLS(WindowmenuIconify, "Iconify"); RefCmd iconify_cmd(new WindowCmd(win, &FluxboxWindow::iconify)); - menu.insert(real_label.c_str(), iconify_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Iconify, "Iconify", "Iconify the window"):label.c_str(), iconify_cmd); } else if (type == "close") { - WINDOWNLS(WindowmenuClose, "Close"); RefCmd close_cmd(new WindowCmd(win, &FluxboxWindow::close)); - menu.insert(real_label.c_str(), close_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Close, "Close", "Close the window"):label.c_str(), close_cmd); } else if (type == "lower") { - WINDOWNLS(WindowmenuLower, "Lower"); RefCmd lower_cmd(new WindowCmd(win, &FluxboxWindow::lower)); - menu.insert(real_label.c_str(), lower_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Lower, "Lower", "Lower the window"):label.c_str(), lower_cmd); } else if (type == "raise") { - WINDOWNLS(WindowmenuRaise, "Raise"); RefCmd raise_cmd(new WindowCmd(win, &FluxboxWindow::raise)); - menu.insert(real_label.c_str(), raise_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Raise, "Raise", "Raise the window"):label.c_str(), raise_cmd); } else if (type == "stick") { - WINDOWNLS(WindowmenuStick, "Stick"); RefCmd stick_cmd(new WindowCmd(win, &FluxboxWindow::stick)); - menu.insert(real_label.c_str(), stick_cmd); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Stick, "Stick", "Stick the window"):label.c_str(), stick_cmd); } else if (type == "extramenus") { FluxboxWindow::ExtraMenus::iterator it = win.extraMenus().begin(); FluxboxWindow::ExtraMenus::iterator it_end = win.extraMenus().end(); @@ -401,10 +386,8 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, } } else if (type == "sendto") { - WINDOWNLS(WindowmenuSendTo, "Send To ..."); - menu.insert(real_label.c_str(), new SendToMenu(win)); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label.c_str(), new SendToMenu(win)); } else if (type == "layer") { - WINDOWNLS(WindowmenuLayer, "Layer ..."); BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); if (screen == 0) return false; @@ -415,14 +398,13 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, &win, false); submenu->disableTitle(); - menu.insert(real_label.c_str(), submenu); + menu.insert(label.empty()?_FBTEXT(Windowmenu, Layer, "Layer ...", "Layer menu"):label.c_str(), submenu); } else if (type == "separator") { menu.insert("---"); } else return false; -#undef WINDOWNLS return true; } diff --git a/src/RegExp.cc b/src/RegExp.cc index 093c53f..1a47d04 100644 --- a/src/RegExp.cc +++ b/src/RegExp.cc @@ -20,9 +20,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: RegExp.cc,v 1.2 2003/06/13 11:43:46 fluxgen Exp $ +// $Id: RegExp.cc,v 1.3 2004/06/07 11:46:04 rathnor Exp $ #include "RegExp.hh" +#include "FbTk/I18n.hh" //use GNU extensions #ifndef _GNU_SOURCE @@ -37,7 +38,7 @@ using namespace std; /******************************************************** * RegExp * - ***********/ + **********/ // full_match is to say if we match on this regexp using the full string // or just a substring. Substrings aren't supported if not HAVE_REGEXP @@ -57,12 +58,13 @@ m_regex(0) { int ret = regcomp(m_regex, match.c_str(), REG_NOSUB | REG_EXTENDED); if (ret != 0) { char *errstr = 0; + _FB_USES_NLS; // gives us the length of the string unsigned int size = regerror(ret, m_regex, errstr, 0); errstr = new char[size]; regerror(ret, m_regex, errstr, size); - cerr<<"Error parsing regular expression: "<insert(new RememberMenuItem("Workspace", remember, win, - Remember::REM_WORKSPACE)); - menu->insert(new RememberMenuItem("Jump to workspace", remember, win, - Remember::REM_JUMPWORKSPACE)); - menu->insert(new RememberMenuItem("Dimensions", remember, win, - Remember::REM_DIMENSIONS)); - menu->insert(new RememberMenuItem("Position", remember, win, - Remember::REM_POSITION)); - menu->insert(new RememberMenuItem("Sticky", remember, win, - Remember::REM_STUCKSTATE)); - menu->insert(new RememberMenuItem("Decorations", remember, win, - Remember::REM_DECOSTATE)); - menu->insert(new RememberMenuItem("Shaded", remember, win, - Remember::REM_SHADEDSTATE)); - menu->insert(new RememberMenuItem("Layer", remember, win, - Remember::REM_LAYER)); - menu->insert(new RememberMenuItem("Save on close", remember, win, - Remember::REM_SAVEONCLOSE)); + _FB_USES_NLS; + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Workspace, "Workspace", "Remember Workspace"), + remember, win, Remember::REM_WORKSPACE)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, JumpToWorkspace, "Jump to workspace", "Change active workspace to remembered one on open"), + remember, win, Remember::REM_JUMPWORKSPACE)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Dimensions, "Dimensions", "Remember Dimensions - windth width and height"), + remember, win, Remember::REM_DIMENSIONS)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Position, "Position", "Remember position - window co-ordinates"), + remember, win, Remember::REM_POSITION)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Sticky, "Sticky", "Remember Sticky"), + remember, win, Remember::REM_STUCKSTATE)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Decorations, "Decorations", "Remember window decorations"), + remember, win, Remember::REM_DECOSTATE)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Shaded, "Shaded", "Remember shaded"), + remember, win, Remember::REM_SHADEDSTATE)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, Layer, "Layer", "Remember Layer"), + remember, win, Remember::REM_LAYER)); + menu->insert(new RememberMenuItem(_FBTEXT(Remember, SaveOnClose, "Save on close", "Save remembered attributes on close"), + remember, win, Remember::REM_SAVEONCLOSE)); menu->update(); return menu; @@ -284,6 +285,7 @@ Application * Remember::add(WinClient &winclient) { int Remember::parseApp(ifstream &file, Application &app, string *first_line) { string line; + _FB_USES_NLS; int row = 0; while (! file.eof()) { if (first_line || getline(file, line)) { @@ -415,7 +417,7 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { } else if (str_key == "end") { return row; } else { - cerr << "Unsupported apps key = " << str_key << endl; + cerr << _FBTEXT(Remember, Unknown, "Unknown apps key", "apps entry type not known")<<" = " << str_key << endl; } } } @@ -758,13 +760,13 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) { void Remember::setupFrame(FluxboxWindow &win) { WinClient &winclient = win.winClient(); - + _FB_USES_NLS; // we don't touch the window if it is a transient // of something else // All windows get the remember menu. - // TODO: nls - win.addExtraMenu("Remember...", createRememberMenu(*this, win, (winclient.transientFor() == 0))); + win.addExtraMenu(_FBTEXT(Remember, MenuItemName, "Remember...", "Remember item in menu"), + createRememberMenu(*this, win, (winclient.transientFor() == 0))); if (winclient.transientFor()) return; diff --git a/src/Screen.cc b/src/Screen.cc index 3497f7d..3fce3a6 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,12 +22,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.278 2004/05/13 01:48:17 rathnor Exp $ +// $Id: Screen.cc,v 1.279 2004/06/07 11:46:04 rathnor Exp $ #include "Screen.hh" -#include "I18n.hh" #include "fluxbox.hh" #include "Window.hh" #include "Workspace.hh" @@ -58,6 +57,7 @@ #include "AtomHandler.hh" +#include "FbTk/I18n.hh" #include "FbTk/Subject.hh" #include "FbTk/FbWindow.hh" #include "FbTk/SimpleCommand.hh" @@ -135,10 +135,12 @@ static bool running = true; namespace { int anotherWMRunning(Display *display, XErrorEvent *) { - cerr< - getMessage(FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning, - "BScreen::BScreen: an error occured while querying the X server.\n" - " another window manager already running on display ")<getMessage(FBNLS::ScreenSet, FBNLS::ScreenManagingScreen, - "BScreen::BScreen: managing screen %d " - "using visual 0x%lx, depth %d\n"), + fprintf(stderr, _FBTEXT(Screen, ManagingScreen, + "BScreen::BScreen: managing screen %d " + "using visual 0x%lx, depth %d\n", + "informational message saying screen number (%d), visual (%lx), and colour depth (%d)"), screenNumber(), XVisualIDFromVisual(rootWindow().visual()), rootWindow().depth()); @@ -362,8 +365,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, // own resources we must do this. fluxbox->load_rc(*this); - // TODO: nls - m_configmenu.reset(createMenu("Configuration")); + m_configmenu.reset(createMenu(_FBTEXT(Menu, Configuration, "Configuration", "Title of configuration menu"))); setupConfigmenu(*m_configmenu.get()); m_configmenu->setInternalMenu(); @@ -1646,7 +1648,6 @@ void BScreen::initMenus() { } void BScreen::initMenu() { - I18n *i18n = I18n::instance(); if (m_rootmenu.get()) { // since all menus in root is submenus in m_rootmenu @@ -1668,19 +1669,17 @@ void BScreen::initMenu() { if (m_rootmenu.get() == 0) { - m_rootmenu.reset(createMenu("Fluxbox default menu")); + _FB_USES_NLS; + m_rootmenu.reset(createMenu(_FBTEXT(Menu, DefaultRootMenu, "Fluxbox default menu", "Title of fallback root menu"))); FbTk::RefCount restart_fb(CommandParser::instance().parseLine("restart")); FbTk::RefCount exit_fb(CommandParser::instance().parseLine("exit")); FbTk::RefCount execute_xterm(CommandParser::instance().parseLine("exec xterm")); m_rootmenu->setInternalMenu(); - m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::Screenxterm, - "xterm"), + m_rootmenu->insert(_FBTEXT(Menu, xterm, "xterm", "xterm - in fallback menu"), execute_xterm); - m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenRestart, - "Restart"), + m_rootmenu->insert(_FBTEXT(Menu, Restart, "Restart", "Restart command"), restart_fb); - m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenExit, - "Exit"), + m_rootmenu->insert(_FBTEXT(Menu, Exit, "Exit", "Exit command"), exit_fb); } @@ -1705,8 +1704,7 @@ void BScreen::removeConfigMenu(FbTk::Menu &menu) { } void BScreen::setupConfigmenu(FbTk::Menu &menu) { - I18n *i18n = I18n::instance(); - using namespace FBNLS; + _FB_USES_NLS; menu.removeAll(); @@ -1720,26 +1718,27 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { // create focus menu // we don't set this to internal menu so will // be deleted toghether with the parent - const char *focusmenu_label = i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel, - "Focus Model"); + const char *focusmenu_label = _FBTEXT(Configmenu, FocusModel, + "Focus Model", "Method used to give focus to windows"); FbTk::Menu *focus_menu = createMenu(focusmenu_label ? focusmenu_label : ""); -#define _FOCUSITEM(a, b, c, d) focus_menu->insert(new FocusModelMenuItem(i18n->getMessage(a, b, c), *this, d, save_and_reconfigure)) +#define _FOCUSITEM(a, b, c, d, e) focus_menu->insert(new FocusModelMenuItem(_FBTEXT(a, b, c, d), *this, e, save_and_reconfigure)) - _FOCUSITEM(ConfigmenuSet, ConfigmenuClickToFocus, - "Click To Focus", + _FOCUSITEM(Configmenu, ClickToFocus, + "Click To Focus", "Click to focus", CLICKTOFOCUS); - _FOCUSITEM(ConfigmenuSet, ConfigmenuSloppyFocus, - "Sloppy Focus", + _FOCUSITEM(Configmenu, SloppyFocus, + "Sloppy Focus", "Sloppy Focus", SLOPPYFOCUS); - _FOCUSITEM(ConfigmenuSet, ConfigmenuSemiSloppyFocus, - "Semi Sloppy Focus", + _FOCUSITEM(Configmenu, SemiSloppyFocus, + "Semi Sloppy Focus", "Semi Sloppy Focus", SEMISLOPPYFOCUS); #undef _FOCUSITEM - focus_menu->insert(new BoolMenuItem(i18n->getMessage(ConfigmenuSet, - ConfigmenuAutoRaise, - "Auto Raise"), + focus_menu->insert(new BoolMenuItem(_FBTEXT(Configmenu, + AutoRaise, + "Auto Raise", + "Auto Raise windows on sloppy"), *resource.auto_raise, save_and_reconfigure)); @@ -1758,38 +1757,38 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { for (; it != it_end; ++it) menu.insert(it->first, it->second); -#define _BOOLITEM(a, b, c, d, e) menu.insert(new BoolMenuItem(i18n->getMessage(a, b, c), d, e)) +#define _BOOLITEM(a, b, c, d, e, f) menu.insert(new BoolMenuItem(_FBTEXT(a, b, c, d), e, f)) - _BOOLITEM(ConfigmenuSet, ConfigmenuImageDithering, - "Image Dithering", + _BOOLITEM(Configmenu, ImageDithering, + "Image Dithering", "Image Dithering", *resource.image_dither, save_and_reconfigure); - _BOOLITEM(ConfigmenuSet, ConfigmenuOpaqueMove, - "Opaque Window Moving", + _BOOLITEM(Configmenu, OpaqueMove, + "Opaque Window Moving", "Window Moving with whole window visible (as opposed to outline moving)", *resource.opaque_move, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuFullMax, - "Full Maximization", + _BOOLITEM(Configmenu, FullMax, + "Full Maximization", "Maximise over slit, toolbar, etc", *resource.full_max, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuFocusNew, - "Focus New Windows", + _BOOLITEM(Configmenu, FocusNew, + "Focus New Windows", "Focus newly created windows", *resource.focus_new, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuFocusLast, - "Focus Last Window on Workspace", + _BOOLITEM(Configmenu, FocusLast, + "Focus Last Window on Workspace", "Focus Last Window on Workspace", *resource.focus_last, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuWorkspaceWarping, - "Workspace Warping", + _BOOLITEM(Configmenu, WorkspaceWarping, + "Workspace Warping", "Workspace Warping - dragging windows to the edge and onto the next workspace", *resource.workspace_warping, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuDesktopWheeling, - "Desktop MouseWheel Switching", + _BOOLITEM(Configmenu, DesktopWheeling, + "Desktop MouseWheel Switching", "Workspace switching using mouse wheel", *resource.desktop_wheeling, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuDecorateTransient, - "Decorate Transient Windows", + _BOOLITEM(Configmenu, DecorateTransient, + "Decorate Transient Windows", "Decorate Transient Windows", *resource.decorate_transient, saverc_cmd); - _BOOLITEM(ConfigmenuSet, ConfigmenuClickRaises, - "Click Raises", + _BOOLITEM(Configmenu, ClickRaises, + "Click Raises", "Click Raises", *resource.click_raises, saverc_cmd); // setup antialias cmd to reload style and save resource on toggle - _BOOLITEM(ConfigmenuSet, ConfigmenuAntiAlias, - "AntiAlias", + _BOOLITEM(Configmenu, AntiAlias, + "AntiAlias", "Use Anti-aliased fonts", *resource.antialias, save_and_reconfigure); #undef _BOOLITEM @@ -1819,7 +1818,7 @@ void BScreen::shutdown() { void BScreen::showPosition(int x, int y) { - if (!doShowWindowPos()) + if (!doShowWindowPos()) return; if (! pos_visible) { @@ -1839,10 +1838,13 @@ void BScreen::showPosition(int x, int y) { pos_visible = true; } char label[256]; - + + _FB_USES_NLS; + sprintf(label, - I18n::instance()->getMessage(FBNLS::ScreenSet, FBNLS::ScreenPositionFormat, - "X: %4d x Y: %4d"), x, y); + _FBTEXT(Screen, PositionFormat, + "X: %4d x Y: %4d", + "Format for screen coordinates - %4d for X, and %4d for Y"), x, y); m_pos_window.clear(); @@ -1886,10 +1888,13 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { } char label[256]; + _FB_USES_NLS; sprintf(label, - I18n::instance()->getMessage(FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat, - "W: %4d x H: %4d"), gx, gy); + _FBTEXT(Screen, GeometryFormat, + "W: %4d x H: %4d", + "Format for width and height window, %4d for widht, and %4d for height"), + gx, gy); m_geom_window.clear(); @@ -1961,10 +1966,12 @@ bool BScreen::doSkipWindow(const WinClient &winclient, int opts) { } void BScreen::renderGeomWindow() { + _FB_USES_NLS; - const char *s = I18n::instance()->getMessage(FBNLS::ScreenSet, - FBNLS::ScreenGeometryLength, - "W: 0000 x H: 0000"); + const char *s = _FBTEXT(Screen, + GeometryLength, + "W: 0000 x H: 0000", + "Representative maximum sized text for width and height dialog"); int l = strlen(s); int geom_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2; @@ -2004,10 +2011,12 @@ void BScreen::renderGeomWindow() { void BScreen::renderPosWindow() { + _FB_USES_NLS; - const char *s = I18n::instance()->getMessage(FBNLS::ScreenSet, - FBNLS::ScreenPositionLength, - "0: 0000 x 0: 0000"); + const char *s = _FBTEXT(Screen, + PositionLength, + "0: 0000 x 0: 0000", + "Representative maximum sized text for X and Y dialog"); int l = strlen(s); int pos_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2; diff --git a/src/Slit.cc b/src/Slit.cc index c5a74a4..4157178 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.94 2004/05/17 15:20:32 rathnor Exp $ +// $Id: Slit.cc,v 1.95 2004/06/07 11:46:04 rathnor Exp $ #include "Slit.hh" @@ -35,7 +35,6 @@ #include "config.h" #endif // HAVE_CONFIG_H -#include "I18n.hh" #include "Screen.hh" #include "ImageControl.hh" #include "RefCount.hh" @@ -58,6 +57,7 @@ #include "Xutil.hh" #include "FbAtoms.hh" #include "FbTk/StringUtil.hh" +#include "FbTk/I18n.hh" #include #include @@ -79,8 +79,9 @@ template<> void FbTk::Resource::setFromString(const char *strval) { if (strcasecmp(strval, "TopLeft")==0) m_value = Slit::TOPLEFT; - else if (strcasecmp(strval, "CenterLeft")==0) - m_value = Slit::CENTERLEFT; + else if (strcasecmp(strval, "LeftCenter")==0 + || strcasecmp(strval, "CenterLeft")==0) + m_value = Slit::LEFTCENTER; else if (strcasecmp(strval, "BottomLeft")==0) m_value = Slit::BOTTOMLEFT; else if (strcasecmp(strval, "TopCenter")==0) @@ -89,8 +90,9 @@ void FbTk::Resource::setFromString(const char *strval) { m_value = Slit::BOTTOMCENTER; else if (strcasecmp(strval, "TopRight")==0) m_value = Slit::TOPRIGHT; - else if (strcasecmp(strval, "CenterRight")==0) - m_value = Slit::CENTERRIGHT; + else if (strcasecmp(strval, "RightCenter")==0 + || strcasecmp(strval, "CenterRight")==0) + m_value = Slit::RIGHTCENTER; else if (strcasecmp(strval, "BottomRight")==0) m_value = Slit::BOTTOMRIGHT; else @@ -113,8 +115,8 @@ string FbTk::Resource::getString() { case Slit::TOPLEFT: return string("TopLeft"); break; - case Slit::CENTERLEFT: - return string("CenterLeft"); + case Slit::LEFTCENTER: + return string("LeftCenter"); break; case Slit::BOTTOMLEFT: return string("BottomLeft"); @@ -128,8 +130,8 @@ string FbTk::Resource::getString() { case Slit::TOPRIGHT: return string("TopRight"); break; - case Slit::CENTERRIGHT: - return string("CenterRight"); + case Slit::RIGHTCENTER: + return string("RightCenter"); break; case Slit::BOTTOMRIGHT: return string("BottomRight"); @@ -198,14 +200,13 @@ public: } void setLabel(const char *label) { - I18n *i18n = I18n::instance(); + _FB_USES_NLS; m_label = (label ? label : ""); std::string reallabel = m_label + " " + ( m_slit.direction() == Slit::HORIZONTAL ? - i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionHoriz, - "Horizontal") : - i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionVert, - "Vertical") ); + + _FBTEXT(Align, Horizontal, "Horizontal", "Horizontal"): + _FBTEXT(Align, Vertical, "Vertical", "Vertical")); FbTk::MenuItem::setLabel(reallabel.c_str()); } private: @@ -278,6 +279,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) m_rc_layernum(scr.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDockLayer()), scr.name() + ".slit.layer", scr.altName() + ".Slit.Layer") { + _FB_USES_NLS; + // attach to theme and root window change signal m_slit_theme->reconfigSig().attach(this); scr.resizeSig().attach(this); @@ -315,9 +318,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer)); moveToLayer((*m_rc_layernum).getNum()); - // TODO: nls if (m_layermenu.get()) - m_layermenu->setLabel("Slit Layer"); + m_layermenu->setLabel(_FBTEXT(Slit, Layer, "Slit Layer", "Title of Slit Layer Menu")); // Get client list for sorting purposes loadClientList(filename); @@ -391,11 +393,11 @@ void Slit::updateStrut() { else right = width(); break; - case CENTERLEFT: + case LEFTCENTER: if (direction() == VERTICAL) left = width(); break; - case CENTERRIGHT: + case RIGHTCENTER: if (direction() == VERTICAL) right = width(); break; @@ -804,7 +806,7 @@ void Slit::reposition() { } break; - case CENTERLEFT: + case LEFTCENTER: frame.x = head_x; frame.y = head_y + (head_h - frame.height) / 2; frame.x_hidden = head_x + bevel_width - @@ -856,7 +858,7 @@ void Slit::reposition() { } break; - case CENTERRIGHT: + case RIGHTCENTER: default: frame.x = head_x + head_w - frame.width - border_width*2; frame.y = head_y + ((head_h - frame.height) / 2); @@ -1096,15 +1098,16 @@ void Slit::loadClientList(const char *filename) { void Slit::updateClientmenu() { if (screen().isShuttingdown()) return; + _FB_USES_NLS; // clear old items m_clientlist_menu.removeAll(); - m_clientlist_menu.setLabel("Clients"); + m_clientlist_menu.setLabel(_FBTEXT(Slit, ClientsMenu, "Clients", "Slit client menu")); FbTk::RefCount cycle_up(new FbTk::SimpleCommand(*this, &Slit::cycleClientsUp)); FbTk::RefCount cycle_down(new FbTk::SimpleCommand(*this, &Slit::cycleClientsDown)); - m_clientlist_menu.insert("Cycle Up", cycle_up); - m_clientlist_menu.insert("Cycle Down", cycle_down); + m_clientlist_menu.insert(_FBTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up); + m_clientlist_menu.insert(_FBTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down); FbTk::MenuItem *separator = new FbTk::MenuItem("---"); separator->setEnabled(false); @@ -1148,8 +1151,7 @@ void Slit::setAutoHide(bool val) { } void Slit::setupMenu() { - I18n *i18n = I18n::instance(); - using namespace FBNLS; + _FB_USES_NLS; using namespace FbTk; FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); @@ -1168,40 +1170,39 @@ void Slit::setupMenu() { FbTk::RefCount save_and_reconfigure_slit(s_a_reconf_slit_macro); // setup base menu - m_slitmenu.setLabel("Slit"); - m_slitmenu.insert(i18n->getMessage(CommonSet, CommonPlacementTitle, - "Placement"), + m_slitmenu.setLabel(_FBTEXT(Slit, Slit, "Slit", "The Slit")); + m_slitmenu.insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &m_placement_menu); - m_slitmenu.insert("Layer...", m_layermenu.get()); + m_slitmenu.insert(_FBTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), m_layermenu.get()); #ifdef XINERAMA if (screen().hasXinerama()) { - // TODO: nls (main label, plus menu heading) - m_slitmenu.insert("On Head...", new XineramaHeadMenu( - screen().menuTheme(), - screen(), - screen().imageControl(), - *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), - *this, - "Slit on Head" - )); + m_slitmenu.insert(_FBTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"), + new XineramaHeadMenu( + screen().menuTheme(), + screen(), + screen().imageControl(), + *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + *this, + _FBTEXT(Slit, OnHead, "Slit on Head", "Title of Slits On Head menu") + )); } #endif //XINERAMA - m_slitmenu.insert(new BoolMenuItem(i18n->getMessage(CommonSet, CommonAutoHide, - "Auto hide"), + m_slitmenu.insert(new BoolMenuItem(_FBTEXT(Common, AutoHide, "Auto hide", "This thing automatically hides when not close by"), *m_rc_auto_hide, save_and_reconfigure_slit)); - m_slitmenu.insert(new BoolMenuItem("Maximize Over", + m_slitmenu.insert(new BoolMenuItem(_FBTEXT(Common, MaximizeOver,"Maximize Over", "Maximize over this thing when maximizing"), *m_rc_maximize_over, save_and_reconfigure_slit)); // this saves resources and clears the slit window to update alpha value - FbTk::MenuItem *alpha_menuitem = new IntResMenuItem("Alpha", - m_rc_alpha, - 0, 255); + FbTk::MenuItem *alpha_menuitem = + new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), + m_rc_alpha, + 0, 255); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); RefCount clear_cmd(new SimpleCommand(*this, &Slit::clearWindow)); @@ -1212,51 +1213,50 @@ void Slit::setupMenu() { m_slitmenu.insert(alpha_menuitem); - m_slitmenu.insert(new SlitDirMenuItem(i18n->getMessage(SlitSet, SlitSlitDirection, - "Slit Direction"), + m_slitmenu.insert(new SlitDirMenuItem(_FBTEXT(Slit, Direction, "Slit Direction", "Orientation of slit"), *this, save_and_reconfigure)); - m_slitmenu.insert("Clients", &m_clientlist_menu); + m_slitmenu.insert(_FBTEXT(Slit, ClientsMenu, "Clients", "Slit client menu"), &m_clientlist_menu); m_slitmenu.update(); // setup sub menu - m_placement_menu.setLabel(i18n->getMessage(SlitSet, SlitSlitPlacement, - "Slit Placement")); + m_placement_menu.setLabel(_FBTEXT(Slit, Placement, "Slit Placement", "Slit Placement")); m_placement_menu.setMinimumSublevels(3); m_layermenu->setInternalMenu(); m_clientlist_menu.setInternalMenu(); + typedef list > Placements; + Placements place_menu; + + // menu is 3 wide, 5 down + place_menu.push_back(make_pair(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), Slit::TOPLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, LeftCenter, "Left Center", "Left Center"), Slit::LEFTCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Slit::BOTTOMLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, TopCenter, "Top Center", "Top Center"), Slit::TOPCENTER)); + place_menu.push_back(make_pair((const char *)0, Slit::TOPLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Slit::BOTTOMCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), Slit::TOPRIGHT)); + place_menu.push_back(make_pair(_FBTEXT(Align, RightCenter, "Right Center", "Right Center"), Slit::RIGHTCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Slit::BOTTOMRIGHT)); + - // setup items in sub menu - struct { - int set; - int base; - const char *default_str; - Placement slit_placement; - } place_menu[] = { - {CommonSet, CommonPlacementTopLeft, "Top Left", Slit::TOPLEFT}, - {CommonSet, CommonPlacementCenterLeft, "Center Left", Slit::CENTERLEFT}, - {CommonSet, CommonPlacementBottomLeft, "Bottom Left", Slit::BOTTOMLEFT}, - {CommonSet, CommonPlacementTopCenter, "Top Center", Slit::TOPCENTER}, - {0, 0, 0, Slit::TOPLEFT}, // middle item, empty - {CommonSet, CommonPlacementBottomCenter, "Bottom Center", Slit::BOTTOMCENTER}, - {CommonSet, CommonPlacementTopRight, "Top Right", Slit::TOPRIGHT}, - {CommonSet, CommonPlacementCenterRight, "Center Right", Slit::CENTERRIGHT}, - {CommonSet, CommonPlacementBottomRight, "Bottom Right", Slit::BOTTOMRIGHT} - }; // create items in sub menu for (size_t i=0; i<9; ++i) { - if (place_menu[i].default_str == 0) { + const char *str = place_menu.front().first; + Slit::Placement placement = place_menu.front().second; + + if (str == 0) { m_placement_menu.insert(""); + m_placement_menu.setItemEnabled(i, false); } else { - const char *i18n_str = i18n->getMessage(place_menu[i].set, - place_menu[i].base, - place_menu[i].default_str); - m_placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this, - place_menu[i].slit_placement, + m_placement_menu.insert(new PlaceSlitMenuItem(str, *this, + placement, save_and_reconfigure)); + } + place_menu.pop_front(); } + // finaly update sub menu m_placement_menu.update(); } diff --git a/src/Slit.hh b/src/Slit.hh index 83d0fae..eea3ad2 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.40 2004/05/17 15:20:32 rathnor Exp $ +/// $Id: Slit.hh,v 1.41 2004/06/07 11:46:04 rathnor Exp $ #ifndef SLIT_HH #define SLIT_HH @@ -57,8 +57,8 @@ public: /** Placement on screen */ - enum Placement { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, - TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; + enum Placement { TOPLEFT = 1, LEFTCENTER, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, + TOPRIGHT, RIGHTCENTER, BOTTOMRIGHT }; Slit(BScreen &screen, FbTk::XLayer &layer, const char *filename = 0); virtual ~Slit(); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 15efb99..5d74b3c 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.139 2004/04/26 15:04:37 rathnor Exp $ +// $Id: Toolbar.cc,v 1.140 2004/06/07 11:46:04 rathnor Exp $ #include "Toolbar.hh" @@ -32,7 +32,7 @@ // themes #include "ToolbarTheme.hh" -#include "I18n.hh" +#include "FbTk/I18n.hh" #include "fluxbox.hh" #include "Screen.hh" #include "IntResMenuItem.hh" @@ -225,7 +225,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): scrn.name() + ".toolbar.tools", scrn.altName() + ".Toolbar.Tools"), m_shape(new Shape(frame.window, 0)), m_resize_lock(false) { - + _FB_USES_NLS; // we need to get notified when the theme is reloaded m_theme.reconfigSig().attach(this); // listen to screen size changes @@ -234,15 +234,14 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): moveToLayer((*m_rc_layernum).getNum()); - // TODO: nls - m_layermenu.setLabel("Toolbar Layer"); - m_placementmenu.setLabel("Toolbar Placement"); + m_layermenu.setLabel(_FBTEXT(Toolbar, Layer, "Toolbar Layer", "Title of toolbar layer menu")); + m_placementmenu.setLabel(_FBTEXT(Toolbar, Placement, "Toolbar Placement", "Title of toolbar placement menu")); m_layermenu.setInternalMenu(); m_placementmenu.setInternalMenu(); setupMenus(); // add menu to screen - screen().addConfigMenu("Toolbar", menu()); + screen().addConfigMenu(_FBTEXT(Toolbar, Toolbar, "Toolbar", "title of toolbar menu item"), menu()); // geometry settings frame.width = width; @@ -751,8 +750,7 @@ void Toolbar::moveToLayer(int layernum) { } void Toolbar::setupMenus() { - const I18n &i18n = *I18n::instance(); - using namespace FBNLS; + _FB_USES_NLS; using namespace FbTk; typedef RefCount RefCommand; @@ -762,14 +760,14 @@ void Toolbar::setupMenus() { RefCommand start_edit(CommandParser::instance().parseLine("setworkspacenamedialog")); - menu().insert(i18n.getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarEditWkspcName, - "Edit current workspace name"), + menu().insert(_FBTEXT(Toolbar, EditWkspcName, + "Edit current workspace name", "Edit current workspace name"), start_edit); - menu().setLabel(i18n.getMessage(FBNLS::ToolbarSet, FBNLS::ToolbarToolbarTitle, - "Toolbar")); + menu().setLabel(_FBTEXT(Toolbar, ToolbarTitle, + "Toolbar", "Title of Toolbar menu")); - MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", + MenuItem *toolbar_menuitem = new IntResMenuItem(_FBTEXT(Toolbar, WidthPercent, "Toolbar width percent", "Percentage of screen width taken by toolbar"), m_rc_width_percent, 0, 100); // min/max value @@ -785,8 +783,8 @@ void Toolbar::setupMenus() { menu().insert(toolbar_menuitem); - menu().insert(new BoolMenuItem(i18n.getMessage(FBNLS::CommonSet, FBNLS::CommonAutoHide, - "Auto hide"), + menu().insert(new BoolMenuItem(_FBTEXT(Common, AutoHide, + "Auto hide", "Toggle auto hide of toolbar"), *m_rc_auto_hide, reconfig_toolbar_and_save_resource)); @@ -795,66 +793,64 @@ void Toolbar::setupMenus() { visible_macro->add(toggle_visible); visible_macro->add(save_resources); RefCommand toggle_visible_cmd(visible_macro); - menu().insert(new BoolMenuItem("Visible", *m_rc_visible, toggle_visible_cmd)); + menu().insert(new BoolMenuItem(_FBTEXT(Common, Visible, "Visible", "Whether this item is visible"), + *m_rc_visible, toggle_visible_cmd)); - menu().insert(new BoolMenuItem("Maximize Over", *m_rc_maximize_over, + menu().insert(new BoolMenuItem(_FBTEXT(Common, MaximizeOver,"Maximize Over", "Maximize over this thing when maximizing"), + *m_rc_maximize_over, reconfig_toolbar_and_save_resource)); - menu().insert("Layer...", &layermenu()); + menu().insert(_FBTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), &layermenu()); if (screen().hasXinerama()) { - // TODO: nls (main label plus menu heading - menu().insert("On Head...", new XineramaHeadMenu(screen().menuTheme(), - screen(), - screen().imageControl(), - *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), - *this, - "Toolbar on Head")); + menu().insert(_FBTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"), + new XineramaHeadMenu(screen().menuTheme(), + screen(), + screen().imageControl(), + *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), + *this, + _FBTEXT(Toolbar, OnHead, "Toolbar on Head", "Title of toolbar on head menu"))); } - // setup items in placement menu - struct { - int set; - int base; - const char *default_str; - Toolbar::Placement placement; - } place_menu[] = { - {0, 0, "Top Left", Toolbar::TOPLEFT}, - - {0, 0, "Left Top", Toolbar::LEFTTOP}, - {0, 0, "Left Center", Toolbar::LEFTCENTER}, - {0, 0, "Left Bottom", Toolbar::LEFTBOTTOM}, - - {0, 0, "Bottom Left", Toolbar::BOTTOMLEFT}, - {0, 0, "Top Center", Toolbar::TOPCENTER}, - {0, 0, 0, Toolbar::TOPCENTER}, - {0, 0, 0, Toolbar::BOTTOMCENTER}, - {0, 0, 0, Toolbar::BOTTOMCENTER}, - {0, 0, "Bottom Center", Toolbar::BOTTOMCENTER}, - {0, 0, "Top Right", Toolbar::TOPRIGHT}, - - {0, 0, "Right Top", Toolbar::RIGHTTOP}, - {0, 0, "Right Center", Toolbar::RIGHTCENTER}, - {0, 0, "Right Bottom", Toolbar::RIGHTBOTTOM}, - - {0, 0, "Bottom Right", Toolbar::BOTTOMRIGHT} - }; + typedef list > Placements; + Placements place_menu; + + // menu is 3 wide, 5 down + place_menu.push_back(make_pair(_FBTEXT(Align, TopLeft, "Top Left", "Top Left"), Toolbar::TOPLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, LeftTop, "Left Top", "Left Top"), Toolbar::LEFTTOP)); + place_menu.push_back(make_pair(_FBTEXT(Align, LeftCenter, "Left Center", "Left Center"), Toolbar::LEFTCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), Toolbar::LEFTBOTTOM)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Toolbar::BOTTOMLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, TopCenter, "Top Center", "Top Center"), Toolbar::TOPCENTER)); + place_menu.push_back(make_pair((const char *)0, Toolbar::TOPLEFT)); + place_menu.push_back(make_pair((const char *)0, Toolbar::TOPLEFT)); + place_menu.push_back(make_pair((const char *)0, Toolbar::TOPLEFT)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Toolbar::BOTTOMCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, TopRight, "Top Right", "Top Right"), Toolbar::TOPRIGHT)); + place_menu.push_back(make_pair(_FBTEXT(Align, RightTop, "Right Top", "Right Top"), Toolbar::RIGHTTOP)); + place_menu.push_back(make_pair(_FBTEXT(Align, RightCenter, "Right Center", "Right Center"), Toolbar::RIGHTCENTER)); + place_menu.push_back(make_pair(_FBTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), Toolbar::RIGHTBOTTOM)); + place_menu.push_back(make_pair(_FBTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Toolbar::BOTTOMRIGHT)); + + placementMenu().setMinimumSublevels(3); // create items in sub menu for (size_t i=0; i<15; ++i) { - if (place_menu[i].default_str == 0) { + const char *str = place_menu.front().first; + Toolbar::Placement placement = place_menu.front().second; + + if (str == 0) { placementMenu().insert(""); + placementMenu().setItemEnabled(i, false); } else { - const char *i18n_str = i18n.getMessage(place_menu[i].set, - place_menu[i].base, - place_menu[i].default_str); - RefCommand setplace(new SetToolbarPlacementCmd(*this, place_menu[i].placement)); - placementMenu().insert(i18n_str, setplace); + RefCommand setplace(new SetToolbarPlacementCmd(*this, placement)); + placementMenu().insert(str, setplace); } + place_menu.pop_front(); } - menu().insert("Placement", &placementMenu()); + menu().insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &placementMenu()); placementMenu().update(); menu().update(); } diff --git a/src/WinClient.cc b/src/WinClient.cc index 3911d6c..fe06245 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -19,18 +19,19 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WinClient.cc,v 1.39 2004/04/28 14:59:12 rathnor Exp $ +// $Id: WinClient.cc,v 1.40 2004/06/07 11:46:04 rathnor Exp $ #include "WinClient.hh" #include "Window.hh" #include "fluxbox.hh" #include "Screen.hh" -#include "I18n.hh" #include "FbAtoms.hh" #include "EventManager.hh" #include "Xutil.hh" +#include "FbTk/I18n.hh" + #include #include #include @@ -630,8 +631,10 @@ void WinClient::updateWMProtocols() { XFree(proto); if (m_win) m_win->updateFunctions(); +#ifdef DEBUG } else { cerr<<"Warning: Failed to read WM Protocols. "< - getMessage(FBNLS::WorkspaceSet, - FBNLS::WorkspaceDefaultNameFormat, - "Workspace %d"), m_id + 1); //m_id starts at 0 + sprintf(tname, + _FBTEXT(Workspace, DefaultNameFormat, + "Workspace %d", "Default workspace names, with a %d for the workspace number"), + m_id + 1); //m_id starts at 0 m_name = tname; } diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index 575ddeb..dd45b38 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceMenu.cc,v 1.1 2004/05/02 20:51:36 fluxgen Exp $ +// $Id: WorkspaceMenu.cc,v 1.2 2004/06/07 11:46:04 rathnor Exp $ #include "WorkspaceMenu.hh" @@ -27,8 +27,8 @@ #include "fluxbox.hh" #include "Workspace.hh" #include "MenuCreator.hh" -#include "I18n.hh" +#include "FbTk/I18n.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/RefCount.hh" #include "FbTk/MenuItem.hh" @@ -84,21 +84,17 @@ void WorkspaceMenu::init(BScreen &screen) { screen.currentWorkspaceSig().attach(this); screen.workspaceCountSig().attach(this); screen.workspaceNamesSig().attach(this); - I18n &i18n = *I18n::instance(); using namespace FbTk; - using namespace FBNLS; + _FB_USES_NLS; removeAll(); - setLabel(i18n.getMessage(WorkspacemenuSet, WorkspacemenuWorkspacesTitle, - "Workspace")); + setLabel(_FBTEXT(Workspace, MenuTitle, "Workspace", "Title of main workspace menu")); RefCount new_workspace(new SimpleCommand(screen, &BScreen::addWorkspace)); RefCount remove_last(new SimpleCommand(screen, &BScreen::removeLastWorkspace)); - insert(i18n.getMessage(WorkspacemenuSet, WorkspacemenuNewWorkspace, - "New Workspace"), + insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), new_workspace); - insert(i18n.getMessage(WorkspacemenuSet, WorkspacemenuRemoveLast, - "Remove Last"), + insert(_FBTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), remove_last); // for each workspace add workspace name and it's menu to our workspace menu for (size_t workspace = 0; workspace < screen.getCount(); ++workspace) { @@ -108,8 +104,7 @@ void WorkspaceMenu::init(BScreen &screen) { } setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true); - insert(i18n.getMessage(IconSet, IconIcons, - "Icons"), + insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), MenuCreator::createMenuType("iconmenu", screen.screenNumber())); FbMenu::update(); } diff --git a/src/Xutil.cc b/src/Xutil.cc index e36080a..514198c 100644 --- a/src/Xutil.cc +++ b/src/Xutil.cc @@ -20,12 +20,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Xutil.cc,v 1.4 2004/01/30 11:06:25 rathnor Exp $ +// $Id: Xutil.cc,v 1.5 2004/06/07 11:46:04 rathnor Exp $ #include "Xutil.hh" -#include "I18n.hh" -#include "App.hh" +#include "FbTk/I18n.hh" +#include "FbTk/App.hh" #include #include @@ -46,7 +46,7 @@ std::string getWMName(Window window) { text_prop.value = 0; char **list; int num; - I18n *i18n = I18n::instance(); + _FB_USES_NLS; std::string name; if (XGetWMName(display, window, &text_prop)) { @@ -69,13 +69,11 @@ std::string getWMName(Window window) { XFree(text_prop.value); } else { // default name - name = i18n->getMessage(FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); + name = _FBTEXT(Window, Unnamed, "Unnamed", "Default name for a window without a WM_NAME"); } } else { // default name - name = i18n->getMessage(FBNLS::WindowSet, FBNLS::WindowUnnamed, - "Unnamed"); + name = _FBTEXT(Window, Unnamed, "Unnamed", "Default name for a window without a WM_NAME"); } return name; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 9f0f24e..c26145c 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,11 +22,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.242 2004/05/02 20:48:16 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.243 2004/06/07 11:46:04 rathnor Exp $ #include "fluxbox.hh" -#include "I18n.hh" #include "Screen.hh" #include "Window.hh" #include "Workspace.hh" @@ -37,6 +36,7 @@ #include "FbAtoms.hh" #include "defaults.hh" +#include "FbTk/I18n.hh" #include "FbTk/Image.hh" #include "FbTk/KeyUtil.hh" #include "FbTk/ImageControl.hh" @@ -432,14 +432,14 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile m_RC_PATH("fluxbox"), m_RC_INIT_FILE("init") { - + _FB_USES_NLS; if (s_singleton != 0) - throw string("Fatal! There can only one instance of fluxbox class."); + throw string(_FBTEXT(Fluxbox, FatalSingleton, "Fatal! There can only one instance of fluxbox class.", "Error displayed on weird error where an instance of the Fluxbox class already exists!")); if (display() == 0) { - //!! TODO: NLS - throw string("Can not connect to X server.\n" - "Make sure you started X before you start Fluxbox."); + throw string(_FBTEXT(Fluxbox, NoDisplay, + "Can not connect to X server.\nMake sure you started X before you start Fluxbox.", + "Error message when no X display appears to exist")); } // For KDE dock applets // KDE v1.x @@ -513,10 +513,10 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile setupConfigFiles(); if (! XSupportsLocale()) - cerr<<"Warning: X server does not support locale"<xmaprequest.parent); if (screen == 0) { - cerr<<"Fluxbox Warning! Could not find screen to map window on!"<createWindow(e->xmaprequest.window); @@ -1288,7 +1290,8 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { /// handle system signals void Fluxbox::handleSignal(int signum) { - I18n *i18n = I18n::instance(); + _FB_USES_NLS; + static int re_enter = 0; switch (signum) { @@ -1314,25 +1317,19 @@ void Fluxbox::handleSignal(int signum) { break; default: fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught, - "%s: signal %d caught\n"), + _FBTEXT(BaseDisplay, SignalCaught, "%s: signal %d caught\n", "signal catch debug message. Include %s for command and %d for signal number"), m_argv[0], signum); if (! m_starting && ! re_enter) { re_enter = 1; fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown, - "shutting down\n")); + _FBTEXT(BaseDisplay, ShuttingDown, "Shutting Down\n", "Quitting because of signal, end with newline")); shutdown(); } fprintf(stderr, - i18n->getMessage( - FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting, - "aborting... dumping core\n")); + _FBTEXT(BaseDisplay, Aborting, "Aborting... dumping core\n", "Aboring and dumping core, end with newline")); abort(); break; } @@ -1607,7 +1604,7 @@ void Fluxbox::shutdown() { /// saves resources void Fluxbox::save_rc() { - + _FB_USES_NLS; XrmDatabase new_blackboxrc = 0; char rc_string[1024]; @@ -1618,7 +1615,7 @@ void Fluxbox::save_rc() { m_resourcemanager.save(dbfile.c_str(), dbfile.c_str()); m_screen_rm.save(dbfile.c_str(), dbfile.c_str()); } else - cerr<<"database filename is invalid!"<empty()) @@ -1714,12 +1711,13 @@ void Fluxbox::load_rc() { *m_rc_stylefile = DEFAULTSTYLE; if (!Workspace::loadGroups(*m_rc_groupfile)) { - cerr<<"Failed to load groupfile: "<<*m_rc_groupfile< disabled): "< "<< + _FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<= argc) { - fprintf(stderr, - i18n.getMessage(FBNLS::mainSet, FBNLS::mainRCRequiresArg, - "error: '-rc' requires and argument\n")); + cerr<<_FBTEXT(main, RCRequiresArg, + "error: '-rc' requires an argument", "the -rc option requires a file argument")<= argc) { - fprintf(stderr, - i18n.getMessage(FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, - "error: '-display' requires an argument\n")); + cerr<<_FBTEXT(main, DISPLAYRequiresArg, + "error: '-display' requires an argument", + "")<(display_env.c_str()))) { - fprintf(stderr, - i18n. - getMessage(FBNLS::mainSet, FBNLS::mainWarnDisplaySet, - "warning: couldn't set environment variable 'DISPLAY'\n")); + cerr<<_FBTEXT(main, WarnDisplaySet, + "warning: couldn't set environment variable 'DISPLAY'", + "")<= argc) { - cerr<<"error: '-log' needs an argument"<\t\tuse display connection.\n" - " -rc \t\t\tuse alternate resource file.\n" - " -version\t\t\tdisplay version and exit.\n" - " -info\t\t\t\tdisplay some useful information.\n" - "\t-log \t\t\tlog output to file.\n" - " -help\t\t\t\tdisplay this help text and exit.\n\n"), + printf(_FBTEXT(main, Usage, + "Fluxbox %s : (c) %s Henrik Kinnunen\n" + "Website: http://www.fluxbox.org/ \n\n" + "\t-display \t\tuse display connection.\n" + "\t-rc \t\t\tuse alternate resource file.\n" + "\t-version\t\t\tdisplay version and exit.\n" + "\t-info\t\t\t\tdisplay some useful information.\n" + "\t-log \t\t\tlog output to file.\n" + "\t-help\t\t\t\tdisplay this help text and exit.\n\n", + + "Main usage string. Please lay it out nicely. There is one %s that is given the version"), __fluxbox_version, "2001-2004"); exit(0); } else if (strcmp(argv[i], "-info") == 0 || strcmp(argv[i], "-i") == 0) { @@ -222,9 +226,9 @@ int main(int argc, char **argv) { // setup log file if (log_file) { - cerr<<"Loggin to: "<