use LC_TIME for interpreting clock locale.
Fix something likely to break locales on BSDs and things without nl_langinfo
This commit is contained in:
parent
fcc756c052
commit
64fcedda00
4 changed files with 22 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -143,11 +143,19 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
|
|||
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 @@ void ClockTool::updateTime() {
|
|||
|
||||
#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()) {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "FbTk/Observer.hh"
|
||||
#include "FbTk/Resource.hh"
|
||||
#include "FbTk/Timer.hh"
|
||||
#include "FbTk/FbString.hh"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -83,6 +84,7 @@ private:
|
|||
|
||||
FbTk::Resource<std::string> m_timeformat;
|
||||
|
||||
FbTk::StringConvertor m_stringconvertor;
|
||||
};
|
||||
|
||||
#endif // CLOCKTOOL_HH
|
||||
|
|
|
@ -79,7 +79,7 @@ void init() {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue