all repos — fluxbox @ a211ca912da6e17cfeee8a8fdde9d4eeff7c51a7

custom fork of the fluxbox windowmanager

grow the clock if the text gets too big
simonb simonb
commit

a211ca912da6e17cfeee8a8fdde9d4eeff7c51a7

parent

9ff23f01ca0a0a6c83a3a5e5d933fffbb59dfab8

2 files changed, 12 insertions(+), 1 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.16: *06/04/17: + * Resize the clock if the text gets too big, sf.net patch #1436406 + (thanks Geoff Lywood - glywood at users.sourceforge.net) + ClockTool.cc * Fix some rotated toolbar+textbutton issues (Simon) Toolbar.cc IconbarTool.cc FbTk/TextButton.cc * Fix /bin/sh portability for fbsetbg and startfluxbox (Simon)
M src/ClockTool.ccsrc/ClockTool.cc

@@ -249,14 +249,22 @@ time_t the_time = time(0);

if (the_time != -1) { char time_string[255]; + int time_string_len; struct tm *time_type = localtime(&the_time); if (time_type == 0) return; #ifdef HAVE_STRFTIME - if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string) + time_string_len = strftime(time_string, 255, m_timeformat->c_str(), time_type); + if( time_string_len == 0 || m_button.text() == time_string) return; m_button.setText(time_string); + + int new_width = m_theme.font().textWidth(time_string, time_string_len) + 2; + if (new_width > m_button.width()) { + resize(new_width, m_button.height()); + resizeSig().notify(); + } #else // dont have strftime so we have to set it to hour:minut // sprintf(time_string, "%d:%d", ); #endif // HAVE_STRFTIME