aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-21 20:09:03 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:57:23 (GMT)
commite6afa5d348cd8e1763615bebf6bbb42221082060 (patch)
tree9ff2788b4f6d4413cc6d515082327c6dc72403ff
parent2e4111c75bbeb7e566d3742e16efc93ffa5eab87 (diff)
downloadfluxbox_pavel-e6afa5d348cd8e1763615bebf6bbb42221082060.zip
fluxbox_pavel-e6afa5d348cd8e1763615bebf6bbb42221082060.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 126e0dd..6252248 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -102,13 +102,13 @@ public:
102 102
103 void click(int button, int time, unsigned int mods) { 103 void click(int button, int time, unsigned int mods) {
104 104
105 std::string newformat = *m_tool.timeFormatResource();
105 // does the current format string contain something with 24/12h? 106 // does the current format string contain something with 24/12h?
106 size_t found; 107 size_t found;
107 size_t pos = FbTk::StringUtil::findCharFromAlphabetAfterTrigger( 108 size_t pos = FbTk::StringUtil::findCharFromAlphabetAfterTrigger(
108 m_tool.timeFormat(), '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found); 109 newformat, '%', SWITCHES_24_12H, sizeof(SWITCHES_24_12H), &found);
109 110
110 if (pos != std::string::npos) { // if so, exchange it with 12/24h 111 if (pos != std::string::npos) { // if so, exchange it with 12/24h
111 std::string newformat = m_tool.timeFormat();
112 newformat[pos+1] = SWITCHES_12_24H[found]; 112 newformat[pos+1] = SWITCHES_12_24H[found];
113 113
114 if (found < 3) { // 24h? erase %P/%p (AM|PM / am|pm) 114 if (found < 3) { // 24h? erase %P/%p (AM|PM / am|pm)
@@ -119,7 +119,7 @@ public:
119 } 119 }
120 } 120 }
121 121
122 m_tool.setTimeFormat(newformat); 122 *m_tool.timeFormatResource() = newformat;
123 setClockModeLabel(); 123 setClockModeLabel();
124 124
125 } // else some other strange format...so we don't do anything 125 } // else some other strange format...so we don't do anything
@@ -130,7 +130,7 @@ private:
130 void setClockModeLabel() { 130 void setClockModeLabel() {
131 _FB_USES_NLS; 131 _FB_USES_NLS;
132 if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger( 132 if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger(
133 m_tool.timeFormat(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { 133 *m_tool.timeFormatResource(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) {
134 setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); 134 setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") );
135 } else { 135 } else {
136 setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); 136 setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") );
@@ -170,6 +170,8 @@ ClockTool::ClockTool(const FbTk::FbWindow &parent,
170 m_stringconvertor(FbTk::StringConvertor::ToFbString) { 170 m_stringconvertor(FbTk::StringConvertor::ToFbString) {
171 // attach signals 171 // attach signals
172 m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured)); 172 m_tracker.join(theme.reconfigSig(), FbTk::MemFun(*this, &ClockTool::themeReconfigured));
173 m_tracker.join(m_timeformat.modifiedSig(),
174 FbTk::MemFunIgnoreArgs(*this, &ClockTool::themeReconfigured));
173 175
174 std::string time_locale = setlocale(LC_TIME, NULL); 176 std::string time_locale = setlocale(LC_TIME, NULL);
175 size_t pos = time_locale.find('.'); 177 size_t pos = time_locale.find('.');
@@ -232,11 +234,6 @@ void ClockTool::hide() {
232 m_button.hide(); 234 m_button.hide();
233} 235}
234 236
235void ClockTool::setTimeFormat(const std::string &format) {
236 *m_timeformat = format;
237 themeReconfigured();
238}
239
240void ClockTool::themeReconfigured() { 237void ClockTool::themeReconfigured() {
241 updateTime(); 238 updateTime();
242 239
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