Enlightenment CVS committal
Author : devilhorns
Project : e_modules
Module : tclock
Dir : e_modules/tclock
Modified Files:
e_mod_config.c e_mod_main.c
Log Message:
Fix tclock to only use one timer for all instances, always polling at one
second intervals.
===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_config.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- e_mod_config.c 17 Sep 2006 16:46:53 -0000 1.27
+++ e_mod_config.c 10 Oct 2006 17:33:48 -0000 1.28
@@ -3,7 +3,6 @@
struct _E_Config_Dialog_Data
{
- int resolution;
int show_date;
int show_time;
char *time_format;
@@ -45,7 +44,6 @@
static void
_fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
{
- cfdata->resolution = ci->resolution;
cfdata->show_time = ci->show_time;
cfdata->show_date = ci->show_date;
cfdata->time_format = strdup (ci->time_format);
@@ -85,14 +83,6 @@
o = e_widget_list_add (evas, 0, 0);
- of = e_widget_framelist_add (evas, D_ ("Resolution"), 0);
- rg = e_widget_radio_group_new (&(cfdata->resolution));
- ob = e_widget_radio_add (evas, D_ ("1 Minute"), RESOLUTION_MINUTE, rg);
- e_widget_framelist_object_append (of, ob);
- ob = e_widget_radio_add (evas, D_ ("1 Second"), RESOLUTION_SECOND, rg);
- 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_ ("Date"), 1);
date_check =
e_widget_check_add (evas, D_ ("Show Date"), &(cfdata->show_date));
@@ -142,15 +132,6 @@
if (ci->date_format)
evas_stringshare_del (ci->date_format);
ci->date_format = evas_stringshare_add (cfdata->date_format);
- ci->resolution = cfdata->resolution;
- if (cfdata->resolution == RESOLUTION_MINUTE)
- ci->poll_time = 60.0;
- else
- ci->poll_time = 1.0;
-
- /* If we're not showing time, no reason to update every second */
- if (!cfdata->show_time)
- ci->poll_time = 60.0;
e_config_save_queue ();
===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_main.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- e_mod_main.c 17 Sep 2006 16:46:53 -0000 1.42
+++ e_mod_main.c 10 Oct 2006 17:33:48 -0000 1.43
@@ -12,24 +12,22 @@
#endif
/* Func Proto Requirements for Gadcon */
-static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name,
- const char *id, const char *style);
-static void _gc_shutdown (E_Gadcon_Client * gcc);
-static void _gc_orient (E_Gadcon_Client * gcc);
-static char *_gc_label (void);
-static Evas_Object *_gc_icon (Evas * evas);
+static E_Gadcon_Client *_gc_init (E_Gadcon *gc, const char *name, const
char *id, const char *style);
+static void _gc_shutdown (E_Gadcon_Client *gcc);
+static void _gc_orient (E_Gadcon_Client *gcc);
+static char *_gc_label (void);
+static Evas_Object *_gc_icon (Evas *evas);
/* Module Protos */
-static void _tclock_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
- void *event_info);
-static void _tclock_menu_cb_configure (void *data, E_Menu * m,
- E_Menu_Item * mi);
-static void _tclock_menu_cb_post (void *data, E_Menu * m);
-static int _tclock_cb_check (void *data);
-static Config_Item *_tclock_config_item_get (const char *id);
+static void _tclock_cb_mouse_down (void *data, Evas *e,
Evas_Object *obj, void *event_info);
+static void _tclock_menu_cb_configure (void *data, E_Menu *m,
E_Menu_Item *mi);
+static void _tclock_menu_cb_post (void *data, E_Menu *m);
+static int _tclock_cb_check (void *data);
+static Config_Item *_tclock_config_item_get (const char *id);
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *conf_item_edd = NULL;
+static Ecore_Timer *check_timer;
Config *tclock_config = NULL;
@@ -45,7 +43,6 @@
{
E_Gadcon_Client *gcc;
Evas_Object *tclock;
- Ecore_Timer *check_timer;
};
static E_Gadcon_Client *
@@ -83,7 +80,8 @@
evas_list_append (tclock_config->instances, inst);
_tclock_cb_check (inst);
- inst->check_timer = ecore_timer_add (ci->poll_time, _tclock_cb_check, inst);
+ if (!check_timer)
+ check_timer = ecore_timer_add (1.0, _tclock_cb_check, NULL);
return gcc;
}
@@ -93,15 +91,21 @@
Instance *inst;
inst = gcc->data;
- if (inst->check_timer)
- ecore_timer_del (inst->check_timer);
- tclock_config->instances =
- evas_list_remove (tclock_config->instances, inst);
-
+
evas_object_event_callback_del (inst->tclock, EVAS_CALLBACK_MOUSE_DOWN,
_tclock_cb_mouse_down);
evas_object_del (inst->tclock);
+
+ tclock_config->instances =
+ evas_list_remove (tclock_config->instances, inst);
+
+ if (evas_list_count(tclock_config->instances) <= 0)
+ {
+ ecore_timer_del (check_timer);
+ check_timer = NULL;
+ }
+
free (inst);
inst = NULL;
}
@@ -227,14 +231,6 @@
_tclock_cb_check (inst);
- if (inst->check_timer)
- ecore_timer_interval_set (inst->check_timer,
- (double) ci->poll_time);
- else
- inst->check_timer =
- ecore_timer_add ((double) ci->poll_time, _tclock_cb_check,
- inst);
-
break;
}
}
@@ -243,36 +239,40 @@
static int
_tclock_cb_check (void *data)
{
- Instance *inst;
- Config_Item *ci;
- time_t current_time;
- struct tm *local_time;
- char buf[1024];
-
- inst = data;
- ci = _tclock_config_item_get (inst->gcc->id);
-
- if (!ci->show_time)
- edje_object_signal_emit (inst->tclock, "time_hidden", "");
- else
- edje_object_signal_emit (inst->tclock, "time_visible", "");
- edje_object_message_signal_process (inst->tclock);
-
- if (!ci->show_date)
- edje_object_signal_emit (inst->tclock, "date_hidden", "");
- else
- edje_object_signal_emit (inst->tclock, "date_visible", "");
- edje_object_message_signal_process (inst->tclock);
-
- memset (buf, 0, sizeof (buf));
- current_time = time (NULL);
- local_time = localtime (¤t_time);
-
- strftime (buf, 1024, ci->time_format, local_time);
- edje_object_part_text_set (inst->tclock, "tclock_time", buf);
- strftime (buf, 1024, ci->date_format, local_time);
- edje_object_part_text_set (inst->tclock, "tclock_date", buf);
-
+ Instance *inst;
+ Config_Item *ci;
+ Evas_List *l;
+ time_t current_time;
+ struct tm *local_time;
+ char buf[1024];
+
+ for (l = tclock_config->instances; l; l = l->next)
+ {
+ inst = l->data;
+ ci = _tclock_config_item_get (inst->gcc->id);
+
+ if (!ci->show_time)
+ edje_object_signal_emit (inst->tclock, "time_hidden", "");
+ else
+ edje_object_signal_emit (inst->tclock, "time_visible", "");
+ edje_object_message_signal_process (inst->tclock);
+
+ if (!ci->show_date)
+ edje_object_signal_emit (inst->tclock, "date_hidden", "");
+ else
+ edje_object_signal_emit (inst->tclock, "date_visible", "");
+ edje_object_message_signal_process (inst->tclock);
+
+ memset (buf, 0, sizeof (buf));
+ current_time = time (NULL);
+ local_time = localtime (¤t_time);
+
+ strftime (buf, 1024, ci->time_format, local_time);
+ edje_object_part_text_set (inst->tclock, "tclock_time", buf);
+ strftime (buf, 1024, ci->date_format, local_time);
+ edje_object_part_text_set (inst->tclock, "tclock_date", buf);
+ }
+
return 1;
}
@@ -293,8 +293,6 @@
ci = E_NEW (Config_Item, 1);
ci->id = evas_stringshare_add (id);
- ci->poll_time = 1.0;
- ci->resolution = RESOLUTION_SECOND;
ci->show_date = 1;
ci->show_time = 1;
ci->time_format = evas_stringshare_add ("%T");
@@ -321,8 +319,6 @@
#define T Config_Item
#define D conf_item_edd
E_CONFIG_VAL (D, T, id, STR);
- E_CONFIG_VAL (D, T, poll_time, DOUBLE);
- E_CONFIG_VAL (D, T, resolution, INT);
E_CONFIG_VAL (D, T, show_date, INT);
E_CONFIG_VAL (D, T, show_time, INT);
E_CONFIG_VAL (D, T, date_format, STR);
@@ -344,8 +340,6 @@
ci = E_NEW (Config_Item, 1);
ci->id = evas_stringshare_add ("0");
- ci->poll_time = 1.0;
- ci->resolution = RESOLUTION_SECOND;
ci->show_date = 1;
ci->show_time = 1;
ci->time_format = evas_stringshare_add ("%T");
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs