From fff4456dee29e675d7f2ed3490db39bcb7e10e53 Mon Sep 17 00:00:00 2001 From: rathnor <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 <iostream> #include <algorithm> @@ -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"<<endl; + _FB_USES_NLS; + cerr<<_FBTEXT(Ewmh, OutOfMemoryClientList, "Fatal: Out of memory, can't allocate for EWMH client list", "")<<endl; return; } @@ -594,7 +596,6 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, } else if (ce.message_type == m_net_close_window) { if (winclient == 0) return true; - cerr<<"We got _NET_CLOSE_WINDOW!"<<endl; // ce.window = window to close (which in this case is the win argument) winclient->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 "<<name<<" "<<value<<endl; return new SetResourceValueCmd(name, value); } else if (command == "setresourcevaluedialog") return new SetResourceValueDialogCmd(); diff --git a/src/FbTk/Color.cc b/src/FbTk/Color.cc index 0a45864..cd6c2a8 100644 --- a/src/FbTk/Color.cc +++ b/src/FbTk/Color.cc @@ -19,12 +19,13 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Color.cc,v 1.10 2004/04/25 16:12:21 fluxgen Exp $ +// $Id: Color.cc,v 1.11 2004/06/07 11:46:05 rathnor Exp $ #include "Color.hh" #include "App.hh" #include "StringUtil.hh" +#include "I18n.hh" #include <iostream> 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."<<endl; + _FB_USES_NLS; + cerr<<"FbTk::Color: "<<_FBTKTEXT(Error, ColorAllocation, "Allocation error.", "XAllocColor failed...")<<endl; } else { setRGB(maxValue(color.red), maxValue(color.green), diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index d4f4f4c..9299b5d 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -19,11 +19,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.cc,v 1.12 2004/05/04 14:33:38 rathnor Exp $ +// $Id: EventManager.cc,v 1.13 2004/06/07 11:46:05 rathnor Exp $ #include "EventManager.hh" #include "FbWindow.hh" #include "App.hh" +#include "I18n.hh" #include <iostream> 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!"<<endl; +#endif // DEBUG } void EventManager::handleEvent(XEvent &ev) { diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc index 8f4cd42..453a195 100644 --- a/src/FbTk/Font.cc +++ b/src/FbTk/Font.cc @@ -19,11 +19,12 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.cc,v 1.6 2003/12/01 19:57:01 fluxgen Exp $ +//$Id: Font.cc,v 1.7 2004/06/07 11:46:05 rathnor Exp $ #include "Font.hh" #include "FontImp.hh" +#include "I18n.hh" #ifdef HAVE_CONFIG_H #include "config.h" @@ -130,8 +131,10 @@ void Font::setAntialias(bool flag) { } if (m_fontimp->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'."<<endl; + if (!m_fontimp->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'."<<endl; + } } m_antialias = flag; diff --git a/src/FbTk/I18n.cc b/src/FbTk/I18n.cc new file mode 100644 index 0000000..caffc6b --- /dev/null +++ b/src/FbTk/I18n.cc @@ -0,0 +1,153 @@ +// I18n.hh for Fluxbox Window Manager +// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) +// +// I18n.cc for Blackbox - an X11 Window manager +// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// $Id: I18n.cc,v 1.1 2004/06/07 11:46:05 rathnor Exp $ + +/* Note: + * A good reference for the older non-gettext style I18n + * functions is the "Locale tutorial" + * Written by Patrick D'Cruze (pdcruze@orac.iinet.com.au) + * A copy of which is available (at the time of writing) here: + * http://www.kulichki.com/moshkow/CYRILLIC/locale-tutorial-0_8.txt + */ + +//usr GNU extensions +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif // _GNU_SOURCE + +#include "I18n.hh" + +#include <X11/Xlocale.h> + +#include <cstdlib> +#include <cstring> +#include <cstdio> + +#include <iostream> + +// 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\""<<endl; +#endif // HAVE_SETLOCALE + + m_locale = "C"; + +#ifdef HAVE_SETLOCALE + + } else { + // MB_CUR_MAX returns the size of a char in the current locale + if (MB_CUR_MAX > 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("<<catalog_filename<<")"<<endl; + cerr<<"for translation, using default messages."<<endl; + } + +#else // !HAVE_CATOPEN + + m_catalog_fd = (nl_catd)-1; +#endif // HAVE_CATOPEN +} + + +const char *I18n::getMessage(int set_number, int message_number, + const char *default_message) const { + +#if defined(NLS) && defined(HAVE_CATGETS) + if (m_catalog_fd != (nl_catd)-1) + return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); + else +#endif // NLS && HAVE_CATGETS + return default_message; +} + +}; // end namespace FbTk diff --git a/src/FbTk/I18n.hh b/src/FbTk/I18n.hh new file mode 100644 index 0000000..08f973d --- /dev/null +++ b/src/FbTk/I18n.hh @@ -0,0 +1,112 @@ +// i18n.hh for Fluxbox Window Manager +// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) +// +// i18n.hh for Blackbox - an X11 Window manager +// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// $Id: I18n.hh,v 1.1 2004/06/07 11:46:05 rathnor Exp $ + +#ifndef I18N_HH +#define I18N_HH + +// TODO: FIXME +#include "../../nls/fluxbox-nls.hh" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + + +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif // HAVE_LOCALE_H + +#ifdef HAVE_NL_TYPES_H +// this is needed for linux libc5 systems +extern "C" { +#include <nl_types.h> +} +#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 <string> + +// 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"<<endl; + _FB_USES_NLS; + cerr<<"FbTk::ImageControl: "<<_FBTKTEXT(Error, UnsupportedVisual, "Unsupported visual", "A visual is a technical term in X")<<endl; break; } } diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index 3f8b8f2..6ebacc5 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am @@ -16,6 +16,7 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ Directory.hh Directory.cc \ EventHandler.hh EventManager.hh EventManager.cc \ FbWindow.hh FbWindow.cc Font.cc Font.hh FontImp.hh \ + I18n.cc I18n.hh \ ImageControl.hh ImageControl.cc \ MacroCommand.hh MacroCommand.cc \ Menu.hh Menu.cc MenuItem.hh MenuItem.cc \ diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 60c40f8..8736edf 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.60 2004/05/17 15:01:32 rathnor Exp $ +// $Id: Menu.cc,v 1.61 2004/06/07 11:46:05 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -38,6 +38,7 @@ #include "EventManager.hh" #include "Transparent.hh" #include "SimpleCommand.hh" +#include "I18n.hh" #include <X11/Xatom.h> #include <X11/keysym.h> @@ -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()<<", "<<menu.frame.width()<<", "<< menu.frame.height()<< ", "<<menu.frame.depth()<<") !"<<endl; diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index 848f629..9b89e2b 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc @@ -19,10 +19,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Resource.cc,v 1.5 2004/01/19 18:26:04 fluxgen Exp $ +// $Id: Resource.cc,v 1.6 2004/06/07 11:46:05 rathnor Exp $ #include "XrmDatabaseHelper.hh" #include "Resource.hh" +#include "I18n.hh" #include <iostream> #include <cassert> @@ -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: "<<resource->name()<<endl; - cerr<<"Setting default value"<<endl; + _FB_USES_NLS; + cerr<<_FBTKTEXT(Error, FailedRead, "Failed to read", "Couldn't load a resource (following)")<<": "<<resource->name()<<endl; + cerr<<_FBTKTEXT(Error, UsingDefault, "Setting default value", "Falling back to default value for resource")<<endl; resource->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 <iostream> #include <string> @@ -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"<<endl; + cerr<<"TextureRender: "<<_FBTKTEXT(Error, BigWidth, "Warning! Width > 3200 setting Width = 3200", "Image width seems too big, clamping")<<endl; width = 3200; } if (height > 3200) { - cerr<<"TextureRender: Warning! Height > 3200 setting Height = 3200"<<endl; + cerr<<"TextureRender: "<<_FBTKTEXT(Error, BigHeight, "Warning! Height > 3200 setting Height = 3200", "Image height seems too big, clamping")<<endl; height = 3200; } @@ -63,7 +65,7 @@ TextureRender::TextureRender(ImageControl &imgctrl, if (red == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): Out of memory while allocating red buffer."+ string(sbuf)); + throw string("TextureRender::TextureRender(): " + string(_FBTKTEXT(Error, OutOfMemoryRed, "Out of memory while allocating red buffer.", "")) + string(sbuf)); } @@ -71,14 +73,14 @@ TextureRender::TextureRender(ImageControl &imgctrl, if (green == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): Out of memory while allocating green buffer. size " + string(sbuf)); + throw string("TextureRender::TextureRender(): " +string(_FBTKTEXT(Error, OutOfMemoryGreen, "Out of memory while allocating green buffer.", ""))+ string(sbuf)); } blue = new(nothrow) unsigned char[width * height]; if (blue == 0) { char sbuf[128]; sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): Out of memory while allocating blue buffer. size " + string(sbuf)); + throw string("TextureRender::TextureRender(): " +string(_FBTKTEXT(Error, OutOfMemoryBlue, "Out of memory while allocating blue buffer.", ""))+ string(sbuf)); } cpc = imgctrl.colorsPerChannel(); @@ -120,7 +122,8 @@ Pixmap TextureRender::renderSolid(const FbTk::Texture &texture) { control.depth()); if (pixmap.drawable() == None) { - cerr<<"FbTk::TextureRender::render_solid(): error creating pixmap"<<endl; + _FB_USES_NLS; + cerr<<"FbTk::TextureRender::render_solid(): "<<_FBTKTEXT(Error, CreatePixmap, "Error creating pixmap", "Couldn't create a pixmap - image - for some reason")<<endl; return None; } @@ -274,7 +277,8 @@ XImage *TextureRender::renderXImage() { width, height, 32, 0); if (! image) { - cerr<<"FbTk::TextureRender::renderXImage(): error creating XImage"<<endl; + _FB_USES_NLS; + cerr<<"FbTk::TextureRender::renderXImage(): "<<_FBTKTEXT(Error, CreateXImage, "Error creating XImage", "Couldn't create an XImage")<<endl; return 0; } @@ -545,7 +549,9 @@ XImage *TextureRender::renderXImage() { */ default: - cerr<<"TextureRender::renderXImage(): unsupported visual"<<endl; + _FB_USES_NLS; + cerr<<"TextureRender::renderXImage(): "<< + _FBTKTEXT(Error, UnsupportedVisual, "unsupported visual", "A visual is a technical term in X")<<endl; delete [] d; XDestroyImage(image); return (XImage *) 0; @@ -644,7 +650,9 @@ XImage *TextureRender::renderXImage() { break; default: - cerr<<"TextureRender::renderXImage(): unsupported visual"<<endl; + _FB_USES_NLS; + cerr<<"TextureRender::renderXImage(): "<< + _FBTKTEXT(Error, UnsupportedVisual, "unsupported visual", "A visual is a technical term in X")<<endl; delete [] d; XDestroyImage(image); return (XImage *) 0; @@ -662,7 +670,8 @@ Pixmap TextureRender::renderPixmap() { width, height, control.depth()); if (pixmap.drawable() == None) { - cerr<<"TextureRender::renderPixmap(): error creating pixmap"<<endl; + _FB_USES_NLS; + cerr<<"FbTk::TextureRender::renderPixmap(): "<<_FBTKTEXT(Error, CreatePixmap, "Error creating pixmap", "Couldn't create a pixmap - image - for some reason")<<endl; return None; } diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index f9c3366..066f9fa 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.26 2004/04/26 15:04:37 rathnor Exp $ +// $Id: Theme.cc,v 1.27 2004/06/07 11:46:05 rathnor Exp $ #include "Theme.hh" @@ -28,6 +28,7 @@ #include "StringUtil.hh" #include "ThemeItems.hh" #include "Directory.hh" +#include "I18n.hh" #include <cstdio> #include <memory> @@ -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: "<<resource->name()<<endl; - resource->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)")<<": "<<resource->name()<<endl; + } + resource->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 <iostream> +#include <stdio.h> 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."<<endl; + cerr<<"FbTk::Transparent: "<<_FBTKTEXT(Error, NoRenderFormat, "Warning: Failed to find valid format for alpha.", "transparency requires a pict format, can't get one...")<<endl; return 0; } @@ -57,7 +60,7 @@ Picture createAlphaPic(Window drawable, unsigned char alpha) { Pixmap alpha_pm = XCreatePixmap(disp, drawable, 1, 1, 8); if (alpha_pm == 0) { - cerr<<"Warning! FbTk::Transparent: Failed to create alpha pixmap."<<endl; + cerr<<"FbTk::Transparent: "<<_FBTKTEXT(Error, NoRenderPixmap, "Warning: Failed to create alpha pixmap.", "XCreatePixmap files for our transparency pixmap")<<endl; return 0; } @@ -68,7 +71,7 @@ Picture createAlphaPic(Window drawable, unsigned char alpha) { format, CPRepeat, &attr); if (alpha_pic == 0) { XFreePixmap(disp, alpha_pm); - cerr<<"Warning! FbTk::Transparent: Failed to create alpha picture."<<endl; + cerr<<"FbTk::Transparent: "<<_FBTKTEXT(Error, NoRenderPicture, "Warning: Failed to create alpha picture.", "XRenderCreatePicture failed")<<endl; return 0; } @@ -181,8 +184,12 @@ void Transparent::setDest(Drawable dest, int screen_num) { XRenderPictFormat *format = XRenderFindVisualFormat(disp, DefaultVisual(disp, screen_num)); - if (format == 0) - cerr<<"Warning! FbTk::Transparent: Failed to find format for screen("<<screen_num<<")"<<endl; + if (format == 0) { + _FB_USES_NLS; + cerr<<"FbTk::Transparent: "; + fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num); + cerr<<endl; + } m_dest_pic = XRenderCreatePicture(disp, dest, format, 0, 0); @@ -216,8 +223,12 @@ void Transparent::setSource(Drawable source, int screen_num) { XRenderPictFormat *format = XRenderFindVisualFormat(disp, DefaultVisual(disp, screen_num)); - if (format == 0) - cerr<<"Warning! FbTk::Transparent: Failed to find format for screen("<<screen_num<<")"<<endl; + if (format == 0) { + _FB_USES_NLS; + cerr<<"FbTk::Transparent: "; + fprintf(stderr, _FBTKTEXT(Error, NoRenderVisualFormat, "Failed to find format for screen(%d)", "XRenderFindVisualFormat failed... include %d for screen number"), screen_num); + cerr<<endl; + } m_src_pic = XRenderCreatePicture(disp, m_source, format, 0, 0); } diff --git a/src/FbTk/XFontImp.cc b/src/FbTk/XFontImp.cc index e253aa6..0a1ea7d 100644 --- a/src/FbTk/XFontImp.cc +++ b/src/FbTk/XFontImp.cc @@ -19,12 +19,13 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XFontImp.cc,v 1.6 2003/09/11 20:00:09 fluxgen Exp $ +// $Id: XFontImp.cc,v 1.7 2004/06/07 11:46:05 rathnor Exp $ #include "XFontImp.hh" #include "App.hh" #include "GContext.hh" #include "FbPixmap.hh" +#include "I18n.hh" #include <X11/Xutil.h> @@ -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"<<endl; + cerr<<"RotFont: "<<_FBTKTEXT(Error, OutOfMemory, "Out of memory", "Something couldn't allocate memory")<<endl; return; } @@ -224,7 +227,7 @@ void XFontImp::rotate(float angle) { vert_w, vert_h, 8, 0); if (I1 == None) { - cerr<<"RotFont: Cant create ximage."<<endl; + cerr<<"RotFont: "<<_FBTKTEXT(Error, CreateXImage, "Cant create XImage", "XCreateImage failed for some reason")<<"."<<endl; delete m_rotfont; m_rotfont = 0; return; @@ -262,7 +265,7 @@ void XFontImp::rotate(float angle) { (char *)bitdata, bit_w, bit_h, 8, 0); if (I2 == None) { - cerr<<"XFontImp: Cant create ximage!"<<endl; + cerr<<"XFontImp: "<<_FBTKTEXT(Error, CreateXImage, "Cant create XImage", "XCreateImage failed for some reason")<<"."<<endl; delete m_rotfont; m_rotfont = 0; return; diff --git a/src/Gnome.cc b/src/Gnome.cc index dcfb029..a01e79b 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Gnome.cc,v 1.34 2004/02/20 09:05:38 fluxgen Exp $ +// $Id: Gnome.cc,v 1.35 2004/06/07 11:46:04 rathnor Exp $ #include "Gnome.hh" @@ -28,6 +28,7 @@ #include "Screen.hh" #include "WinClient.hh" #include "Workspace.hh" +#include "FbTk/I18n.hh" #include <iostream> #include <new> @@ -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 ("<<num*sizeof (Window)<<") for gnome client list"<<endl; + _FB_USES_NLS; + cerr<<_FBTEXT(Gnome, OutOfMemoryClientList, "Fatal: Out of memory, can't allocate for GNOME client list", "")<<endl; return; } diff --git a/src/I18n.cc b/src/I18n.cc deleted file mode 100644 index 43f8cea..0000000 --- a/src/I18n.cc +++ /dev/null @@ -1,140 +0,0 @@ -// I18n.hh for Fluxbox Window Manager -// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) -// -// I18n.cc for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// $Id: I18n.cc,v 1.6 2004/01/21 14:12:51 fluxgen Exp $ - -//usr GNU extensions -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif // _GNU_SOURCE - -#include "I18n.hh" - -#include <X11/Xlocale.h> - -#include <cstdlib> -#include <cstring> -#include <cstdio> - -#include <iostream> - -#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\""<<endl; -#endif // HAVE_SETLOCALE - - m_locale = "C"; - -#ifdef HAVE_SETLOCALE - - } else { - // MB_CUR_MAX returns the size of a char in the current locale - if (MB_CUR_MAX > 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("<<catalog_filename<<")"<<endl; - cerr<<"for translation, using default messages."<<endl; - } - -#else // !HAVE_CATOPEN - - m_catalog_fd = (nl_catd)-1; -#endif // HAVE_CATOPEN -} - - -const char *I18n::getMessage(int set_number, int message_number, - const char *default_message) const { - -#if defined(NLS) && defined(HAVE_CATGETS) - if (m_catalog_fd != (nl_catd)-1) - return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); - else -#endif // NLS && HAVE_CATGETS - return default_message; -} diff --git a/src/I18n.hh b/src/I18n.hh deleted file mode 100644 index 09c0b41..0000000 --- a/src/I18n.hh +++ /dev/null @@ -1,83 +0,0 @@ -// i18n.hh for Fluxbox Window Manager -// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) -// -// i18n.hh for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// $Id: I18n.hh,v 1.4 2004/05/02 20:46:43 fluxgen Exp $ - -#ifndef I18N_HH -#define I18N_HH - -#include "../nls/fluxbox-nls.hh" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - - -#ifdef HAVE_LOCALE_H -#include <locale.h> -#endif // HAVE_LOCALE_H - -#ifdef HAVE_NL_TYPES_H -// this is needed for linux libc5 systems -extern "C" { -#include <nl_types.h> -} -#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 <string> - -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<Container::Alignment>::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<Command> saverc_cmd(new SimpleCommand<Fluxbox>( *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<val.size(); argc++) { @@ -180,7 +182,7 @@ bool Keys::addBinding(const std::string &linebuffer) { else { key = FbTk::KeyUtil::getKey(val[argc].c_str()); // else get the key if (key == 0) { - cerr<<"Keys: Invalid key/modifier on line("<< + cerr<<_FBTEXT(Keys, InvalidKeyMod, "Keys: Invalid key/modifier on line", "A bad key/modifier string was found on line (number following)")<<" "<< m_current_line<<"): "<<linebuffer<<endl; return false; } @@ -197,7 +199,7 @@ bool Keys::addBinding(const std::string &linebuffer) { } else { // parse command line if (last_key == 0) { - cerr<<"Keys: Error on line: "<<m_current_line<<endl; + cerr<<_FBTEXT(Keys, BadLine, "Keys: Error on line", "Error on line (number following)")<<": "<<m_current_line<<endl; cerr<<"> "<<linebuffer<<endl; return false; } @@ -206,7 +208,7 @@ bool Keys::addBinding(const std::string &linebuffer) { FbTk::StringUtil::strcasestr(linebuffer.c_str(), val[argc].c_str() + 1); // +1 to skip ':' if (str == 0) { - cerr<<"Keys: Error on line: "<<m_current_line<<endl; + cerr<<_FBTEXT(Keys, BadLine, "Keys: Error on line", "Error on line (number following)")<<": "<<m_current_line<<endl; cerr<<"> "<<linebuffer<<endl; ret_val = false; } else { @@ -214,12 +216,12 @@ bool Keys::addBinding(const std::string &linebuffer) { last_key->m_command = CommandParser::instance().parseLine(str); if (*last_key->m_command == 0) { - cerr<<"Keys: Error on line: "<<m_current_line<<endl; + cerr<<_FBTEXT(Keys, BadLine, "Keys: Error on line", "Error on line (number following)")<<": "<<m_current_line<<endl; cerr<<"> "<<linebuffer<<endl; } else { // Add the keychain to list if (!mergeTree(current_key)) { - cerr<<"Keys: Failed to merge keytree!"<<endl; + cerr<<_FBTEXT(Keys, BadMerge, "Keys: Failed to merge keytree!", "relatively technical error message. Key bindings are stored in a tree structure")<<endl; ret_val = false; } } diff --git a/src/Makefile.am b/src/Makefile.am index 9a430e1..c42ae12 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,9 +41,8 @@ defaults.hh: Makefile echo '#define DEFAULT_INITFILE "$(pkgdatadir)/init"' >> 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<FbTk::Command> 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<FbTk::Command> 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<FbTk::Command> 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<FbTk::Command> RefCmd; typedef FbTk::SimpleCommand<FluxboxWindow> 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: "<<errstr<<endl; + cerr<<_FBTEXT(Fluxbox, ErrorRegexp, "Error parsing regular expression", "Error parsing regular expression (following)")<<": "<<errstr<<endl; delete [] errstr; delete m_regex; // I don't think I regfree a failed compile? m_regex = 0; diff --git a/src/Remember.cc b/src/Remember.cc index c0c0b9d..af0270d 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -21,7 +21,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Remember.cc,v 1.36 2004/04/18 17:53:15 fluxgen Exp $ +// $Id: Remember.cc,v 1.37 2004/06/07 11:46:04 rathnor Exp $ #include "Remember.hh" #include "ClientPattern.hh" @@ -32,6 +32,7 @@ #include "FbCommands.hh" #include "fluxbox.hh" +#include "FbTk/I18n.hh" #include "FbTk/StringUtil.hh" #include "FbTk/MenuItem.hh" #include "FbTk/App.hh" @@ -123,25 +124,25 @@ FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win, bool enab return menu; } - // TODO: nls - menu->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<<I18n::instance()-> - getMessage(FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning, - "BScreen::BScreen: an error occured while querying the X server.\n" - " another window manager already running on display ")<<DisplayString(display)<<endl; + _FB_USES_NLS; + cerr<<_FBTEXT(Screen, AnotherWMRunning, + "BScreen::BScreen: an error occured while querying the X server.\n" + " another window manager already running on display ", + "Message when another WM is found already active on all screens") + <<DisplayString(display)<<endl; running = false; @@ -248,11 +250,12 @@ BScreen::BScreen(FbTk::ResourceManager &rm, if (! managed) return; - I18n *i18n = I18n::instance(); + _FB_USES_NLS; - fprintf(stderr, i18n->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<FbTk::Command> restart_fb(CommandParser::instance().parseLine("restart")); FbTk::RefCount<FbTk::Command> exit_fb(CommandParser::instance().parseLine("exit")); FbTk::RefCount<FbTk::Command> 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 <algorithm> #include <iostream> @@ -79,8 +79,9 @@ template<> void FbTk::Resource<Slit::Placement>::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<Slit::Placement>::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<Slit::Placement>::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<Slit::Placement>::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<FbTk::Command> cycle_up(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsUp)); FbTk::RefCount<FbTk::Command> cycle_down(new FbTk::SimpleCommand<Slit>(*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<FbTk::Command> 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<Slit>( - 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<Slit>( + 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<Command> clear_cmd(new SimpleCommand<Slit>(*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<pair<const char *, Slit::Placement> > 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<Command> 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<Toolbar>(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<Toolbar>(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<pair<const char *, Toolbar::Placement> > 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 <iostream> #include <algorithm> #include <iterator> @@ -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. "<<endl; +#endif // DEBUG } } diff --git a/src/Window.cc b/src/Window.cc index 9299653..a70dad3 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,12 +22,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.287 2004/05/13 01:48:18 rathnor Exp $ +// $Id: Window.cc,v 1.288 2004/06/07 11:46:04 rathnor Exp $ #include "Window.hh" #include "WinClient.hh" -#include "I18n.hh" #include "fluxbox.hh" #include "Screen.hh" #include "FbWinFrameTheme.hh" @@ -40,6 +39,7 @@ #include "Remember.hh" #include "MenuCreator.hh" +#include "FbTk/I18n.hh" #include "FbTk/TextButton.hh" #include "FbTk/Compose.hh" #include "FbTk/EventManager.hh" diff --git a/src/Workspace.cc b/src/Workspace.cc index 87c32c4..b9776d7 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -22,17 +22,17 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.96 2004/05/13 01:48:18 rathnor Exp $ +// $Id: Workspace.cc,v 1.97 2004/06/07 11:46:04 rathnor Exp $ #include "Workspace.hh" -#include "I18n.hh" #include "fluxbox.hh" #include "Screen.hh" #include "Window.hh" #include "WinClient.hh" #include "FbWinFrame.hh" +#include "FbTk/I18n.hh" #include "FbTk/MenuItem.hh" #include "FbTk/StringUtil.hh" @@ -352,11 +352,12 @@ void Workspace::setName(const std::string &name) { if (!name.empty()) { m_name = name; } else { //if name == 0 then set default name from nls + _FB_USES_NLS; char tname[128]; - sprintf(tname, I18n::instance()-> - 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<Command> new_workspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace)); RefCount<Command> remove_last(new SimpleCommand<BScreen, int>(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 <X11/Xutil.h> #include <X11/Xatom.h> @@ -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"<<endl; + cerr<<_FBTEXT(Fluxbox, WarningLocale, "Warning: X server does not support locale", "XSupportsLocale returned false")<<endl; if (XSetLocaleModifiers("") == 0) - cerr<<"Warning: cannot set locale modifiers"<<endl; + cerr<<_FBTEXT(Fluxbox, WarningLocaleModifiers, "Warning: cannot set locale modifiers", "XSetLocaleModifiers returned false")<<endl; #ifdef HAVE_GETPID @@ -599,9 +599,8 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile m_keyscreen = m_mousescreen = m_screen_list.front(); if (m_screen_list.empty()) { - //!! TODO: NLS - throw string("Couldn't find screens to manage.\n" - "Make sure you don't have another window manager running."); + throw string(_FBTEXT(Fluxbox, ErrorNoScreens, + "Couldn't find screens to manage.\nMake sure you don't have another window manager running.", "Error message when no unmanaged screens found - usually means another window manager is running")); } // setup theme manager to have our style file ready to be scanned @@ -728,10 +727,12 @@ void Fluxbox::setupConfigFiles() { #ifdef DEBUG cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl; #endif // DEBUG - + _FB_USES_NLS; // create directory with perm 700 if (mkdir(dirname.c_str(), 0700)) { - cerr << "Can't create " << dirname << " directory!" << endl; + fprintf(stderr, _FBTEXT(Fluxbox, ErrorCreatingDirectory, + "Can't create %s directory", "Can't create a directory, one %s for directory name"), dirname.c_str()); + cerr<<endl; return; } @@ -755,6 +756,7 @@ void Fluxbox::setupConfigFiles() { } void Fluxbox::handleEvent(XEvent * const e) { + _FB_USES_NLS; m_last_event = *e; // it is possible (e.g. during moving) for a window @@ -885,7 +887,7 @@ void Fluxbox::handleEvent(XEvent * const e) { screen = searchScreen(e->xmaprequest.parent); if (screen == 0) { - cerr<<"Fluxbox Warning! Could not find screen to map window on!"<<endl; + cerr<<"Fluxbox "<<_FBTEXT(Fluxbox, CantMapWindow, "Warning! Could not find screen to map window on!", "")<<endl; } else win = screen->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!"<<endl; + cerr<<_FBTEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; ScreenList::iterator it = m_screen_list.begin(); ScreenList::iterator it_end = m_screen_list.end(); @@ -1678,20 +1675,20 @@ void Fluxbox::getDefaultDataFilename(char *name, string &filename) { /// loads resources void Fluxbox::load_rc() { - + _FB_USES_NLS; //get resource filename string dbfile(getRcFilename()); if (!dbfile.empty()) { if (!m_resourcemanager.load(dbfile.c_str())) { - cerr<<"Failed to load database:"<<dbfile<<endl; - cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl; if (!m_resourcemanager.load(DEFAULT_INITFILE)) - cerr<<"Failed to load database: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; } } else { if (!m_resourcemanager.load(DEFAULT_INITFILE)) - cerr<<"Failed to load database: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; } if (m_rc_menufile->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<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadGroupFile, "Failed to load groupfile", "Couldn't load the groupfile")<<": "<<*m_rc_groupfile<<endl; } } void Fluxbox::load_rc(BScreen &screen) { //get resource filename + _FB_USES_NLS; string dbfile(getRcFilename()); XrmDatabaseHelper database; @@ -1774,16 +1772,15 @@ void Fluxbox::load_rc(BScreen &screen) { if (!dbfile.empty()) { if (!m_screen_rm.load(dbfile.c_str())) { - cerr<<"Failed to load database:"<<dbfile<<endl; - cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<dbfile<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl; if (!m_screen_rm.load(DEFAULT_INITFILE)) - cerr<<"Failed to load database: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; } } else { if (!m_screen_rm.load(DEFAULT_INITFILE)) - cerr<<"Failed to load database: "<<DEFAULT_INITFILE<<endl; + cerr<<_FBTEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl; } - } void Fluxbox::loadRootCommand(BScreen &screen) { diff --git a/src/main.cc b/src/main.cc index 9f3d816..68bb62f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -20,14 +20,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: main.cc,v 1.29 2004/02/28 10:32:06 fluxgen Exp $ +// $Id: main.cc,v 1.30 2004/06/07 11:46:04 rathnor Exp $ #include "fluxbox.hh" -#include "I18n.hh" #include "version.h" #include "defaults.hh" #include "FbTk/Theme.hh" +#include "FbTk/I18n.hh" #ifdef HAVE_CONFIG_H #include "config.h" @@ -48,26 +48,31 @@ using namespace std; void showInfo(ostream &ostr) { - ostr<<"Fluxbox version: "<<__fluxbox_version<<endl; + _FB_USES_NLS; + ostr<<_FBTEXT(Common, FluxboxVersion, "Fluxbox version", "Fluxbox version heading")<<": "<<__fluxbox_version<<endl; #if defined(__DATE__) && defined(__TIME__) - ostr<<"Compiled: "<<__DATE__<<" "<<__TIME__<<endl; + ostr<<_FBTEXT(Common, Compiled, "Compiled", "Time fluxbox was compiled")<<": "<<__DATE__<<" "<<__TIME__<<endl; #endif #ifdef __fluxbox_compiler - ostr<<"Compiler: "<<__fluxbox_compiler<<endl; + ostr<<_FBTEXT(Common, Compiler, "Compiler", "Compiler used to build fluxbox")<<": "<<__fluxbox_compiler<<endl; #endif // __fluxbox_compiler #ifdef __fluxbox_compiler_version - ostr<<"Compiler version: "<<__fluxbox_compiler_version<<endl; + ostr<<_FBTEXT(Common, CompilerVersion, "Compiler version", "Compiler version used to build fluxbox")<<": "<<__fluxbox_compiler_version<<endl; #endif // __fluxbox_compiler_version - ostr<<endl<<"Defaults:"<<endl; - ostr<<" menu: "<<DEFAULTMENU<<endl; - ostr<<" style: "<<DEFAULTSTYLE<<endl; + ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl; + + ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl; + ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl; - ostr<<" keys: "<<DEFAULTKEYSFILE<<endl; - ostr<<" init: "<<DEFAULT_INITFILE<<endl; + ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl; + ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl; const char NOT[] = "-"; - ostr<<endl<<"Compiled options ("<<NOT<<" => disabled): "<<endl<< + ostr<<endl<< + _FBTEXT(Common, CompiledOptions, "Compiled options", "Options used when compiled") + <<" ("<<NOT<<" => "<< + _FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<< #ifndef DEBUG NOT<< #endif // DEBUG @@ -141,8 +146,8 @@ int main(int argc, char **argv) { std::string rc_file; std::string log_filename; - NLSInit("fluxbox.cat"); - I18n &i18n = *I18n::instance(); + FbTk::NLSInit("fluxbox.cat"); + _FB_USES_NLS; int i; for (i = 1; i < argc; ++i) { @@ -150,9 +155,8 @@ int main(int argc, char **argv) { // look for alternative rc file to use if ((++i) >= 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")<<endl;; exit(1); } @@ -162,19 +166,18 @@ int main(int argc, char **argv) { // set by the environment variable DISPLAY if ((++i) >= argc) { - fprintf(stderr, - i18n.getMessage(FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, - "error: '-display' requires an argument\n")); + cerr<<_FBTEXT(main, DISPLAYRequiresArg, + "error: '-display' requires an argument", + "")<<endl; exit(1); } session_display = argv[i]; std::string display_env = "DISPLAY=" + session_display; if (putenv(const_cast<char *>(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'", + "")<<endl; perror("putenv()"); } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) { @@ -183,22 +186,23 @@ int main(int argc, char **argv) { exit(0); } else if (strcmp(argv[i], "-log") == 0 ) { if (i + 1 >= argc) { - cerr<<"error: '-log' needs an argument"<<endl; + cerr<<_FBTEXT(main, LOGRequiresArg, "error: '-log' needs an argument", "")<<endl; exit(1); } log_filename = argv[++i]; } else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) { // print program usage and command line options - printf(i18n. - getMessage(FBNLS::mainSet, FBNLS::mainUsage, - "Fluxbox %s : (c) %s Henrik Kinnunen\n" - "Website: http://www.fluxbox.org/ \n\n" - " -display <string>\t\tuse display connection.\n" - " -rc <string>\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 <filename>\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 <string>\t\tuse display connection.\n" + "\t-rc <string>\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 <filename>\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: "<<log_filename<<endl; + cerr<<_FBTEXT(main, LoggingTo, "Logging to", "Logging to a file")<<": "<<log_filename<<endl; log_file<<"------------------------------------------"<<endl; - log_file<<"Logfile: "<<log_filename<<endl; + log_file<<_FBTEXT(main, LogFile, "Log File", "")<<": "<<log_filename<<endl; showInfo(log_file); log_file<<"------------------------------------------"<<endl; // setup log to use cout and cerr stream @@ -240,19 +244,19 @@ int main(int argc, char **argv) { exitcode = EXIT_SUCCESS; } catch (std::out_of_range &oor) { - cerr<<"Fluxbox: Out of range: "<<oor.what()<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl; } catch (std::runtime_error &re) { - cerr<<"Fluxbox: Runtime error: "<<re.what()<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorRuntime, "Runtime error", "Error message")<<": "<<re.what()<<endl; } catch (std::bad_cast &bc) { - cerr<<"Fluxbox: Bad cast: "<<bc.what()<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorBadCast, "Bad cast", "Error message")<<": "<<bc.what()<<endl; } catch (std::bad_alloc &ba) { - cerr<<"Fluxbox: Bad Alloc: "<<ba.what()<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorBadAlloc, "Bad Alloc", "Error message")<<": "<<ba.what()<<endl; } catch (std::exception &e) { - cerr<<"Fluxbox: Standard exception: "<<e.what()<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorStandardException, "Standard Exception", "Error message")<<": "<<e.what()<<endl; } catch (std::string error_str) { - cerr<<"Error: "<<error_str<<endl; + cerr<<_FBTEXT(Common, Error, "Error", "Error message header")<<": "<<error_str<<endl; } catch (...) { - cerr<<"Fluxbox: Unknown error."<<endl; + cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl; abort(); } // destroy fluxbox -- cgit v0.11.2