*add* changed everything to kernel timer for easier integration with new timer

*todo* adapt tooltip also to the timer syntax
*fix* memory leak



git-svn-id: http://tint2.googlecode.com/svn/trunk@266 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85
2009-11-15 16:55:50 +00:00
parent 429660abb6
commit 806451955b
9 changed files with 113 additions and 87 deletions

View File

@@ -30,6 +30,7 @@
#include "panel.h"
#include "taskbar.h"
#include "clock.h"
#include "timer.h"
char *time1_format=0;
@@ -37,7 +38,6 @@ char *time2_format=0;
char *clock_lclick_command=0;
char *clock_rclick_command=0;
struct timeval time_clock;
int time_precision;
PangoFontDescription *time1_font_desc=0;
PangoFontDescription *time2_font_desc=0;
static char buf_time[40];
@@ -45,25 +45,25 @@ static char buf_date[40];
int clock_enabled;
void init_precision()
void update_clocks()
{
if (!time1_format) time_precision = 60;
else if (strchr(time1_format, 'S')) time_precision = 1;
else if (strchr(time1_format, 'T')) time_precision = 1;
else if (strchr(time1_format, 'r')) time_precision = 1;
else time_precision = 60;
gettimeofday(&time_clock, 0);
int i;
if (time1_format) {
for (i=0 ; i < nb_panel ; i++)
panel1[i].clock.area.resize = 1;
}
panel_refresh = 1;
}
void init_clock()
{
init_precision();
// update clock to force update (-time_precision)
struct timeval stv;
gettimeofday(&stv, 0);
time_clock.tv_sec = stv.tv_sec - time_precision;
time_clock.tv_sec -= time_clock.tv_sec % time_precision;
if(time1_format) {
if (strchr(time1_format, 'S') || strchr(time1_format, 'T') || strchr(time1_format, 'r'))
install_timer(0, 1000000, 1, 0, update_clocks);
else install_timer(0, 1000000, 60, 0, update_clocks);
}
}

View File

@@ -26,8 +26,6 @@ typedef struct Clock {
extern char *time1_format;
extern char *time2_format;
extern struct timeval time_clock;
extern int time_precision;
extern PangoFontDescription *time1_font_desc;
extern PangoFontDescription *time2_font_desc;
extern char *clock_lclick_command;
@@ -38,7 +36,6 @@ extern int clock_enabled;
// initialize clock : y position, precision, ...
void init_clock();
void init_clock_panel(void *panel);
void init_precision();
void cleanup_clock();
void draw_clock (void *obj, cairo_t *c, int active);