Enlightenment CVS committal Author : englebass Project : e_modules Module : uptime
Dir : e_modules/uptime Modified Files: e_mod_main.c Log Message: Implement id_new() =================================================================== RCS file: /cvs/e/e_modules/uptime/e_mod_main.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- e_mod_main.c 16 Sep 2007 01:46:52 -0000 1.24 +++ e_mod_main.c 16 Sep 2007 03:31:42 -0000 1.25 @@ -59,6 +59,7 @@ static void _gc_orient (E_Gadcon_Client * gcc); static char *_gc_label (void); static Evas_Object *_gc_icon (Evas * evas); +static const char *_gc_id_new (void); static void _ut_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, void *event_info); @@ -77,7 +78,7 @@ static const E_Gadcon_Client_Class _gc_class = { GADCON_CLIENT_CLASS_VERSION, - "uptime", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon}, + "uptime", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL}, E_GADCON_CLIENT_STYLE_PLAIN }; @@ -175,6 +176,15 @@ return o; } +static const char * +_gc_id_new (void) +{ + Config_Item *ci; + + ci = _ut_config_item_get (NULL); + return ci->id; +} + static void _ut_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, void *event_info) { @@ -238,26 +248,45 @@ static Config_Item * _ut_config_item_get (const char *id) { - Evas_List *l; - Config_Item *ci; - - for (l = ut_config->items; l; l = l->next) - { - ci = l->data; - if (ci->id == NULL) - continue; - if (strcmp (ci->id, id) == 0) - return ci; - } - - ci = E_NEW (Config_Item, 1); - ci->id = evas_stringshare_add (id); - ci->check_interval = 60.0; - ci->update_interval = 60.0; + Evas_List *l; + Config_Item *ci; + char buf[128]; + + if (!id) + { + int num = 0; + + /* Create id */ + if (ut_config->items) + { + const char *p; + ci = evas_list_last (ut_config->items)->data; + p = strrchr (ci->id, '.'); + if (p) num = atoi (p + 1) + 1; + } + snprintf (buf, sizeof (buf), "%s.%d", _gc_class.name, num); + id = buf; + } + else + { + for (l = ut_config->items; l; l = l->next) + { + ci = l->data; + if (ci->id == NULL) + continue; + if (strcmp (ci->id, id) == 0) + return ci; + } + } + + ci = E_NEW (Config_Item, 1); + ci->id = evas_stringshare_add (id); + ci->check_interval = 60.0; + ci->update_interval = 60.0; - ut_config->items = evas_list_append (ut_config->items, ci); + ut_config->items = evas_list_append (ut_config->items, ci); - return ci; + return ci; } void ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs