all repos — fluxbox @ 64fcedda00205f0c0b9464967f06322d4c7afa91

custom fork of the fluxbox windowmanager

use LC_TIME for interpreting clock locale.
Fix something likely to break locales on BSDs and things without 
nl_langinfo
simonb simonb
commit

64fcedda00205f0c0b9464967f06322d4c7afa91

parent

fcc756c052c91eb582b459684017e10898322eed

4 files changed, 22 insertions(+), 5 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 1.0rc3: *07/01/05: + * Fix locale being applied to the clock. (Simon) + - Also fixed a likely locale-killer for BSDs (without nl_langinfo) + ClockTool.hh/cc FbTk/FbString.cc * Fix nls digit strings to prefix with zero "%4d" => "%04d" for proper spacing (Simon) Screen.cc nls/fluxbox-nls.hh nls/*/*.m
M src/ClockTool.ccsrc/ClockTool.cc

@@ -143,11 +143,19 @@ m_theme(theme),

m_screen(screen), m_pixmap(0), m_timeformat(screen.resourceManager(), std::string("%k:%M"), - screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat") { + screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat"), + m_stringconvertor(FbTk::StringConvertor::ToFbString) { // attach signals theme.reconfigSig().attach(this); - _FB_USES_NLS; + std::string time_locale = setlocale(LC_TIME, NULL); + size_t pos = time_locale.find('.'); + if (pos != std::string::npos) + time_locale = time_locale.substr(pos+1); + if (!time_locale.empty()) + m_stringconvertor.setSource(time_locale); + + _FB_USES_NLS; // setup timer to check the clock every 0.01 second // if nothing has changed, it wont update the graphics

@@ -256,9 +264,13 @@ return;

#ifdef HAVE_STRFTIME time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type); - if( time_string_len == 0 || m_button.text() == time_string) + if( time_string_len == 0) return; - m_button.setText(time_string); + std::string text = m_stringconvertor.recode(time_string); + if (m_button.text() == text) + return; + + m_button.setText(text); unsigned int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; if (new_width > m_button.width()) {
M src/ClockTool.hhsrc/ClockTool.hh

@@ -32,6 +32,7 @@ #include "FbTk/TextButton.hh"

#include "FbTk/Observer.hh" #include "FbTk/Resource.hh" #include "FbTk/Timer.hh" +#include "FbTk/FbString.hh" #include <string>

@@ -83,6 +84,7 @@ FbTk::Timer m_timer;

FbTk::Resource<std::string> m_timeformat; + FbTk::StringConvertor m_stringconvertor; }; #endif // CLOCKTOOL_HH
M src/FbTk/FbString.ccsrc/FbTk/FbString.cc

@@ -79,7 +79,7 @@ locale_codeset = "";

string locale = setlocale(LC_CTYPE, NULL); size_t pos = locale.find('.'); if (pos != string::npos) - locale_codeset = locale.substr(pos); + locale_codeset = locale.substr(pos+1); #endif // CODESET #ifdef DEBUG