Tclock can now support new-line's in the format string.
Do Not Use strftime's %n, use <br> instead. (%c<br>%H) NOTE: You will need to remove old tclock config (modules.tclock.cfg) SVN revision: 22636
This commit is contained in:
parent
b5c07e58f1
commit
601d444490
|
@ -4,7 +4,7 @@
|
|||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
unsigned int resolution;
|
||||
int resolution;
|
||||
char *format;
|
||||
int userformat;
|
||||
};
|
||||
|
@ -35,9 +35,9 @@ _config_tclock_module(E_Container *con, TClock_Face *f)
|
|||
static void
|
||||
_fill_data(TClock_Face *f, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
printf("Cfg Format: %s\n", f->conf->format);
|
||||
cfdata->resolution = f->conf->resolution;
|
||||
if (f->conf->format)
|
||||
cfdata->format = strdup(f->conf->format);
|
||||
cfdata->format = strdup(f->conf->format);
|
||||
cfdata->userformat = f->conf->userformat;
|
||||
}
|
||||
|
||||
|
@ -75,19 +75,24 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, D_("Time Format"), 0);
|
||||
of = e_widget_frametable_add(evas, D_("Time Format"), 1);
|
||||
checked = e_widget_check_add(evas, D_("User format String"), &(cfdata->userformat));
|
||||
if (cfdata->userformat)
|
||||
e_widget_check_checked_set(checked, 1);
|
||||
e_widget_frametable_object_append(of, checked, 0, 0, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
entry = e_widget_entry_add(evas, &cfdata->format);
|
||||
e_widget_disabled_set(entry, !cfdata->userformat);
|
||||
//e_widget_min_size_set(entry, 150, 1);
|
||||
e_widget_frametable_object_append(of, entry, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_label_add(evas, D_("Consult strftime(3) for format syntax"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
|
||||
entry = e_widget_entry_add(evas, &(cfdata->format));
|
||||
e_widget_disabled_set(entry, !cfdata->userformat);
|
||||
e_widget_min_size_set(entry, 150, 1);
|
||||
e_widget_frametable_object_append(of, entry, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_label_add(evas, "");
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_label_add(evas, D_("If you wish to insert %n use <br> instead"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
// ob = e_widget_label_add(evas, "");
|
||||
// e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
e_widget_on_change_hook_set(checked, onCheckChange, entry);
|
||||
|
||||
|
@ -100,29 +105,30 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
TClock_Face *f;
|
||||
|
||||
f = cfd->data;
|
||||
e_border_button_bindings_ungrab_all();
|
||||
if (cfdata->resolution != f->conf->resolution)
|
||||
{
|
||||
if (cfdata->resolution == RESOLUTION_MINUTE)
|
||||
f->tclock->conf->poll_time = 60.0;
|
||||
else
|
||||
f->tclock->conf->poll_time = 1.0;
|
||||
ecore_timer_interval_set(f->tclock->tclock_check_timer, f->tclock->conf->poll_time);
|
||||
ecore_timer_interval_set(f->tclock->tclock_check_timer, f->tclock->conf->poll_time);
|
||||
}
|
||||
f->conf->resolution = cfdata->resolution;
|
||||
f->conf->userformat = cfdata->userformat;
|
||||
|
||||
/* update the format string with the format string given by the user
|
||||
* when the userformat is true and the string(typed by the user) isn't empty */
|
||||
if (strlen(cfdata->format) > 0 && cfdata->userformat)
|
||||
{
|
||||
if (f->conf->format)
|
||||
evas_stringshare_del(f->conf->format);
|
||||
f->conf->format = (char *)evas_stringshare_add(cfdata->format);
|
||||
}
|
||||
if (f->conf->format)
|
||||
evas_stringshare_del(f->conf->format);
|
||||
|
||||
if (cfdata->userformat && (strlen(cfdata->format) > 0))
|
||||
f->conf->format = (char *)evas_stringshare_add(cfdata->format);
|
||||
else
|
||||
f->conf->format = (char *)evas_stringshare_add("%c");
|
||||
|
||||
e_config_save_queue();
|
||||
e_border_button_bindings_grab_all();
|
||||
printf("Cfg Format: %s\n", f->conf->format);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -130,6 +136,5 @@ static void
|
|||
onCheckChange(void *data, Evas_Object *obj)
|
||||
{
|
||||
int checked = e_widget_check_checked_get(obj);
|
||||
|
||||
e_widget_disabled_set(data, !checked);
|
||||
}
|
||||
|
|
71
e_mod_main.c
71
e_mod_main.c
|
@ -50,13 +50,11 @@ e_modapi_shutdown(E_Module *module)
|
|||
TClock *tclock;
|
||||
|
||||
if (module->config_menu)
|
||||
module->config_menu = NULL;
|
||||
module->config_menu = NULL;
|
||||
|
||||
tclock = module->data;
|
||||
if (tclock)
|
||||
{
|
||||
_tclock_shutdown(tclock);
|
||||
}
|
||||
_tclock_shutdown(tclock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -135,10 +133,10 @@ _tclock_new()
|
|||
#define T Config_Face
|
||||
#define D conf_face_edd
|
||||
E_CONFIG_VAL(D, T, enabled, UCHAR);
|
||||
E_CONFIG_VAL(D, T, resolution, UINT);
|
||||
E_CONFIG_VAL(D, T, resolution, INT);
|
||||
E_CONFIG_VAL(D, T, format, STR);
|
||||
E_CONFIG_VAL(D, T, userformat, UINT);
|
||||
|
||||
E_CONFIG_VAL(D, T, userformat, UCHAR);
|
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("TClock_Config", Config);
|
||||
|
||||
#undef T
|
||||
|
@ -149,14 +147,14 @@ _tclock_new()
|
|||
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
||||
|
||||
tclock->conf = e_config_domain_load("module.tclock", conf_edd);
|
||||
|
||||
if (!tclock->conf)
|
||||
{
|
||||
tclock->conf = E_NEW(Config, 1);
|
||||
|
||||
tclock->conf->poll_time = 60.0;
|
||||
}
|
||||
|
||||
E_CONFIG_LIMIT(tclock->conf->poll_time, 1.0, 60.0);
|
||||
|
||||
_tclock_config_menu_new(tclock);
|
||||
|
||||
managers = e_manager_list();
|
||||
|
@ -187,11 +185,9 @@ _tclock_new()
|
|||
face->conf->enabled = 1;
|
||||
face->conf->resolution = RESOLUTION_MINUTE;
|
||||
face->conf->userformat = 0;
|
||||
face->conf->format = (char *)evas_stringshare_add("%c");
|
||||
|
||||
const char *format;
|
||||
|
||||
format = edje_object_part_state_get(face->tclock_object, "tclock_format", NULL);
|
||||
face->conf->format = (char *)evas_stringshare_add(format);
|
||||
E_CONFIG_LIMIT(face->conf->resolution, 0, 1);
|
||||
|
||||
tclock->conf->faces = evas_list_append(tclock->conf->faces, face->conf);
|
||||
}
|
||||
|
@ -199,22 +195,13 @@ _tclock_new()
|
|||
{
|
||||
face->conf = cl->data;
|
||||
cl = cl->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (face->conf->resolution == RESOLUTION_SECOND)
|
||||
{
|
||||
E_CONFIG_LIMIT(tclock->conf->poll_time, 0.1, 1.0);
|
||||
tclock->tclock_check_timer = ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock);
|
||||
TCLOCK_DEBUG("RES_SEC");
|
||||
}
|
||||
else
|
||||
{
|
||||
E_CONFIG_LIMIT(tclock->conf->poll_time, 60.0, 60.0);
|
||||
tclock->tclock_check_timer = ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock);
|
||||
TCLOCK_DEBUG("RES_MIN");
|
||||
/* to avoid the long display of "Starting the clock..." */
|
||||
_tclock_cb_check(tclock);
|
||||
}
|
||||
printf("Format: %s\n", face->conf->format);
|
||||
|
||||
/* to avoid the long display of "Starting the clock..." */
|
||||
_tclock_cb_check(tclock);
|
||||
tclock->tclock_check_timer = ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock);
|
||||
|
||||
/* Menu */
|
||||
/* This menu must be initialized after conf */
|
||||
|
@ -246,10 +233,10 @@ _tclock_shutdown(TClock *tclock)
|
|||
|
||||
for (list = tclock->faces; list; list = list->next)
|
||||
_tclock_face_free(list->data);
|
||||
evas_list_free(tclock->faces);
|
||||
|
||||
e_object_del(E_OBJECT(tclock->config_menu));
|
||||
|
||||
evas_list_free(tclock->faces);
|
||||
evas_list_free(tclock->conf->faces);
|
||||
free(tclock->conf);
|
||||
free(tclock);
|
||||
|
@ -306,17 +293,14 @@ _tclock_face_new(E_Container *con)
|
|||
e_gadman_client_domain_set(face->gmc, "module.tclock", _tclock_count++);
|
||||
e_gadman_client_policy_set(face->gmc,
|
||||
E_GADMAN_POLICY_ANYWHERE |
|
||||
E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_VMOVE | E_GADMAN_POLICY_HSIZE | E_GADMAN_POLICY_VSIZE);
|
||||
E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_VMOVE |
|
||||
E_GADMAN_POLICY_HSIZE | E_GADMAN_POLICY_VSIZE);
|
||||
e_gadman_client_min_size_set(face->gmc, 4, 4);
|
||||
e_gadman_client_max_size_set(face->gmc, 512, 512);
|
||||
e_gadman_client_auto_size_set(face->gmc, 40 + (face->inset.l + face->inset.r), 40 + (face->inset.t + face->inset.b));
|
||||
|
||||
e_gadman_client_align_set(face->gmc, 1.0, 1.0);
|
||||
//e_gadman_client_aspect_set(face->gmc, 1.0, 1.0);
|
||||
e_gadman_client_padding_set(face->gmc, face->inset.l, face->inset.r, face->inset.t, face->inset.b);
|
||||
|
||||
e_gadman_client_resize(face->gmc, 40 + (face->inset.l + face->inset.r), 40 + (face->inset.t + face->inset.b));
|
||||
|
||||
e_gadman_client_change_func_set(face->gmc, _tclock_face_cb_gmc_change, face);
|
||||
e_gadman_client_load(face->gmc);
|
||||
|
||||
|
@ -336,6 +320,7 @@ _tclock_face_free(TClock_Face *face)
|
|||
|
||||
if (face->conf->format)
|
||||
evas_stringshare_del(face->conf->format);
|
||||
|
||||
free(face->conf);
|
||||
free(face);
|
||||
_tclock_count--;
|
||||
|
@ -360,24 +345,8 @@ _tclock_cb_check(void *data)
|
|||
TClock_Face *face;
|
||||
|
||||
face = l->data;
|
||||
|
||||
const char *format;
|
||||
|
||||
/* Load the default format string from the module.edj-file
|
||||
* when the user defineable format string shouldn't be used
|
||||
* otherwise use the user defined format string */
|
||||
if (!face->conf->userformat)
|
||||
{
|
||||
format = edje_object_part_state_get(face->tclock_object, "tclock_format", NULL);
|
||||
}
|
||||
else
|
||||
format = face->conf->format;
|
||||
|
||||
strftime(buf, TIME_BUF, format, local_time);
|
||||
|
||||
TCLOCK_DEBUG(face->conf->format);
|
||||
strftime(buf, TIME_BUF, face->conf->format, local_time);
|
||||
edje_object_part_text_set(face->tclock_object, "tclock_text", buf);
|
||||
e_config_save_queue();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#define TIME_BUF 1024
|
||||
#define FORMAT_BUF_SIZE 1024
|
||||
#define TCLOCK_DEBUG(X) (printf("tclock_debug: %s\n",X))
|
||||
#undef TCLOCK_DEBUG
|
||||
#define TCLOCK_DEBUG(X)
|
||||
|
||||
typedef struct _Config
|
||||
{
|
||||
|
|
142
tclock.edc
142
tclock.edc
|
@ -1,73 +1,81 @@
|
|||
// Sample EDC
|
||||
images {
|
||||
image, "background.png" COMP;
|
||||
images
|
||||
{
|
||||
image: "background.png" COMP;
|
||||
}
|
||||
collections {
|
||||
group {
|
||||
name, "modules/tclock/main";
|
||||
min, 32 32;
|
||||
max, 1024 768;
|
||||
|
||||
parts {
|
||||
part {
|
||||
name, "background";
|
||||
type, IMAGE;
|
||||
mouse_events, 0;
|
||||
description {
|
||||
state, "default" 0.0;
|
||||
rel1 {
|
||||
relative, 0.0 0.0;
|
||||
offset, 0 0;
|
||||
}
|
||||
rel2 {
|
||||
relative, 1.0 1.0;
|
||||
offset, -1 -1;
|
||||
}
|
||||
image {
|
||||
normal, "background.png";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
part {
|
||||
name: "tclock_format";
|
||||
type: TEXT;
|
||||
mouse_events, 0;
|
||||
description {
|
||||
state: " %c" 0.0;
|
||||
}
|
||||
styles
|
||||
{
|
||||
style
|
||||
{
|
||||
name: "tclock_style";
|
||||
base: "font=Edje-Vera font_size=12 text_class=tb_plain align=center style=soft_shadow color=#fff shadow_color=#00000020 valign=center";
|
||||
tag: "br" "\n";
|
||||
}
|
||||
}
|
||||
|
||||
part {
|
||||
name: "tclock_text";
|
||||
type: TEXT;
|
||||
effect: SOFT_SHADOW;
|
||||
mouse_events, 0;
|
||||
|
||||
description {
|
||||
state, "default" 0.0;
|
||||
rel1 {
|
||||
relative, 0.0 0.0;
|
||||
offset, 0 0;
|
||||
}
|
||||
collections
|
||||
{
|
||||
group
|
||||
{
|
||||
name: "modules/tclock/main";
|
||||
min: 32 32;
|
||||
max: 1024 768;
|
||||
|
||||
rel2 {
|
||||
relative, 1.0 1.0;
|
||||
offset, -1 -1;
|
||||
}
|
||||
color: 255 255 255 230;
|
||||
//color2: 0 0 255 155;
|
||||
color3: 0 0 0 50;
|
||||
text {
|
||||
text, "Starting the clock...";
|
||||
font, "vera";
|
||||
size, 12;
|
||||
align, 0.5 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* Close Parts */
|
||||
parts
|
||||
{
|
||||
part
|
||||
{
|
||||
name: "background";
|
||||
type: IMAGE;
|
||||
mouse_events: 0;
|
||||
description
|
||||
{
|
||||
state: "default" 0.0;
|
||||
rel1
|
||||
{
|
||||
relative: 0.0 0.0;
|
||||
offset: 0 0;
|
||||
}
|
||||
rel2
|
||||
{
|
||||
relative: 1.0 1.0;
|
||||
offset: -1 -1;
|
||||
}
|
||||
image
|
||||
{
|
||||
normal: "background.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* Close Group */
|
||||
} /* Close Coll */
|
||||
part
|
||||
{
|
||||
name: "tclock_text";
|
||||
type: TEXTBLOCK;
|
||||
mouse_events: 0;
|
||||
description
|
||||
{
|
||||
state: "default" 0.0;
|
||||
rel1
|
||||
{
|
||||
relative: 0.0 0.0;
|
||||
offset: 0 0;
|
||||
}
|
||||
rel2
|
||||
{
|
||||
relative: 1.0 1.0;
|
||||
offset: -1 -1;
|
||||
}
|
||||
text
|
||||
{
|
||||
style: "tclock_style";
|
||||
min: 1 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Close Parts */
|
||||
}
|
||||
/* Close Group */
|
||||
}
|
||||
/* Close Coll */
|
||||
|
|
Loading…
Reference in New Issue