aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2014-05-12 10:27:46 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2014-05-12 10:27:46 (GMT)
commit6700eb354fee98492d1b17b927b76749242bf9b9 (patch)
tree6adcf6d02d2b9eef330e4241fc9cba7e99769e40 /src
parent948e63eb600e173815a9ddedd2951db56fe51611 (diff)
downloadfluxbox-6700eb354fee98492d1b17b927b76749242bf9b9.zip
fluxbox-6700eb354fee98492d1b17b927b76749242bf9b9.tar.bz2
cosmetic, less code
Diffstat (limited to 'src')
-rw-r--r--src/ClockTool.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index f11a793..f2a7333 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -216,16 +216,16 @@ void ClockTool::setTimeFormat(const std::string &format) {
216 216
217void ClockTool::themeReconfigured() { 217void ClockTool::themeReconfigured() {
218 218
219 // + 2 to make the entire text fit inside 219 // we replace only numbers with zeros because everything else should be
220 // we only replace numbers with zeros because everything else should be 220 // relatively static. if we replace all text with zeros then widths of
221 // relatively static. If we replace all text with zeros then widths of
222
223 // proportional fonts with some strftime formats will be considerably off. 221 // proportional fonts with some strftime formats will be considerably off.
222
224 const FbTk::FbString& t = m_button.text().logical(); 223 const FbTk::FbString& t = m_button.text().logical();
225 size_t s = t.size() + 2; 224 const size_t s = t.size();
226 FbTk::FbString text(s, '0'); 225 size_t i;
226 FbTk::FbString text(s + 2, '0'); // +2 for extra padding
227 227
228 for (size_t i = 0; i < (s - 2); ++i) { 228 for (i = 0; i < s; ++i) {
229 if (!isdigit(t[i])) 229 if (!isdigit(t[i]))
230 text[i] = t[i]; 230 text[i] = t[i];
231 } 231 }
@@ -233,7 +233,7 @@ void ClockTool::themeReconfigured() {
233 unsigned int new_width = m_button.width(); 233 unsigned int new_width = m_button.width();
234 unsigned int new_height = m_button.height(); 234 unsigned int new_height = m_button.height();
235 translateSize(orientation(), new_width, new_height); 235 translateSize(orientation(), new_width, new_height);
236 new_width = m_theme->font().textWidth(text.c_str(), s); 236 new_width = m_theme->font().textWidth(text.c_str(), text.size());
237 translateSize(orientation(), new_width, new_height); 237 translateSize(orientation(), new_width, new_height);
238 if (new_width != m_button.width() || new_height != m_button.height()) { 238 if (new_width != m_button.width() || new_height != m_button.height()) {
239 resize(new_width, new_height); 239 resize(new_width, new_height);
@@ -286,8 +286,9 @@ void ClockTool::updateTime() {
286 goto restart_timer; 286 goto restart_timer;
287 287
288 text = m_stringconvertor.recode(buf); 288 text = m_stringconvertor.recode(buf);
289 if (m_button.text().logical() == text) 289 if (m_button.text().logical() == text) {
290 goto restart_timer; 290 goto restart_timer;
291 }
291 292
292#else // dont have strftime so we have to set it to hour:minut 293#else // dont have strftime so we have to set it to hour:minut
293 // sprintf(time_string, "%d:%d", ); 294 // sprintf(time_string, "%d:%d", );