all repos — tint2 @ 441c42077323c084542698367e73645fa11d76f4

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Remove static clock tooltip buffer

Use GLib's GDateTime to generate the tooltip, so that a
correctly sized string is automatically created.
Sebastian Reichel sre@ring0.de
commit

441c42077323c084542698367e73645fa11d76f4

parent

edad9bb7f59c500aac4fd748647993fa31ba8f2c

1 files changed, 7 insertions(+), 4 deletions(-)

jump to
M src/clock/clock.csrc/clock/clock.c

@@ -48,7 +48,6 @@ PangoFontDescription *time1_font_desc;

PangoFontDescription *time2_font_desc; static char buf_time[256]; static char buf_date[256]; -static char buf_tooltip[512]; int clock_enabled; static timeout* clock_timeout;

@@ -146,8 +145,13 @@ }

char* clock_get_tooltip(void* obj) { - strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); - return strdup(buf_tooltip); + GTimeZone *tz = g_time_zone_new(time_tooltip_timezone); + GDateTime *now = g_date_time_new_now(tz); + char *result = g_date_time_format(now, time_tooltip_format); + g_date_time_unref(now); + g_time_zone_unref(tz); + + return result; } int time_format_needs_sec_ticks(char *time_format)

@@ -197,7 +201,6 @@ clock->area.on_screen = 1;

if (time_tooltip_format) { clock->area._get_tooltip_text = clock_get_tooltip; - strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone)); } }