mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Let tooltip shows a date
This commit is contained in:
parent
6de400ed8b
commit
83a14d9a27
@ -13,9 +13,13 @@ static void clock_refresh(void *o);
|
|||||||
|
|
||||||
class Clock : public Fl_Box {
|
class Clock : public Fl_Box {
|
||||||
private:
|
private:
|
||||||
char buf[64];
|
int hour;
|
||||||
|
char buf[64], tbuf[256];
|
||||||
|
|
||||||
|
time_t curr_time;
|
||||||
|
struct tm *curr_tm;
|
||||||
public:
|
public:
|
||||||
Clock() : Fl_Box(450, 0, 80, 25, NULL) {
|
Clock() : Fl_Box(450, 0, 80, 25, NULL), hour(0) {
|
||||||
box(FL_FLAT_BOX);
|
box(FL_FLAT_BOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,16 +39,20 @@ static void clock_refresh(void *o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Clock::update_time(void) {
|
void Clock::update_time(void) {
|
||||||
time_t t;
|
curr_time = time(NULL);
|
||||||
struct tm *tmp;
|
curr_tm = localtime(&curr_time);
|
||||||
|
if(!curr_tm)
|
||||||
t = time(NULL);
|
|
||||||
tmp = localtime(&t);
|
|
||||||
if(!tmp)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strftime(buf, sizeof(buf), "%H:%M:%S", tmp);
|
strftime(buf, sizeof(buf), "%H:%M:%S", curr_tm);
|
||||||
label(buf);
|
label(buf);
|
||||||
|
|
||||||
|
/* update tooltip if needed */
|
||||||
|
if(curr_tm->tm_hour != hour) {
|
||||||
|
hour = curr_tm->tm_hour;
|
||||||
|
strftime(tbuf, sizeof(tbuf), "%d %B %Y", curr_tm);
|
||||||
|
tooltip(tbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Clock::handle(int e) {
|
int Clock::handle(int e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user