aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-21 20:09:03 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-18 21:04:24 (GMT)
commit99c90fa4a55138a943d9cdf18b1cc0d0df0414a9 (patch)
tree50c3504ddd78fd00b510a54f3671c4ee5282c2a3
parentfb0235c51656bf834ec1bc91b0e012321e676d71 (diff)
downloadfluxbox_pavel-99c90fa4a55138a943d9cdf18b1cc0d0df0414a9.zip
fluxbox_pavel-99c90fa4a55138a943d9cdf18b1cc0d0df0414a9.tar.bz2
Attach modifiedSig handlers to the session.screenX.strftimeFormat resource
-rw-r--r--src/ClockTool.cc15
-rw-r--r--src/ClockTool.hh3
2 files changed, 7 insertions, 11 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
227void ClockTool::setTimeFormat(const std::string &format) {
228 *m_timeformat = format;
229 themeReconfigured();
230}
231
232void ClockTool::themeReconfigured() { 229void ClockTool::themeReconfigured() {
233 updateTime(); 230 updateTime();
234 231
diff --git a/src/ClockTool.hh b/src/ClockTool.hh
index 80dde97..8fb6f7f 100644
--- a/src/ClockTool.hh
+++ b/src/ClockTool.hh
@@ -54,12 +54,11 @@ public:
54 54
55 void show(); 55 void show();
56 void hide(); 56 void hide();
57 void setTimeFormat(const std::string &format);
58 // accessors 57 // accessors
59 unsigned int width() const; 58 unsigned int width() const;
60 unsigned int height() const; 59 unsigned int height() const;
61 unsigned int borderWidth() const; 60 unsigned int borderWidth() const;
62 const std::string &timeFormat() const { return *m_timeformat; } 61 FbTk::StringResource &timeFormatResource() { return m_timeformat; }
63 62
64 void setOrientation(FbTk::Orientation orient); 63 void setOrientation(FbTk::Orientation orient);
65 64