X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclock%2Fclock.c;h=73547d155dc21318c1a458d16e167eef05f8e1c5;hb=694d127008b23ab2296d305a218d491c931ff26e;hp=55e5e456285b59b019dc8f9d4460a22c3e2c05e5;hpb=bbec33ce1a15b555a737f2fefe7bdfb6a8881705;p=chaz%2Ftint2 diff --git a/src/clock/clock.c b/src/clock/clock.c index 55e5e45..73547d1 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -2,7 +2,7 @@ * * Tint2 : clock * -* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) +* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr) from Omega distribution * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -43,9 +43,9 @@ char *clock_rclick_command; struct timeval time_clock; PangoFontDescription *time1_font_desc; PangoFontDescription *time2_font_desc; -static char buf_time[40]; -static char buf_date[40]; -static char buf_tooltip[40]; +static char buf_time[256]; +static char buf_date[256]; +static char buf_tooltip[512]; int clock_enabled; static timeout* clock_timeout; @@ -78,6 +78,7 @@ void cleanup_clock() if (time_tooltip_timezone) g_free(time_tooltip_timezone); if (clock_lclick_command) g_free(clock_lclick_command); if (clock_rclick_command) g_free(clock_rclick_command); + if (clock_timeout) stop_timeout(clock_timeout); } @@ -142,18 +143,19 @@ void init_clock_panel(void *p) { Panel *panel =(Panel*)p; Clock *clock = &panel->clock; - + + if (clock->area.bg == 0) + clock->area.bg = &g_array_index(backgrounds, Background, 0); clock->area.parent = p; clock->area.panel = p; clock->area._draw_foreground = draw_clock; clock->area.size_mode = SIZE_BY_CONTENT; clock->area._resize = resize_clock; - clock->area.resize = 1; - clock->area.redraw = 1; // check consistency if (time1_format == 0) return; + clock->area.resize = 1; clock->area.on_screen = 1; if (time_tooltip_format) { @@ -205,13 +207,14 @@ int resize_clock (void *obj) clock->area.redraw = 1; + date_height = date_width = 0; strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); get_text_size2(time1_font_desc, &time_height_ink, &time_height, &time_width, panel->area.height, panel->area.width, buf_time, strlen(buf_time)); if (time2_format) { strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); get_text_size2(time2_font_desc, &date_height_ink, &date_height, &date_width, panel->area.height, panel->area.width, buf_date, strlen(buf_date)); } - + if (panel_horizontal) { int new_size = (time_width > date_width) ? time_width : date_width; new_size += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width); @@ -220,8 +223,8 @@ int resize_clock (void *obj) clock->area.width = new_size + 1; clock->time1_posy = (clock->area.height - time_height) / 2; if (time2_format) { - clock->time1_posy -= ((date_height_ink + 2) / 2); - clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2; + clock->time1_posy -= (date_height)/2; + clock->time2_posy = clock->time1_posy + time_height; } ret = 1; } @@ -233,8 +236,8 @@ int resize_clock (void *obj) clock->area.height = new_size; clock->time1_posy = (clock->area.height - time_height) / 2; if (time2_format) { - clock->time1_posy -= ((date_height_ink + 2) / 2); - clock->time2_posy = clock->time1_posy + time_height + 2 - (time_height - time_height_ink)/2 - (date_height - date_height_ink)/2; + clock->time1_posy -= (date_height)/2; + clock->time2_posy = clock->time1_posy + time_height; } ret = 1; }