]> Dogcows Code - chaz/tint2/blobdiff - src/clock/clock.c
fix clock to update even if it is on line two
[chaz/tint2] / src / clock / clock.c
index 6ce24b8d18194ea5712dc2153ccddac44e69918e..6212dc12dde23407ed8ddc8035c960000adf5684 100644 (file)
@@ -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);
 }
 
 
@@ -129,8 +130,9 @@ const char* clock_get_tooltip(void* obj)
 
 void init_clock()
 {
-       if(time1_format && clock_timeout==0) {
-               if (strchr(time1_format, 'S') || strchr(time1_format, 'T') || strchr(time1_format, 'r'))
+       if((time1_format || time2_format) && clock_timeout==0) {
+               if (strchr(time1_format, 'S') || strchr(time1_format, 'T') || strchr(time1_format, 'r') ||
+                   strchr(time2_format, 'S') || strchr(time2_format, 'T') || strchr(time2_format, 'r'))
                        clock_timeout = add_timeout(10, 1000, update_clocks_sec, 0);
                else
                        clock_timeout = add_timeout(10, 1000, update_clocks_min, 0);
@@ -142,7 +144,9 @@ 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;
@@ -220,8 +224,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 +237,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;
                }
This page took 0.022991 seconds and 4 git commands to generate.