aboutsummaryrefslogtreecommitdiff
path: root/src
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
parentfcc756c052c91eb582b459684017e10898322eed (diff)
downloadfluxbox_paul-64fcedda00205f0c0b9464967f06322d4c7afa91.zip
fluxbox_paul-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')
-rw-r--r--src/ClockTool.cc20
-rw-r--r--src/ClockTool.hh2
-rw-r--r--src/FbTk/FbString.cc2
3 files changed, 19 insertions, 5 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()) {
diff --git a/src/ClockTool.hh b/src/ClockTool.hh
index d55bf5f..7e29bd5 100644
--- a/src/ClockTool.hh
+++ b/src/ClockTool.hh
@@ -32,6 +32,7 @@
32#include "FbTk/Observer.hh" 32#include "FbTk/Observer.hh"
33#include "FbTk/Resource.hh" 33#include "FbTk/Resource.hh"
34#include "FbTk/Timer.hh" 34#include "FbTk/Timer.hh"
35#include "FbTk/FbString.hh"
35 36
36#include <string> 37#include <string>
37 38
@@ -83,6 +84,7 @@ private:
83 84
84 FbTk::Resource<std::string> m_timeformat; 85 FbTk::Resource<std::string> m_timeformat;
85 86
87 FbTk::StringConvertor m_stringconvertor;
86}; 88};
87 89
88#endif // CLOCKTOOL_HH 90#endif // CLOCKTOOL_HH
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc
index c767a30..6614ec4 100644
--- a/src/FbTk/FbString.cc
+++ b/src/FbTk/FbString.cc
@@ -79,7 +79,7 @@ void init() {
79 string locale = setlocale(LC_CTYPE, NULL); 79 string locale = setlocale(LC_CTYPE, NULL);
80 size_t pos = locale.find('.'); 80 size_t pos = locale.find('.');
81 if (pos != string::npos) 81 if (pos != string::npos)
82 locale_codeset = locale.substr(pos); 82 locale_codeset = locale.substr(pos+1);
83#endif // CODESET 83#endif // CODESET
84 84
85#ifdef DEBUG 85#ifdef DEBUG