diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-21 20:09:03 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-18 21:04:24 (GMT) |
commit | 99c90fa4a55138a943d9cdf18b1cc0d0df0414a9 (patch) | |
tree | 50c3504ddd78fd00b510a54f3671c4ee5282c2a3 /src/ClockTool.cc | |
parent | fb0235c51656bf834ec1bc91b0e012321e676d71 (diff) | |
download | fluxbox_pavel-99c90fa4a55138a943d9cdf18b1cc0d0df0414a9.zip fluxbox_pavel-99c90fa4a55138a943d9cdf18b1cc0d0df0414a9.tar.bz2 |
Attach modifiedSig handlers to the session.screenX.strftimeFormat resource
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r-- | src/ClockTool.cc | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 5d6af9b..cbb7f80 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc | |||
@@ -94,13 +94,13 @@ public: | |||
94 | 94 | ||
95 | void click(int button, int time, unsigned int mods) { | 95 | void click(int button, int time, unsigned int mods) { |
96 | 96 | ||
97 | std::string newformat = *m_tool.timeFormatResource(); | ||
97 | // does the current format string contain something with 24/12h? | 98 | // does the current format string contain something with 24/12h? |
98 | size_t found; | 99 | size_t found; |
99 | size_t pos = FbTk::StringUtil::findCharFromAlphabetAfterTrigger( | 100 | size_t pos = FbTk::StringUtil::findCharFromAlphabetAfterTrigger( |
100 | m_tool.timeFormat(), '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found); | 101 | newformat, '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found); |
101 | 102 | ||
102 | if (pos != std::string::npos) { // if so, exchange it with 12/24h | 103 | if (pos != std::string::npos) { // if so, exchange it with 12/24h |
103 | std::string newformat = m_tool.timeFormat(); | ||
104 | newformat[pos+1] = SWITCHES_12_24H[found]; | 104 | newformat[pos+1] = SWITCHES_12_24H[found]; |
105 | 105 | ||
106 | if (found < 3) { // 24h? erase %P/%p (AM|PM / am|pm) | 106 | if (found < 3) { // 24h? erase %P/%p (AM|PM / am|pm) |
@@ -111,7 +111,7 @@ public: | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | m_tool.setTimeFormat(newformat); | 114 | *m_tool.timeFormatResource() = newformat; |
115 | setClockModeLabel(); | 115 | setClockModeLabel(); |
116 | 116 | ||
117 | } // else some other strange format...so we don't do anything | 117 | } // else some other strange format...so we don't do anything |
@@ -122,7 +122,7 @@ private: | |||
122 | void setClockModeLabel() { | 122 | void setClockModeLabel() { |
123 | _FB_USES_NLS; | 123 | _FB_USES_NLS; |
124 | if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger( | 124 | if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger( |
125 | m_tool.timeFormat(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { | 125 | *m_tool.timeFormatResource(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { |
126 | setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); | 126 | setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); |
127 | } else { | 127 | } else { |
128 | setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); | 128 | setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); |
@@ -162,6 +162,8 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent, | |||
162 | m_stringconvertor(FbTk::StringConvertor::ToFbString) { | 162 | m_stringconvertor(FbTk::StringConvertor::ToFbString) { |
163 | // attach signals | 163 | // attach signals |
164 | m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured)); | 164 | m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured)); |
165 | m_tracker.join(m_timeformat.modifiedSig(), | ||
166 | FbTk::MemFunIgnoreArgs(*this, &ClockTool::themeReconfigured)); | ||
165 | 167 | ||
166 | std::string time_locale = setlocale(LC_TIME, NULL); | 168 | std::string time_locale = setlocale(LC_TIME, NULL); |
167 | size_t pos = time_locale.find('.'); | 169 | size_t pos = time_locale.find('.'); |
@@ -224,11 +226,6 @@ void ClockTool::hide() { | |||
224 | m_button.hide(); | 226 | m_button.hide(); |
225 | } | 227 | } |
226 | 228 | ||
227 | void ClockTool::setTimeFormat(const std::string &format) { | ||
228 | *m_timeformat = format; | ||
229 | themeReconfigured(); | ||
230 | } | ||
231 | |||
232 | void ClockTool::themeReconfigured() { | 229 | void ClockTool::themeReconfigured() { |
233 | updateTime(); | 230 | updateTime(); |
234 | 231 | ||