Remove static clock tooltip buffer
Use GLib's GDateTime to generate the tooltip, so that a correctly sized string is automatically created.
This commit is contained in:
parent
edad9bb7f5
commit
441c420773
1 changed files with 7 additions and 4 deletions
|
@ -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 @@ struct tm* clock_gettime_for_tz(const char* timezone) {
|
|||
|
||||
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 @@ void init_clock_panel(void *p)
|
|||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue