aboutsummaryrefslogtreecommitdiff
path: root/src/ClockTool.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2007-01-05 16:10:56 (GMT)
committersimonb <simonb>2007-01-05 16:10:56 (GMT)
commit64fcedda00205f0c0b9464967f06322d4c7afa91 (patch)
tree4b0bbde89c7d1b11e16059632e8dd8eaba99b039 /src/ClockTool.cc
parentfcc756c052c91eb582b459684017e10898322eed (diff)
downloadfluxbox-64fcedda00205f0c0b9464967f06322d4c7afa91.zip
fluxbox-64fcedda00205f0c0b9464967f06322d4c7afa91.tar.bz2
use LC_TIME for interpreting clock locale.
Fix something likely to break locales on BSDs and things without nl_langinfo
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r--src/ClockTool.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 7385a98..6e06ed6 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -143,11 +143,19 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
143 m_screen(screen), 143 m_screen(screen),
144 m_pixmap(0), 144 m_pixmap(0),
145 m_timeformat(screen.resourceManager(), std::string("%k:%M"), 145 m_timeformat(screen.resourceManager(), std::string("%k:%M"),
146 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat") { 146 screen.name() + ".strftimeFormat", screen.altName() + ".StrftimeFormat"),
147 m_stringconvertor(FbTk::StringConvertor::ToFbString) {
147 // attach signals 148 // attach signals
148 theme.reconfigSig().attach(this); 149 theme.reconfigSig().attach(this);
149 150
150 _FB_USES_NLS; 151 std::string time_locale = setlocale(LC_TIME, NULL);
152 size_t pos = time_locale.find('.');
153 if (pos != std::string::npos)
154 time_locale = time_locale.substr(pos+1);
155 if (!time_locale.empty())
156 m_stringconvertor.setSource(time_locale);
157
158 _FB_USES_NLS;
151 159
152 // setup timer to check the clock every 0.01 second 160 // setup timer to check the clock every 0.01 second
153 // if nothing has changed, it wont update the graphics 161 // if nothing has changed, it wont update the graphics
@@ -256,9 +264,13 @@ void ClockTool::updateTime() {
256 264
257#ifdef HAVE_STRFTIME 265#ifdef HAVE_STRFTIME
258 time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type); 266 time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type);
259 if( time_string_len == 0 || m_button.text() == time_string) 267 if( time_string_len == 0)
268 return;
269 std::string text = m_stringconvertor.recode(time_string);
270 if (m_button.text() == text)
260 return; 271 return;
261 m_button.setText(time_string); 272
273 m_button.setText(text);
262 274
263 unsigned int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; 275 unsigned int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2;
264 if (new_width > m_button.width()) { 276 if (new_width > m_button.width()) {