Enlightenment CVS committal

Author  : englebass
Project : e_modules
Module  : mixer

Dir     : e_modules/mixer


Modified Files:
        e_mod_main.c 


Log Message:
Implement id_new()

===================================================================
RCS file: /cvs/e/e_modules/mixer/e_mod_main.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -3 -r1.64 -r1.65
--- e_mod_main.c        16 Sep 2007 01:46:50 -0000      1.64
+++ e_mod_main.c        16 Sep 2007 03:31:41 -0000      1.65
@@ -24,6 +24,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         _mixer_simple_volume_change (Mixer *mixer, Config_Item 
*ci, double val);
@@ -68,7 +69,7 @@
 static const E_Gadcon_Client_Class _gc_class =
 {
    GADCON_CLIENT_CLASS_VERSION, "mixer",
-     {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon},
+     {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, 
NULL},
    E_GADCON_CLIENT_STYLE_PLAIN
 };
 
@@ -102,7 +103,6 @@
 
    /* Defer this until after the mixer system has been setup */
    inst->ci = _mixer_config_item_get(mixer, id);
-   if (!inst->ci->id) inst->ci->id = evas_stringshare_add(id);
 
    if ((mixer->mix_sys->get_volume) && (inst->ci->card_id != 0) && 
(inst->ci->channel_id != 0))
      {
@@ -187,6 +187,15 @@
    return o;
 }
 
+static const char *
+_gc_id_new(void)
+{
+   Config_Item *ci;
+
+   ci = _mixer_config_item_get(NULL, NULL);
+   return ci->id;
+}
+
 void
 mixer_vol_increase(Instance *inst)
 {
@@ -322,14 +331,33 @@
    Mixer_Channel *chan;
    Evas_List     *l;
    Config_Item   *ci;
+   char buf[128];
 
    mixer = data;
-   
-   for (l = mixer_config->items; l; l = l->next)
+
+   if (!id)
+     {
+       int  num = 0;
+
+       /* Create id */
+       if (mixer_config->items)
+         {
+            const char *p;
+            ci = evas_list_last(mixer_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
      {
-       ci = l->data;
-       if (!ci->id) continue;
-       if (!strcmp(ci->id, id)) return ci;
+       for (l = mixer_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);



-------------------------------------------------------------------------
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

Reply via email to