1999-10-15 07:10:39 -07:00
|
|
|
#include "epplet.h"
|
1999-10-26 06:56:51 -07:00
|
|
|
Epplet_gadget b_close, label1, label2, label3, label4;
|
1999-10-15 07:10:39 -07:00
|
|
|
|
|
|
|
static void timer_cb(void *data);
|
|
|
|
static void close_cb(void *data);
|
|
|
|
static void in_cb(void *data, Window w);
|
|
|
|
static void out_cb(void *data, Window w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
timer_cb(void *data)
|
|
|
|
{
|
|
|
|
char tm[64];
|
|
|
|
struct tm tim;
|
|
|
|
struct tm *tim2;
|
|
|
|
time_t t2;
|
|
|
|
|
|
|
|
t2 = time(NULL);
|
|
|
|
tim2 = localtime(&t2);
|
|
|
|
if (tim2)
|
|
|
|
{
|
|
|
|
memcpy(&tim, tim2, sizeof(struct tm));
|
1999-11-08 10:37:49 -08:00
|
|
|
strftime(tm, 63, "%A", &tim);
|
1999-10-15 07:10:39 -07:00
|
|
|
Epplet_change_label(label1, tm);
|
1999-11-08 10:37:49 -08:00
|
|
|
strftime(tm, 63, "%e %b", &tim);
|
1999-10-15 07:10:39 -07:00
|
|
|
Epplet_change_label(label2, tm);
|
|
|
|
strftime(tm, 63, "%H:%M:%S", &tim);
|
|
|
|
Epplet_change_label(label3, tm);
|
1999-10-26 06:56:51 -07:00
|
|
|
strftime(tm, 63, "%Z %Y", &tim);
|
|
|
|
Epplet_change_label(label4, tm);
|
1999-10-15 07:10:39 -07:00
|
|
|
}
|
|
|
|
Epplet_timer(timer_cb, NULL, 0.5, "TIMER");
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
close_cb(void *data)
|
|
|
|
{
|
|
|
|
Epplet_unremember();
|
|
|
|
Esync();
|
1999-10-22 09:43:22 -07:00
|
|
|
Epplet_cleanup();
|
|
|
|
data = NULL;
|
1999-10-15 07:10:39 -07:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
in_cb(void *data, Window w)
|
|
|
|
{
|
|
|
|
Epplet_gadget_show(b_close);
|
1999-10-22 16:45:57 -07:00
|
|
|
return;
|
|
|
|
data = NULL;
|
|
|
|
w = (Window) 0;
|
1999-10-15 07:10:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
out_cb(void *data, Window w)
|
|
|
|
{
|
|
|
|
Epplet_gadget_hide(b_close);
|
1999-10-22 16:45:57 -07:00
|
|
|
return;
|
|
|
|
data = NULL;
|
|
|
|
w = (Window) 0;
|
1999-10-15 07:10:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
Epplet_Init("E-Time", "0.1", "Enlightenment Digital Clock Epplet",
|
1999-10-22 15:09:18 -07:00
|
|
|
3, 3, argc, argv, 0);
|
1999-10-15 07:10:39 -07:00
|
|
|
b_close = Epplet_create_button(NULL, NULL,
|
1999-10-26 08:48:35 -07:00
|
|
|
2, 2, 0, 0, "CLOSE", 0, NULL,
|
1999-10-15 07:10:39 -07:00
|
|
|
close_cb, NULL);
|
1999-10-26 08:48:35 -07:00
|
|
|
Epplet_gadget_show(label1 = Epplet_create_label(-4, 4, "", 1));
|
|
|
|
Epplet_gadget_show(label2 = Epplet_create_label(-4, 15, "", 1));
|
|
|
|
Epplet_gadget_show(label3 = Epplet_create_label(-4, 26, "", 1));
|
|
|
|
Epplet_gadget_show(label4 = Epplet_create_label(-4, 36, "", 1));
|
1999-10-15 07:10:39 -07:00
|
|
|
Epplet_register_focus_in_handler(in_cb, NULL);
|
|
|
|
Epplet_register_focus_out_handler(out_cb, NULL);
|
|
|
|
|
|
|
|
Epplet_show();
|
|
|
|
timer_cb(NULL);
|
|
|
|
Epplet_Loop();
|
|
|
|
return 0;
|
|
|
|
}
|