Enlightenment CVS committal

Author  : englebass
Project : e_modules
Module  : tclock

Dir     : e_modules/tclock


Modified Files:
        e_mod_main.c 


Log Message:
Implement id_new()

===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_main.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- e_mod_main.c        16 Sep 2007 01:46:51 -0000      1.49
+++ e_mod_main.c        16 Sep 2007 03:31:42 -0000      1.50
@@ -17,6 +17,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);
 
 /* Module Protos */
 static void         _tclock_cb_mouse_down     (void *data, Evas *e, 
Evas_Object *obj, void *event_info);
@@ -34,7 +35,7 @@
 /* Define the class and gadcon functions this module provides */
 static const E_Gadcon_Client_Class _gc_class = {
   GADCON_CLIENT_CLASS_VERSION,
-  "tclock", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon},
+  "tclock", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, 
_gc_id_new, NULL},
   E_GADCON_CLIENT_STYLE_PLAIN
 };
 
@@ -100,7 +101,7 @@
    tclock_config->instances =
     evas_list_remove (tclock_config->instances, inst);
 
-   if (evas_list_count(tclock_config->instances) <= 0) 
+   if (evas_list_count (tclock_config->instances) <= 0) 
      { 
        ecore_timer_del (check_timer);
        check_timer = NULL;
@@ -140,6 +141,15 @@
   return o;
 }
 
+static const char *
+_gc_id_new (void)
+{
+   Config_Item *ci;
+
+   ci = _tclock_config_item_get (NULL);
+   return ci->id;
+}
+
 static void
 _tclock_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
                       void *event_info)
@@ -273,27 +283,46 @@
 static Config_Item *
 _tclock_config_item_get (const char *id)
 {
-  Evas_List *l;
-  Config_Item *ci;
+   Evas_List *l;
+   Config_Item *ci;
+   char buf[128];
 
-  for (l = tclock_config->items; l; l = l->next)
-    {
-      ci = l->data;
-      if (!ci->id)
-       continue;
-      if (!strcmp (ci->id, id))
-       return ci;
-    }
+   if (!id)
+     {
+       int  num = 0;
+
+       /* Create id */
+       if (tclock_config->items)
+         {
+            const char *p;
+            ci = evas_list_last (tclock_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 = tclock_config->items; l; l = l->next)
+         {
+            ci = l->data;
+            if (!ci->id)
+              continue;
+            if (!strcmp (ci->id, id))
+              return ci;
+         }
+     }
 
-  ci = E_NEW (Config_Item, 1);
-  ci->id = evas_stringshare_add (id);
-  ci->show_date = 1;
-  ci->show_time = 1;
-  ci->time_format = evas_stringshare_add ("%T");
-  ci->date_format = evas_stringshare_add ("%d/%m/%y");
+   ci = E_NEW (Config_Item, 1);
+   ci->id = evas_stringshare_add (id);
+   ci->show_date = 1;
+   ci->show_time = 1;
+   ci->time_format = evas_stringshare_add ("%T");
+   ci->date_format = evas_stringshare_add ("%d/%m/%y");
 
-  tclock_config->items = evas_list_append (tclock_config->items, ci);
-  return ci;
+   tclock_config->items = evas_list_append (tclock_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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to