thar be clock theme fun... in e17.

warning: new strings for intl due to having to make date a config
option.



SVN revision: 79130
This commit is contained in:
Carsten Haitzler 2012-11-12 04:32:59 +00:00
parent dba1bff12e
commit e34a70334f
19 changed files with 522 additions and 29 deletions

View File

@ -146,6 +146,19 @@ img/clock_ss7.png \
img/clock_ss.png \
img/darken_rounded_square.png \
img/diagonal_stripes.png \
img/digit_0.png \
img/digit_1.png \
img/digit_2.png \
img/digit_3.png \
img/digit_4.png \
img/digit_5.png \
img/digit_6.png \
img/digit_7.png \
img/digit_8.png \
img/digit_9.png \
img/digit_am.png \
img/digit_na.png \
img/digit_pm.png \
img/dot_pattern.png \
img/downlight_glow.png \
img/eth.png \

View File

@ -43,7 +43,7 @@ collections {
#include "edc/O/battery.edc"
#include "edc/O/border.edc"
#include "edc/O/border_icons.edc"
#include "edc/O/clock.edc"
//#include "edc/O/clock.edc"
#include "edc/O/colors.edc"
#include "edc/O/conf_gad.edc"
#include "edc/O/cpufreq.edc"

View File

@ -1,9 +1,447 @@
#if 0
group { name: "e/modules/clock/digital";
}
#endif
min: 64 16;
max: 512 128;
images.image: "digit_na.png" COMP;
images.image: "digit_0.png" COMP;
images.image: "digit_1.png" COMP;
images.image: "digit_2.png" COMP;
images.image: "digit_3.png" COMP;
images.image: "digit_4.png" COMP;
images.image: "digit_5.png" COMP;
images.image: "digit_6.png" COMP;
images.image: "digit_7.png" COMP;
images.image: "digit_8.png" COMP;
images.image: "digit_9.png" COMP;
images.image: "digit_am.png" COMP;
images.image: "digit_pm.png" COMP;
images.image: "hole_tiny.png" COMP;
script {
public do_seconds, do_24h, do_date;
new tick_timer;
valset(id, v) {
if ((v >= 0) && (v <= 9)) {
new buf[20];
snprintf(buf, 20, "%i", v);
set_state(id, buf, 0.0);
} else {
set_state(id, "default", 0.0);
}
}
apvalset(id, pm) {
if (pm) set_state(id, "active", 0.0);
else set_state(id, "default", 0.0);
}
evalsize() {
new do24h, dosec, v[14], i, tot, mul;
new parts[] = {
PART:"hours1", PART:"hours1",
PART:"hours2", PART:"hours2",
PART:"mins1", PART:"mins1",
PART:"mins2", PART:"mins2",
PART:"secs1", PART:"secs1",
PART:"secs2", PART:"secs2",
PART:"ampm", PART:"ampm"
};
mul = 4;
if (get_int(do_date)) {
mul = 3;
}
for (i = 0; i < 14; i += 2) {
custom_state(parts[i], "default", 0.0);
}
v[0] = 0; v[1] = 2; v[2] = 2; v[3] = 4; // hrs
v[4] = 5; v[5] = 7; v[6] = 7; v[7] = 9; // mins
tot = 9;
dosec = get_int(do_seconds);
do24h = get_int(do_24h);
if ((dosec) && (!do24h)) { // sec + ampm
tot += 7;
v[8] = 10; v[9] = 12; v[10] = 12; v[11] = 14;
v[12] = 14; v[13] = 16;
}
else if ((dosec) && (do24h)) { // sec + -
tot += 5;
v[8] = 10; v[9] = 12; v[10] = 12; v[11] = 14;
v[12] = 0; v[13] = 0;
}
else if ((!dosec) && (!do24h)) { // - + ampm
tot += 2;
v[8] = 0; v[9] = 0; v[10] = 0; v[11] = 0;
v[12] = 9; v[13] = 11;
}
else if ((!dosec) && (do24h)) { // - + -
tot += 0;
v[8] = 0; v[9] = 0; v[10] = 0; v[11] = 0;
v[12] = 0; v[13] = 0;
}
for (i = 0; i < 14; i += 2) {
set_state_val(parts[i], STATE_REL1,
float(v[i]) / float(tot), 0.0);
set_state_val(parts[i + 1], STATE_REL2,
float(v[i + 1]) / float(tot), 1.0);
}
for (i = 0; i < 14; i += 2) {
set_state(parts[i], "custom", 0.0);
}
set_min_size(tot * mul, 16);
set_max_size(tot * 8 * mul, 128);
emit("e,state,sizing,changed", "");
}
reset() {
new tim;
evalsize();
tim = get_int(tick_timer);
if (tim) {
cancel_timer(tim);
set_int(tick_timer, 0);
}
clock_cb(0);
}
public clock_cb(val) {
new year, month, day, yearday, weekday, hour, minute;
new Float:second;
new v, dosec, do24h, tim;
date(year, month, day, yearday, weekday, hour, minute, second);
dosec = get_int(do_seconds);
dosec = 1;
if (dosec) {
v = round(second);
tim = timer(1.0 - (second - v), "clock_cb", 1);
// set seconds to v
valset(PART:"s0", v / 10);
valset(PART:"s1", v % 10);
}
else {
tim = timer(60.0 - (second), "clock_cb", 1);
}
set_int(tick_timer, tim);
// set minutes to minute
valset(PART:"m0", minute / 10);
valset(PART:"m1", minute % 10);
// set hours to hour
do24h = get_int(do_24h);
if (do24h) {
valset(PART:"h0", hour / 10);
valset(PART:"h1", hour % 10);
}
else {
new pm;
// if 12 or later, its pm
if (hour >= 12) {
pm = 1;
// if we are after 12 (1, 2, 3 etc.) then mod by 12
if (hour > 12) hour = hour % 12;
}
else {
pm = 0;
// make after midnight be 12:XX AM :)
if (hour == 0) hour = 12;
}
valset(PART:"h0", hour / 10);
valset(PART:"h1", hour % 10);
apvalset(PART:"ap", pm);
}
}
}
parts {
part { name: "secclip"; type: RECT;
description { state: "default" 0.0;
}
description { state: "hidden" 0.0;
visible: 0;
}
}
part { name: "ampmclip"; type: RECT;
description { state: "default" 0.0;
}
description { state: "hidden" 0.0;
visible: 0;
}
}
// XXX: hours1/2, mins1/2, secs1/2 and ampm SHOULD be spacers... but
// if they are calculations go weird. this shouldnt happen, but does.
part { name: "timearea"; type: RECT;
description { state: "default" 0.0;
visible: 0;
}
description { state: "date" 0.0;
inherit: "default" 0.0;
rel2.relative: 1.0 0.0;
rel2.offset: -1 4;
rel2.to_y: "e.text.today";
}
}
part { name: "hours1"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (0/16) 0.0;
rel2.relative: (2/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "hours2"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (2/16) 0.0;
rel2.relative: (4/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "mins1"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (5/16) 0.0;
rel2.relative: (7/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "mins2"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (7/16) 0.0;
rel2.relative: (9/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "secs1"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (10/16) 0.0;
rel2.relative: (12/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "secs2"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (12/16) 0.0;
rel2.relative: (14/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "ampm"; type: RECT;
description { state: "default" 0.0;
rel1.relative: (14/16) 0.0;
rel2.relative: (16/16) 1.0;
rel1.to: "timearea";
rel2.to: "timearea";
visible: 0;
}
}
part { name: "c00";
description { state: "default" 0.0;
rel1.to: "hours2";
rel1.relative: 1.0 0.5;
rel1.offset: 0 -2;
rel2.to: "mins1";
rel2.relative: 0.0 0.5;
rel2.offset: 0 -2;
align: 0.5 1.0;
FIXED_SIZE(4, 4)
image.normal: "hole_tiny.png";
}
}
part { name: "c01";
description { state: "default" 0.0;
rel1.to: "hours2";
rel1.relative: 1.0 0.5;
rel1.offset: 0 1;
rel2.to: "mins1";
rel2.relative: 0.0 0.5;
rel2.offset: 0 1;
align: 0.5 0.0;
FIXED_SIZE(4, 4)
image.normal: "hole_tiny.png";
}
}
part { name: "c10";
clip_to: "secclip";
description { state: "default" 0.0;
rel1.to: "mins2";
rel1.relative: 1.0 0.5;
rel1.offset: 0 -2;
rel2.to: "secs1";
rel2.relative: 0.0 0.5;
rel2.offset: 0 -2;
align: 0.5 1.0;
FIXED_SIZE(4, 4)
image.normal: "hole_tiny.png";
}
}
part { name: "c11";
clip_to: "secclip";
description { state: "default" 0.0;
rel1.to: "mins2";
rel1.relative: 1.0 0.5;
rel1.offset: 0 1;
rel2.to: "secs1";
rel2.relative: 0.0 0.5;
rel2.offset: 0 1;
align: 0.5 0.0;
FIXED_SIZE(4, 4)
image.normal: "hole_tiny.png";
}
}
#define DIGIT(_NAME, _TO) \
part { name: _NAME; \
description { state: "default" 0.0; \
rel1.to: _TO; rel2.to: _TO; \
aspect: (52/72) (52/72); aspect_preference: BOTH; \
image.normal: "digit_na.png"; \
} \
description { state: "0" 0.0; inherit: "default" 0.0; image.normal: "digit_0.png"; } \
description { state: "1" 0.0; inherit: "default" 0.0; image.normal: "digit_1.png"; } \
description { state: "2" 0.0; inherit: "default" 0.0; image.normal: "digit_2.png"; } \
description { state: "3" 0.0; inherit: "default" 0.0; image.normal: "digit_3.png"; } \
description { state: "4" 0.0; inherit: "default" 0.0; image.normal: "digit_4.png"; } \
description { state: "5" 0.0; inherit: "default" 0.0; image.normal: "digit_5.png"; } \
description { state: "6" 0.0; inherit: "default" 0.0; image.normal: "digit_6.png"; } \
description { state: "7" 0.0; inherit: "default" 0.0; image.normal: "digit_7.png"; } \
description { state: "8" 0.0; inherit: "default" 0.0; image.normal: "digit_8.png"; } \
description { state: "9" 0.0; inherit: "default" 0.0; image.normal: "digit_9.png"; } \
}
#define DIGITC(_NAME, _TO, _CLIP) \
part { name: _NAME; \
clip_to: _CLIP; \
description { state: "default" 0.0; \
rel1.to: _TO; rel2.to: _TO; \
aspect: (52/72) (52/72); aspect_preference: BOTH; \
image.normal: "digit_na.png"; \
} \
description { state: "0" 0.0; inherit: "default" 0.0; image.normal: "digit_0.png"; } \
description { state: "1" 0.0; inherit: "default" 0.0; image.normal: "digit_1.png"; } \
description { state: "2" 0.0; inherit: "default" 0.0; image.normal: "digit_2.png"; } \
description { state: "3" 0.0; inherit: "default" 0.0; image.normal: "digit_3.png"; } \
description { state: "4" 0.0; inherit: "default" 0.0; image.normal: "digit_4.png"; } \
description { state: "5" 0.0; inherit: "default" 0.0; image.normal: "digit_5.png"; } \
description { state: "6" 0.0; inherit: "default" 0.0; image.normal: "digit_6.png"; } \
description { state: "7" 0.0; inherit: "default" 0.0; image.normal: "digit_7.png"; } \
description { state: "8" 0.0; inherit: "default" 0.0; image.normal: "digit_8.png"; } \
description { state: "9" 0.0; inherit: "default" 0.0; image.normal: "digit_9.png"; } \
}
#define TAG(_NAME, _TO, _CLIP) \
part { name: _NAME; \
clip_to: _CLIP; \
description { state: "default" 0.0; \
rel1.to: _TO; rel2.to: _TO; \
aspect: (48/31) (48/31); aspect_preference: BOTH; \
image.normal: "digit_am.png"; \
} \
description { state: "active" 0.0; \
inherit: "default" 0.0; \
image.normal: "digit_pm.png"; \
} \
}
DIGIT ("h0", "hours1")
DIGIT ("h1", "hours2")
DIGIT ("m0", "mins1")
DIGIT ("m1", "mins2")
DIGITC("s0", "secs1", "secclip")
DIGITC("s1", "secs2", "secclip")
TAG("ap", "ampm", "ampmclip")
#undef TAG
#undef DIGIT
part { name: "e.text.today"; type: TEXT;
effect: GLOW;
description { state: "default" 0.0;
rel1.relative: 0.0 1.0;
rel1.offset: 0 1;
rel2.offset: -1 1;
align: 0.5 1.0;
color: 51 153 255 255;
color2: 51 153 255 24;
color3: 51 153 255 18;
text { font: "Sans"; size: 8;
text_class: "module_small";
align: 0.5 0.5;
min: 0 1;
}
fixed: 0 1;
}
}
part { name: "event"; type: RECT;
description { state: "default" 0.0;
color: 0 0 0 0;
}
}
}
programs {
program {
signal: "load"; source: "";
script {
clock_cb(0);
}
}
program {
signal: "e,state,date,on"; source: "e";
script {
set_int(do_date, 1);
set_state(PART:"timearea", "date", 0.0);
reset();
}
}
program {
signal: "e,state,date,off"; source: "e";
script {
set_int(do_date, 0);
set_state(PART:"timearea", "default", 0.0);
reset();
}
}
program {
signal: "e,state,seconds,on"; source: "e";
script {
set_int(do_seconds, 1);
set_state(PART:"secclip", "default", 0.0);
reset();
}
}
program {
signal: "e,state,seconds,off"; source: "e";
script {
set_int(do_seconds, 0);
set_state(PART:"secclip", "hidden", 0.0);
reset();
}
}
program {
signal: "e,state,24h,on"; source: "e";
script {
set_int(do_24h, 1);
set_state(PART:"ampmclip", "hidden", 0.0);
reset();
}
}
program {
signal: "e,state,24h,off"; source: "e";
script {
set_int(do_24h, 0);
set_state(PART:"ampmclip", "default", 0.0);
reset();
}
}
}
}
#if 1
group { name: "e/modules/clock/main";
images {
image: "hole_tiny.png" COMP;
@ -240,7 +678,6 @@ group { name: "e/modules/clock/main";
}
}
}
#endif
group { name: "e/modules/clock/calendar/dayname";
parts {

BIN
data/themes/img/digit_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
data/themes/img/digit_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
data/themes/img/digit_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
data/themes/img/digit_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/themes/img/digit_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
data/themes/img/digit_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
data/themes/img/digit_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
data/themes/img/digit_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
data/themes/img/digit_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
data/themes/img/digit_9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -97,6 +97,14 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__,
ob = e_widget_check_add(evas, _("Seconds"), &(cfdata->cfg.show_seconds));
e_widget_frametable_object_append(of, ob, 0, 6, 1, 1, 1, 1, 0, 0);
rg = e_widget_radio_group_new(&(cfdata->cfg.show_date));
ob = e_widget_radio_add(evas, _("No Date"), 0, rg);
e_widget_frametable_object_append(of, ob, 0, 7, 1, 1, 1, 1, 0, 0);
ob = e_widget_radio_add(evas, _("Words"), 1, rg);
e_widget_frametable_object_append(of, ob, 0, 8, 1, 1, 1, 1, 0, 0);
ob = e_widget_radio_add(evas, _("Numbers"), 2, rg);
e_widget_frametable_object_append(of, ob, 0, 9, 1, 1, 1, 1, 0, 0);
e_widget_table_object_append(tab, of, 0, 0, 1, 1, 1, 1, 1, 1);
of = e_widget_frametable_add(evas, _("Week"), 0);

View File

@ -20,7 +20,7 @@ struct _Instance
int madj;
char year[8];
char month[32];
char month[64];
const char *daynames[7];
unsigned char daynums[7][6];
Eina_Bool dayweekends[7][6];
@ -78,6 +78,35 @@ _clear_timestrs(Instance *inst)
}
}
static void
_todaystr_eval(Instance *inst, char *buf, int bufsz)
{
if (!inst->cfg->show_date)
{
buf[0] = 0;
}
else
{
struct timeval timev;
struct tm *tm;
time_t tt;
tzset();
gettimeofday(&timev, NULL);
tt = (time_t)(timev.tv_sec);
tm = localtime(&tt);
if (tm)
{
if (inst->cfg->show_date == 1)
strftime(buf, bufsz, "%a, %e %b, %Y", (const struct tm *)tm);
else if (inst->cfg->show_date == 2)
strftime(buf, bufsz, "%a, %x", (const struct tm *)tm);
}
else
buf[0] = 0;
}
}
static void
_time_eval(Instance *inst)
{
@ -283,16 +312,12 @@ _clock_popup_new(Instance *inst)
Evas *evas;
Evas_Object *o, *oi;
Evas_Coord mw = 128, mh = 128;
char todaystr[32];
time_t t;
struct tm *tm;
t = time(NULL);
tm = localtime(&t);
strftime(todaystr, sizeof(todaystr) - 1, "%a, %x", tm);
char todaystr[128];
if (inst->popup) return;
_todaystr_eval(inst, todaystr, sizeof(todaystr) - 1);
inst->madj = 0;
_time_eval(inst);
@ -310,6 +335,10 @@ _clock_popup_new(Instance *inst)
else
e_theme_edje_object_set(oi, "base/theme/modules/clock",
"e/modules/clock/main");
if (inst->cfg->show_date)
edje_object_signal_emit(oi, "e,state,date,on", "e");
else
edje_object_signal_emit(oi, "e,state,date,off", "e");
if (inst->cfg->digital_24h)
edje_object_signal_emit(oi, "e,state,24h,on", "e");
else
@ -434,24 +463,23 @@ e_int_clock_instances_redo(void)
{
Eina_List *l;
Instance *inst;
char todaystr[32];
time_t t;
struct tm *tm;
t = time(NULL);
tm = localtime(&t);
strftime(todaystr, sizeof(todaystr) - 1, "%a, %x", tm);
char todaystr[128];
EINA_LIST_FOREACH(clock_instances, l, inst)
{
Evas_Object *o = inst->o_clock;
_todaystr_eval(inst, todaystr, sizeof(todaystr) - 1);
if (inst->cfg->digital_clock)
e_theme_edje_object_set(o, "base/theme/modules/clock",
"e/modules/clock/digital");
else
e_theme_edje_object_set(o, "base/theme/modules/clock",
"e/modules/clock/main");
if (inst->cfg->show_date)
edje_object_signal_emit(o, "e,state,date,on", "e");
else
edje_object_signal_emit(o, "e,state,date,off", "e");
if (inst->cfg->digital_24h)
edje_object_signal_emit(o, "e,state,24h,on", "e");
else
@ -475,6 +503,10 @@ e_int_clock_instances_redo(void)
else
e_theme_edje_object_set(o, "base/theme/modules/clock",
"e/modules/clock/main");
if (inst->cfg->show_date)
edje_object_signal_emit(o, "e,state,date,on", "e");
else
edje_object_signal_emit(o, "e,state,date,off", "e");
if (inst->cfg->digital_24h)
edje_object_signal_emit(o, "e,state,24h,on", "e");
else
@ -591,17 +623,13 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
Evas_Object *o;
E_Gadcon_Client *gcc;
Instance *inst;
char todaystr[32];
time_t t;
struct tm *tm;
t = time(NULL);
tm = localtime(&t);
strftime(todaystr, sizeof(todaystr) - 1, "%a, %x", tm);
char todaystr[128];
inst = E_NEW(Instance, 1);
inst->cfg = _conf_item_get(id);
_todaystr_eval(inst, todaystr, sizeof(todaystr) - 1);
o = edje_object_add(gc->evas);
edje_object_signal_callback_add(o, "e,state,sizing,changed", "*",
_clock_sizing_changed_cb, inst);
@ -611,6 +639,10 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
else
e_theme_edje_object_set(o, "base/theme/modules/clock",
"e/modules/clock/main");
if (inst->cfg->show_date)
edje_object_signal_emit(o, "e,state,date,on", "e");
else
edje_object_signal_emit(o, "e,state,date,off", "e");
if (inst->cfg->digital_24h)
edje_object_signal_emit(o, "e,state,24h,on", "e");
else
@ -710,6 +742,7 @@ _conf_item_get(const char *id)
ci->digital_clock = 0;
ci->digital_24h = 0;
ci->show_seconds = 1;
ci->show_date = 0;
clock_config->items = eina_list_append(clock_config->items, ci);
e_config_save_queue();
@ -804,6 +837,7 @@ e_modapi_init(E_Module *m)
E_CONFIG_VAL(D, T, digital_clock, INT);
E_CONFIG_VAL(D, T, digital_24h, INT);
E_CONFIG_VAL(D, T, show_seconds, INT);
E_CONFIG_VAL(D, T, show_date, INT);
conf_edd = E_CONFIG_DD_NEW("Config", Config);
#undef T

View File

@ -30,6 +30,7 @@ struct _Config_Item
int digital_clock;
int digital_24h;
int show_seconds;
int show_date;
};
void e_int_config_clock_module(E_Container *con, Config_Item *ci);