Enlightenment CVS committal
Author : englebass
Project : e_modules
Module : wlan
Dir : e_modules/wlan
Modified Files:
e_mod_main.c
Log Message:
Implement id_new()
===================================================================
RCS file: /cvs/e/e_modules/wlan/e_mod_main.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- e_mod_main.c 16 Sep 2007 01:46:52 -0000 1.39
+++ e_mod_main.c 16 Sep 2007 03:32:39 -0000 1.40
@@ -26,6 +26,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);
/* Func Protos for Module */
static void _wlan_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
@@ -50,7 +51,7 @@
static const E_Gadcon_Client_Class _gc_class = {
GADCON_CLIENT_CLASS_VERSION,
- "wlan", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon},
+ "wlan", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon,
_gc_id_new, NULL},
E_GADCON_CLIENT_STYLE_PLAIN
};
@@ -65,8 +66,6 @@
inst = E_NEW (Instance, 1);
inst->ci = _wlan_config_item_get (id);
- if (!inst->ci->id)
- inst->ci->id = evas_stringshare_add (id);
wlan = _wlan_new (gc->evas);
wlan->inst = inst;
@@ -121,6 +120,15 @@
return o;
}
+static const char *
+_gc_id_new (void)
+{
+ Config_Item *ci;
+
+ ci = _wlan_config_item_get (NULL);
+ return ci->id;
+}
+
static void
_gc_shutdown (E_Gadcon_Client * gcc)
{
@@ -219,30 +227,49 @@
static Config_Item *
_wlan_config_item_get (const char *id)
{
- Evas_List *l;
- Config_Item *ci;
-
- for (l = wlan_config->items; l; l = l->next)
- {
- ci = l->data;
- if (!ci->id)
- continue;
- if (!strcmp (ci->id, id))
- {
- if (!ci->device)
- ci->device = evas_stringshare_add ("wlan0");
- return ci;
- }
- }
- ci = E_NEW (Config_Item, 1);
- ci->id = evas_stringshare_add (id);
- ci->device = evas_stringshare_add ("wlan0");
- ci->poll_time = 1.0;
- ci->always_text = 0;
- ci->show_percent = 1;
+ Evas_List *l;
+ Config_Item *ci;
+ char buf[128];
+
+ if (!id)
+ {
+ int num = 0;
+
+ /* Create id */
+ if (wlan_config->items)
+ {
+ const char *p;
+ ci = evas_list_last (wlan_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 = wlan_config->items; l; l = l->next)
+ {
+ ci = l->data;
+ if (!ci->id)
+ continue;
+ if (!strcmp (ci->id, id))
+ {
+ if (!ci->device)
+ ci->device = evas_stringshare_add ("wlan0");
+ return ci;
+ }
+ }
+ }
+ ci = E_NEW (Config_Item, 1);
+ ci->id = evas_stringshare_add (id);
+ ci->device = evas_stringshare_add ("wlan0");
+ ci->poll_time = 1.0;
+ ci->always_text = 0;
+ ci->show_percent = 1;
- wlan_config->items = evas_list_append (wlan_config->items, ci);
- return ci;
+ wlan_config->items = evas_list_append (wlan_config->items, ci);
+ return ci;
}
EAPI E_Module_Api e_modapi = {
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs