summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ClockTool.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 8a5077b..851973c 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -249,14 +249,22 @@ void ClockTool::updateTime() {
249 249
250 if (the_time != -1) { 250 if (the_time != -1) {
251 char time_string[255]; 251 char time_string[255];
252 int time_string_len;
252 struct tm *time_type = localtime(&the_time); 253 struct tm *time_type = localtime(&the_time);
253 if (time_type == 0) 254 if (time_type == 0)
254 return; 255 return;
255 256
256#ifdef HAVE_STRFTIME 257#ifdef HAVE_STRFTIME
257 if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string) 258 time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type);
259 if( time_string_len == 0 || m_button.text() == time_string)
258 return; 260 return;
259 m_button.setText(time_string); 261 m_button.setText(time_string);
262
263 int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2;
264 if (new_width > m_button.width()) {
265 resize(new_width, m_button.height());
266 resizeSig().notify();
267 }
260#else // dont have strftime so we have to set it to hour:minut 268#else // dont have strftime so we have to set it to hour:minut
261 // sprintf(time_string, "%d:%d", ); 269 // sprintf(time_string, "%d:%d", );
262#endif // HAVE_STRFTIME 270#endif // HAVE_STRFTIME