Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-11-30 Thread Gustavo Sverzut Barbieri
On Tuesday, November 30, 2010, Daniel Juyung Seo  wrote:
>>
>>  By: WooHyun Jung 
>>
>
> k-s: see some one else is motivated :)

Yeah! Keep rocking!

>
>
> On Wed, Dec 1, 2010 at 3:53 AM, Enlightenment SVN
>  wrote:
>> Log:
>> Improve elm_colorselector readability and fix clicked entry sig emission
>>
>>  The reason for modifying about elm_colorselector can be "readability".
>>  Each bar in the colorselector has its own color type (like hue, saturation,
>>  ...)
>>  So I thought it will be better, if I added enum for each color type.
>>
>>  And, for about elm_entry.c , I thought that "SIG_CLICKED" was wrongly
>>  emitted (by "MOUSE_UP" event).
>>  I deleted mouse_up callback function (as you advised),
>>  because this function didn't do anything by my modification.
>>
>>  By: WooHyun Jung 
>>
>>
>> Author:       bdilly
>> Date:         2010-11-30 10:53:52 -0800 (Tue, 30 Nov 2010)
>> New Revision: 55097
>> Trac:         http://trac.enlightenment.org/e/changeset/55097
>>
>> Modified:
>>  trunk/TMP/st/elementary/src/lib/elm_colorselector.c 
>> trunk/TMP/st/elementary/src/lib/elm_entry.c
>>
>> Modified: trunk/TMP/st/elementary/src/lib/elm_colorselector.c
>> ===
>> --- trunk/TMP/st/elementary/src/lib/elm_colorselector.c 2010-11-30 18:51:16 
>> UTC (rev 55096)
>> +++ trunk/TMP/st/elementary/src/lib/elm_colorselector.c 2010-11-30 18:53:52 
>> UTC (rev 55097)
>> @@ -14,8 +14,22 @@
>>  #define LIG_STEP 256.0
>>  #define ALP_STEP 256.0
>>
>> +typedef enum _Button_State
>> +{
>> +   BUTTON_RELEASED,
>> +   L_BUTTON_PRESSED,
>> +   R_BUTTON_PRESSED
>> +} Button_State;
>> +
>> +typedef enum _Color_Type
>> +{
>> +   HUE,
>> +   SATURATION,
>> +   LIGHTNESS,
>> +   ALPHA
>> +} Color_Type;
>> +
>>  typedef struct _Colorselector_Data Colorselector_Data;
>> -
>>  struct _Colorselector_Data
>>  {
>>    Evas_Object *parent;
>> @@ -26,12 +40,11 @@
>>    Evas_Object *bg_rect;
>>    Evas_Object *arrow;
>>    Evas_Object *touch_area;
>> -   int colorselector_num;
>> -   int button_state;
>> +   Color_Type color_type;
>> +   Button_State button_state;
>>  };
>>
>>  typedef struct _Widget_Data Widget_Data;
>> -
>>  struct _Widget_Data
>>  {
>>    Evas_Object *base;
>> @@ -46,13 +59,6 @@
>>    Ecore_Timer *mv_timer;
>>  };
>>
>> -typedef enum
>> -{
>> -   BUTTON_RELEASED,
>> -   L_BUTTON_PRESSED,
>> -   R_BUTTON_PRESSED
>> -} Button_State;
>> -
>>  static const char *widtype = NULL;
>>
>>  static void _del_hook(Evas_Object *obj);
>> @@ -317,9 +323,9 @@
>>    Widget_Data *wd = elm_widget_data_get(cp->parent);
>>    double one_six = 1.0 / 6.0;
>>
>> -   switch (cp->colorselector_num)
>> +   switch (cp->color_type)
>>      {
>> -     case 0:
>> +     case HUE:
>>         wd->h = 360.0 * x;
>>
>>         if (x < one_six)
>> @@ -377,26 +383,25 @@
>>                               wd->a);
>>         break;
>>
>> -     case 1:
>> +     case SATURATION:
>>         wd->s = 1.0 - x;
>>         _color_with_saturation(wd);
>>         evas_object_color_set(wd->cp[1]->arrow, wd->sr, wd->sg, wd->sb, 255);
>>         break;
>>
>> -     case 2:
>> +     case LIGHTNESS:
>>         wd->l = x;
>>         _color_with_lightness(wd);
>>         evas_object_color_set(wd->cp[2]->arrow, wd->lr, wd->lg, wd->lb, 255);
>>         break;
>>
>> -     case 3:
>> +     case ALPHA:
>>         wd->a = 255.0 * x;
>>         evas_object_color_set(wd->cp[3]->arrow, wd->er, wd->eg, wd->eb, 
>> wd->a);
>>         break;
>>
>>      default:
>>         break;
>> -
>>      }
>>    _hsl_to_rgb(wd);
>>  }
>> @@ -502,10 +507,23 @@
>>                           "left_button");
>>    edje_object_part_drag_value_get(cp->colorbar, "elm.arrow", &x, &y);
>>
>> -   if (!cp->colorselector_num) x -= 1.0 / HUE_STEP;
>> -   else if (cp->colorselector_num == 1) x -= 1.0 / SAT_STEP;
>> -   else if (cp->colorselector_num == 2) x -= 1.0 / LIG_STEP;
>> -   else if (cp->colorselector_num == 3) x -= 1.0 / ALP_STEP;
>> +   switch(cp->color_type)
>> +     {
>> +      case HUE :
>> +         x -= 1.0 / HUE_STEP;
>> +         break;
>> +      case SATURATION :
>> +         x -= 1.0 / SAT_STEP;
>> +         break;
>> +      case LIGHTNESS :
>> +         x -= 1.0 / LIG_STEP;
>> +         break;
>> +      case ALPHA :
>> +         x -= 1.0 / ALP_STEP;
>> +         break;
>> +      default :
>> +         break;
>> +     }
>>
>>    if (x < 0.0) x = 0.0;
>>
>> @@ -528,10 +546,23 @@
>>                           "right_button");
>>    edje_object_part_drag_value_get(cp->colorbar, "elm.arrow", &x, &y);
>>
>> -   if (!cp->colorselector_num) x += 1.0 / HUE_STEP;
>> -   else if (cp->colorselector_num == 1) x += 1.0 / SAT_STEP;
>> -   else if (cp->colorselector_num == 2) x += 1.0 / LIG_STEP;
>> -   else if (cp->colorselector_num == 3) x += 1.0 / ALP_STEP;
>> +   switch(cp->color_type)
>> +     {
>> +      case HUE :
>> +         x += 1.0 / HUE_STEP;
>> +         break;
>> +      case SATURATION :
>> +         x += 1.0 / SAT_STEP;
>> +         break;
>

Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-11-30 Thread Daniel Juyung Seo
>
>  By: WooHyun Jung 
>

k-s: see some one else is motivated :)


On Wed, Dec 1, 2010 at 3:53 AM, Enlightenment SVN
 wrote:
> Log:
> Improve elm_colorselector readability and fix clicked entry sig emission
>
>  The reason for modifying about elm_colorselector can be "readability".
>  Each bar in the colorselector has its own color type (like hue, saturation,
>  ...)
>  So I thought it will be better, if I added enum for each color type.
>
>  And, for about elm_entry.c , I thought that "SIG_CLICKED" was wrongly
>  emitted (by "MOUSE_UP" event).
>  I deleted mouse_up callback function (as you advised),
>  because this function didn't do anything by my modification.
>
>  By: WooHyun Jung 
>
>
> Author:       bdilly
> Date:         2010-11-30 10:53:52 -0800 (Tue, 30 Nov 2010)
> New Revision: 55097
> Trac:         http://trac.enlightenment.org/e/changeset/55097
>
> Modified:
>  trunk/TMP/st/elementary/src/lib/elm_colorselector.c 
> trunk/TMP/st/elementary/src/lib/elm_entry.c
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_colorselector.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_colorselector.c 2010-11-30 18:51:16 
> UTC (rev 55096)
> +++ trunk/TMP/st/elementary/src/lib/elm_colorselector.c 2010-11-30 18:53:52 
> UTC (rev 55097)
> @@ -14,8 +14,22 @@
>  #define LIG_STEP 256.0
>  #define ALP_STEP 256.0
>
> +typedef enum _Button_State
> +{
> +   BUTTON_RELEASED,
> +   L_BUTTON_PRESSED,
> +   R_BUTTON_PRESSED
> +} Button_State;
> +
> +typedef enum _Color_Type
> +{
> +   HUE,
> +   SATURATION,
> +   LIGHTNESS,
> +   ALPHA
> +} Color_Type;
> +
>  typedef struct _Colorselector_Data Colorselector_Data;
> -
>  struct _Colorselector_Data
>  {
>    Evas_Object *parent;
> @@ -26,12 +40,11 @@
>    Evas_Object *bg_rect;
>    Evas_Object *arrow;
>    Evas_Object *touch_area;
> -   int colorselector_num;
> -   int button_state;
> +   Color_Type color_type;
> +   Button_State button_state;
>  };
>
>  typedef struct _Widget_Data Widget_Data;
> -
>  struct _Widget_Data
>  {
>    Evas_Object *base;
> @@ -46,13 +59,6 @@
>    Ecore_Timer *mv_timer;
>  };
>
> -typedef enum
> -{
> -   BUTTON_RELEASED,
> -   L_BUTTON_PRESSED,
> -   R_BUTTON_PRESSED
> -} Button_State;
> -
>  static const char *widtype = NULL;
>
>  static void _del_hook(Evas_Object *obj);
> @@ -317,9 +323,9 @@
>    Widget_Data *wd = elm_widget_data_get(cp->parent);
>    double one_six = 1.0 / 6.0;
>
> -   switch (cp->colorselector_num)
> +   switch (cp->color_type)
>      {
> -     case 0:
> +     case HUE:
>         wd->h = 360.0 * x;
>
>         if (x < one_six)
> @@ -377,26 +383,25 @@
>                               wd->a);
>         break;
>
> -     case 1:
> +     case SATURATION:
>         wd->s = 1.0 - x;
>         _color_with_saturation(wd);
>         evas_object_color_set(wd->cp[1]->arrow, wd->sr, wd->sg, wd->sb, 255);
>         break;
>
> -     case 2:
> +     case LIGHTNESS:
>         wd->l = x;
>         _color_with_lightness(wd);
>         evas_object_color_set(wd->cp[2]->arrow, wd->lr, wd->lg, wd->lb, 255);
>         break;
>
> -     case 3:
> +     case ALPHA:
>         wd->a = 255.0 * x;
>         evas_object_color_set(wd->cp[3]->arrow, wd->er, wd->eg, wd->eb, 
> wd->a);
>         break;
>
>      default:
>         break;
> -
>      }
>    _hsl_to_rgb(wd);
>  }
> @@ -502,10 +507,23 @@
>                           "left_button");
>    edje_object_part_drag_value_get(cp->colorbar, "elm.arrow", &x, &y);
>
> -   if (!cp->colorselector_num) x -= 1.0 / HUE_STEP;
> -   else if (cp->colorselector_num == 1) x -= 1.0 / SAT_STEP;
> -   else if (cp->colorselector_num == 2) x -= 1.0 / LIG_STEP;
> -   else if (cp->colorselector_num == 3) x -= 1.0 / ALP_STEP;
> +   switch(cp->color_type)
> +     {
> +      case HUE :
> +         x -= 1.0 / HUE_STEP;
> +         break;
> +      case SATURATION :
> +         x -= 1.0 / SAT_STEP;
> +         break;
> +      case LIGHTNESS :
> +         x -= 1.0 / LIG_STEP;
> +         break;
> +      case ALPHA :
> +         x -= 1.0 / ALP_STEP;
> +         break;
> +      default :
> +         break;
> +     }
>
>    if (x < 0.0) x = 0.0;
>
> @@ -528,10 +546,23 @@
>                           "right_button");
>    edje_object_part_drag_value_get(cp->colorbar, "elm.arrow", &x, &y);
>
> -   if (!cp->colorselector_num) x += 1.0 / HUE_STEP;
> -   else if (cp->colorselector_num == 1) x += 1.0 / SAT_STEP;
> -   else if (cp->colorselector_num == 2) x += 1.0 / LIG_STEP;
> -   else if (cp->colorselector_num == 3) x += 1.0 / ALP_STEP;
> +   switch(cp->color_type)
> +     {
> +      case HUE :
> +         x += 1.0 / HUE_STEP;
> +         break;
> +      case SATURATION :
> +         x += 1.0 / SAT_STEP;
> +         break;
> +      case LIGHTNESS :
> +         x += 1.0 / LIG_STEP;
> +         break;
> +      case ALPHA :
> +         x += 1.0 / ALP_STEP;
> +         break;
> +      default :
> +         break;
> +     }
>
>    if (x > 1.0) x = 1.0;
>
> @@ -602,11 +633,25 @@
>    for

Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Gustavo Sverzut Barbieri
On Tue, Oct 19, 2010 at 10:26 AM, Lucas De Marchi
 wrote:
> On Tue, Oct 19, 2010 at 10:19 AM, Gustavo Sverzut Barbieri
>  wrote:
>> This seems good, but would it handle the following cases?
>>
>> 1.
>>
>> void name_set(struct my_struct *p, const char *name) {
>>    eina_stringshare_replace(&p->str, name); // could be a simple 
>> eina_stringshare_add() as well
>> }
>> const char *name_get(const struct my_struct *p) {
>>    return p->str;
>> }
>> Eina_Bool use_it(const struct my_struct *p) {
>>     return strlen(p->str) % 2; // should be eina_stringshare_strlen()
>> }
>>
>
> As I told, right now it will not handle this case. But it can be
> extended to do so.

then it will not handle most of our cases :-/  Actually if it's in the form:

const char *s = eina_stringshare_add(bla);
size_t len = eina_stringshare_strlen(s);

it's better (minimal performance gains) to write it like:
size_t len = strlen(bla); // if you know it's !NULL
const char *s = eina_stringshare_add_length(bla, len);

as internally eina_stringshare_add_length() will be called by
eina_stringshare_add(), and strlen() is often optimized by the
compiler if possible (ie: instead of bla you have "string" it turns it
into sizeof("string")-1).



>> 2.
>> Eina_Bool use_it(const char *s) {
>>     return strlen(x) % 2; // should not be eina_stringshare_strlen()
>> }
>>
>> use_it(name_get(p));
>> use_it("hello");
>
> If you meant "return strlen(s) % 2", yes, this would not be changed.

typos :-D that's why we should not write programs in MS word kids! ;-)


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Lucas De Marchi
On Tue, Oct 19, 2010 at 10:19 AM, Gustavo Sverzut Barbieri
 wrote:
> This seems good, but would it handle the following cases?
>
> 1.
>
> void name_set(struct my_struct *p, const char *name) {
>    eina_stringshare_replace(&p->str, name); // could be a simple 
> eina_stringshare_add() as well
> }
> const char *name_get(const struct my_struct *p) {
>    return p->str;
> }
> Eina_Bool use_it(const struct my_struct *p) {
>     return strlen(p->str) % 2; // should be eina_stringshare_strlen()
> }
>

As I told, right now it will not handle this case. But it can be
extended to do so.

>
> 2.
> Eina_Bool use_it(const char *s) {
>     return strlen(x) % 2; // should not be eina_stringshare_strlen()
> }
>
> use_it(name_get(p));
> use_it("hello");

If you meant "return strlen(s) % 2", yes, this would not be changed.



Lucas De Marchi

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Gustavo Sverzut Barbieri
On Tue, Oct 19, 2010 at 10:08 AM, Lucas De Marchi
 wrote:
> On Tue, Oct 19, 2010 at 9:54 AM, Gustavo Sverzut Barbieri
>  wrote:
>> I guess it's hard if not impossible to know for sure, unfortunately we
>> have no way to tell from a const char* if it came from stringshare or
>> regular malloc :-/
>
>
> What about the following first attempt of a semantic patch? The
> assumption here is that if a pointer is used once as stringshare
> (therefore there's a call to eina_stringshare_add()) it will always be
> used as stringshare. It seems reasonable to me... I didn't check if it
> works across different compilation units though and it misses the case
> where the pointer is the return value of a function returning a
> stringshare (possibly just using eina_stringshare_ref()).
>
> It might not get all cases, but I can't think in a case where it would
> have a false positive. If anyone is interested in learning Coccinelle
> (there were so many at irc asking me about this), this is a good start
> point.
>
>
> // 
> // Prefer the use of eina_stringshare_strlen() over strlen()
> //
> // If a string is stringshared, use eina_stringshare_strlen() that is O(1)
> // instead of strlen();
> //
>
> @r1@
> expression x;
> @@
>
> x = eina_stringshare_add(...)
>
> @r2@
> expression r1.x;
> @@
> - strlen(x)
> + eina_stringshare_strlen(x)

This seems good, but would it handle the following cases?

1.

void name_set(struct my_struct *p, const char *name) {
eina_stringshare_replace(&p->str, name); // could be a simple
eina_stringshare_add() as well
}
const char *name_get(const struct my_struct *p) {
return p->str;
}
Eina_Bool use_it(const struct my_struct *p) {
 return strlen(p->str) % 2; // should be eina_stringshare_strlen()
}


2.
Eina_Bool use_it(const char *s) {
 return strlen(x) % 2; // should not be eina_stringshare_strlen()
}

use_it(name_get(p));
use_it("hello");

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Lucas De Marchi
On Tue, Oct 19, 2010 at 9:54 AM, Gustavo Sverzut Barbieri
 wrote:
> I guess it's hard if not impossible to know for sure, unfortunately we
> have no way to tell from a const char* if it came from stringshare or
> regular malloc :-/


What about the following first attempt of a semantic patch? The
assumption here is that if a pointer is used once as stringshare
(therefore there's a call to eina_stringshare_add()) it will always be
used as stringshare. It seems reasonable to me... I didn't check if it
works across different compilation units though and it misses the case
where the pointer is the return value of a function returning a
stringshare (possibly just using eina_stringshare_ref()).

It might not get all cases, but I can't think in a case where it would
have a false positive. If anyone is interested in learning Coccinelle
(there were so many at irc asking me about this), this is a good start
point.


// 
// Prefer the use of eina_stringshare_strlen() over strlen()
//
// If a string is stringshared, use eina_stringshare_strlen() that is O(1)
// instead of strlen();
//

@r1@
expression x;
@@

x = eina_stringshare_add(...)

@r2@
expression r1.x;
@@
- strlen(x)
+ eina_stringshare_strlen(x)

// 



Lucas De Marchi

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Gustavo Sverzut Barbieri
On Tue, Oct 19, 2010 at 9:38 AM, Bruno Dilly  wrote:
> On Tue, Oct 19, 2010 at 9:34 AM, Lucas De Marchi
>  wrote:
>> On Tue, Oct 19, 2010 at 8:58 AM, Gustavo Sverzut Barbieri
>>  wrote:
 --- trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 
 05:58:26 UTC (rev 53590)
 +++ trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 
 10:48:11 UTC (rev 53591)
 @@ -388,13 +388,15 @@

    EINA_LIST_FOREACH(list, l, it)
      {
 -        int len = strlen(it->label);
         Evas_Coord x, w;
 +        int len;
         evas_object_geometry_get(it->base.view, &x, NULL, &w, NULL);
         /* item not visible */
         if (x + w <= ox || x >= ox + ow)
           continue;

 +        len = strlen(it->label);
>>>
>>> likely what's in an internal item should be stringshared, then
>>> eina_stringshare_strlen() is O(1) :-)
>>
>> Do you want an automatic conversion from strlen() to
>> eina_stringshare_strlen() when the parameter is indeed stringshared?
>> It's pretty easy for coccinelle
>
> I'm wondering how much strlen calls instead of eina_stringshare_strlen are 
> done.
> If it's not complicated to do, I believe it would be great! =D

I guess it's hard if not impossible to know for sure, unfortunately we
have no way to tell from a const char* if it came from stringshare or
regular malloc :-/

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Bruno Dilly
On Tue, Oct 19, 2010 at 9:34 AM, Lucas De Marchi
 wrote:
> On Tue, Oct 19, 2010 at 8:58 AM, Gustavo Sverzut Barbieri
>  wrote:
>>> --- trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 05:58:26 
>>> UTC (rev 53590)
>>> +++ trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 10:48:11 
>>> UTC (rev 53591)
>>> @@ -388,13 +388,15 @@
>>>
>>>    EINA_LIST_FOREACH(list, l, it)
>>>      {
>>> -        int len = strlen(it->label);
>>>         Evas_Coord x, w;
>>> +        int len;
>>>         evas_object_geometry_get(it->base.view, &x, NULL, &w, NULL);
>>>         /* item not visible */
>>>         if (x + w <= ox || x >= ox + ow)
>>>           continue;
>>>
>>> +        len = strlen(it->label);
>>
>> likely what's in an internal item should be stringshared, then
>> eina_stringshare_strlen() is O(1) :-)
>
> Do you want an automatic conversion from strlen() to
> eina_stringshare_strlen() when the parameter is indeed stringshared?
> It's pretty easy for coccinelle

I'm wondering how much strlen calls instead of eina_stringshare_strlen are done.
If it's not complicated to do, I believe it would be great! =D

>
>
>
> Lucas De Marchi
>
> --
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> ___
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Lucas De Marchi
On Tue, Oct 19, 2010 at 8:58 AM, Gustavo Sverzut Barbieri
 wrote:
>> --- trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 05:58:26 
>> UTC (rev 53590)
>> +++ trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 10:48:11 
>> UTC (rev 53591)
>> @@ -388,13 +388,15 @@
>>
>>    EINA_LIST_FOREACH(list, l, it)
>>      {
>> -        int len = strlen(it->label);
>>         Evas_Coord x, w;
>> +        int len;
>>         evas_object_geometry_get(it->base.view, &x, NULL, &w, NULL);
>>         /* item not visible */
>>         if (x + w <= ox || x >= ox + ow)
>>           continue;
>>
>> +        len = strlen(it->label);
>
> likely what's in an internal item should be stringshared, then
> eina_stringshare_strlen() is O(1) :-)

Do you want an automatic conversion from strlen() to
eina_stringshare_strlen() when the parameter is indeed stringshared?
It's pretty easy for coccinelle



Lucas De Marchi

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-19 Thread Gustavo Sverzut Barbieri
On Tue, Oct 19, 2010 at 8:48 AM, Enlightenment SVN
 wrote:
> Log:
>  elm_diskpicker: save (list_len - 3) strlen calls
>
>  demarchi-- for reducing performance just to solve a comparison between
>  signed and unsigned.
>
>
> Author:       bdilly
> Date:         2010-10-19 03:48:11 -0700 (Tue, 19 Oct 2010)
> New Revision: 53591
>
> Modified:
>  trunk/TMP/st/elementary/src/lib/elm_diskpicker.c
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_diskpicker.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 05:58:26 
> UTC (rev 53590)
> +++ trunk/TMP/st/elementary/src/lib/elm_diskpicker.c    2010-10-19 10:48:11 
> UTC (rev 53591)
> @@ -388,13 +388,15 @@
>
>    EINA_LIST_FOREACH(list, l, it)
>      {
> -        int len = strlen(it->label);
>         Evas_Coord x, w;
> +        int len;
>         evas_object_geometry_get(it->base.view, &x, NULL, &w, NULL);
>         /* item not visible */
>         if (x + w <= ox || x >= ox + ow)
>           continue;
>
> +        len = strlen(it->label);

likely what's in an internal item should be stringshared, then
eina_stringshare_strlen() is O(1) :-)


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-10-18 Thread Brett Nash
On Mon, 18 Oct 2010 11:15:59 -0700
"Enlightenment SVN"  wrote:

> Log:
>   Fixes for clang warnings
>   
> Author:   bdilly
> Date: 2010-10-18 11:15:59 -0700 (Mon, 18 Oct 2010)
> New Revision: 53576
> 
> Modified:
>   trunk/TMP/st/elementary/src/lib/elm_cnp_helper.c
> trunk/TMP/st/elementary/src/lib/elm_menu.c 
> 
> Modified: trunk/TMP/st/elementary/src/lib/elm_cnp_helper.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_cnp_helper.c
> 2010-10-18 18:05:22 UTC (rev 53575) +++
> trunk/TMP/st/elementary/src/lib/elm_cnp_helper.c  2010-10-18
> 18:15:59 UTC (rev 53576) @@ -1160,7 +1160,7 @@ int i;
>  
> /* Skip it */
> -   if (enter->num_types == 0 || enter->types == NULL) return true;
> +   if (!enter || !enter->num_types || !enter->types) return
> EINA_TRUE; 

The function argument should be annotated here, it's an appropriate
place for a not null as it's a callback.  If ecore is sending NULL to
it's callbacks, all bets are off.  



Regards,
nash

--
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-06-25 Thread Gustavo Sverzut Barbieri
Listen and unlisten are quite bad. Keep Edje name compat as did for
emit. I know it may be used differently, but even them
signal_callback_add is good

On Friday, June 25, 2010, Enlightenment SVN  wrote:
> Log:
>   Implement elm_object_signal_listen and unlisten
>
>   elm_object_signal_listen add callback(s) for edje object(s) of the widget.
>   elm_object_signal_unlisten delete this callback.
>   They're general functions, and every widget should set hooks for these.
>
>   It will improve elm extension flexibility. We have already
>   elm_object_signal_emit to send signals for the widgets theme, adding 
> callbacks
>   is an expected step.
>
>   It provides a way to support sound on widgets. For example, in the elm 
> extension
>   we could emit "file_to_play", "play", and add a callback with
>   elm_object_signal_listen for "*", "play". The callback function could use
>   the signal received to request the file to be played by the backend
>   sound system.
>
>   Certainly we should look for a better way to provide support for sound
>   on edje, but for now, it does the work. And anyway, it's only a use case
>   for these new functions.
>
>
> Author:       bdilly
> Date:         2010-06-25 15:38:32 -0700 (Fri, 25 Jun 2010)
> New Revision: 49868
>
> Modified:
>   trunk/TMP/st/elementary/src/lib/Elementary.h.in 
> trunk/TMP/st/elementary/src/lib/elm_main.c 
> trunk/TMP/st/elementary/src/lib/elm_priv.h 
> trunk/TMP/st/elementary/src/lib/elm_widget.c
>
> Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in
> ===
> --- trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-06-25 22:28:06 
> UTC (rev 49867)
> +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-06-25 22:38:32 
> UTC (rev 49868)
> @@ -288,6 +288,8 @@
>     EAPI void         elm_object_scroll_freeze_pop(Evas_Object *obj);
>
>     EAPI void         elm_object_signal_emit(Evas_Object *obj, const char 
> *emission, const char *source);
> +   EAPI void         elm_object_signal_listen(Evas_Object *obj, const char 
> *emission, const char *source, void (*func) (void *data, Evas_Object *o, 
> const char *emission, const char *source), void *data);
> +   EAPI void         *elm_object_signal_unlisten(Evas_Object *obj, const 
> char *emission, const char *source, void (*func) (void *data, Evas_Object *o, 
> const char *emission, const char *source));
>
>     EAPI void         elm_coords_finger_size_adjust(int times_w, Evas_Coord 
> *w, int times_h, Evas_Coord *h);
>
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_main.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_main.c  2010-06-25 22:28:06 UTC (rev 
> 49867)
> +++ trunk/TMP/st/elementary/src/lib/elm_main.c  2010-06-25 22:38:32 UTC (rev 
> 49868)
> @@ -1409,3 +1409,45 @@
>  {
>      elm_widget_signal_emit(obj, emission, source);
>  }
> +
> +/**
> + * Add a callback for a signal emitted by widget edje object.
> + *
> + * This function connects a callback function to a signal emitted by the
> + * edje object of the obj.
> + * Globs can occur in either the emission or source name.
> + *
> + * @param obj The object
> + * @param emission The signal's name.
> + * @param source The signal's source.
> + * @param func The callback function to be executed when the signal is
> + * emitted.
> + * @param data A pointer to data to pass in to the callback function.
> + * @ingroup General
> + */
> +EAPI void elm_object_signal_listen(Evas_Object *obj, const char *emission, 
> const char *source, void (*func) (void *data, Evas_Object *o, const char 
> *emission, const char *source), void *data)
> +{
> +    elm_widget_signal_listen(obj, emission, source, func, data);
> +}
> +
> +/**
> + * Remove a signal-triggered callback from an widget edje object.
> + *
> + * This function removes a callback, previoulsy attached to a signal emitted
> + * by the edje object of the obj.
> + * The parameters emission, source and func must match exactly those passed 
> to
> + * a previous call to elm_object_signal_listen(). The data pointer that
> + * was passed to this call will be returned.
> + *
> + * @param obj The object
> + * @param emission The signal's name.
> + * @param source The signal's source.
> + * @param func The callback function to be executed when the signal is
> + * emitted.
> + * @return The data pointer
> + * @ingroup General
> + */
> +EAPI void *elm_object_signal_unlisten(Evas_Object *obj, const char 
> *emission, const char *source, void (*func) (void *data, Evas_Object *o, 
> const char *emission, const char *source))
> +{
> +    return elm_widget_signal_unlisten(obj, emission, source, func);
> +}
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_priv.h
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_priv.h  2010-06-25 22:28:06 UTC (rev 
> 49867)
> +++ trunk/TMP/st/elementary/src/lib/elm_priv.h  2010-06-25 22

Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-06-07 Thread Gustavo Sverzut Barbieri
On Mon, Jun 7, 2010 at 10:43 AM, Enlightenment SVN
 wrote:
> Log:
>  oops - forgot to return CALLBACK_CANCEL on elm_clock
>
>
> Author:       bdilly
> Date:         2010-06-07 06:43:07 -0700 (Mon, 07 Jun 2010)
> New Revision: 49553
>
> Modified:
>  trunk/TMP/st/elementary/src/lib/elm_clock.c
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_clock.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_clock.c 2010-06-07 13:08:19 UTC (rev 
> 49552)
> +++ trunk/TMP/st/elementary/src/lib/elm_clock.c 2010-06-07 13:43:07 UTC (rev 
> 49553)
> @@ -115,9 +115,9 @@
>  _signal_clock_val_up(void *data)
>  {
>    Widget_Data *wd = elm_widget_data_get(data);
> -   if (!wd) return;
> -   if (!wd->edit) return;
> -   if (!wd->sel_obj) return;
> +   if (!wd) return ECORE_CALLBACK_CANCEL;
> +   if (!wd->edit) return ECORE_CALLBACK_CANCEL;
> +   if (!wd->sel_obj) return ECORE_CALLBACK_CANCEL;
>    if (wd->sel_obj == wd->digit[0])
>      {
>        wd->hrs = wd->hrs + 10;
> @@ -164,9 +164,9 @@
>  _signal_clock_val_down(void *data)
>  {
>    Widget_Data *wd = elm_widget_data_get(data);
> -   if (!wd) return;
> -   if (!wd->edit) return;
> -   if (!wd->sel_obj) return;
> +   if (!wd) return ECORE_CALLBACK_CANCEL;
> +   if (!wd->edit) return ECORE_CALLBACK_CANCEL;
> +   if (!wd->sel_obj) return ECORE_CALLBACK_CANCEL;

I did not look this code in depth, but if you return
ECORE_CALLBACK_CANCEL (or 0) then this function
timer/animator/whatever is deleted. It is likely that you still hold a
pointer to its handle (Ecore_Timer, Ecore_Animator...) and thus you
must NULL-ify it, otherwise you'll later on delete a dead pointer and
crash.

If you don't have the reference and delete it at exit, then it is
another bug :-)

BR,

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-05-24 Thread Sachiel
On Mon, May 24, 2010 at 10:48 PM, Bruno Dilly  wrote:
> On Mon, May 24, 2010 at 12:06 AM, Iván Briano (Sachiel)
>  wrote:
>> On Mon, May 24, 2010 at 8:41 AM, Enlightenment SVN
>>  wrote:
>>> Log:
>>>  Implement elm index sorted insert
>>>   - Name index item as Elm_Index_Item
>>>   - Add some other index functions:
>>>     + Item find
>>>     + Data get/set
>>>     + Letter get
>>>
>>>  I think this stuff will make easier to create index for
>>>  dynamically created lists.
>>>
>>> Author:       bdilly
>>> Date:         2010-05-23 16:41:32 -0700 (Sun, 23 May 2010)
>>> New Revision: 49171
>>>
>>> Modified:
>>>  trunk/TMP/st/elementary/src/lib/Elementary.h.in 
>>> trunk/TMP/st/elementary/src/lib/elm_index.c
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in
>>> ===
>>> --- trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:23:51 
>>> UTC (rev 49170)
>>> +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:41:32 
>>> UTC (rev 49171)
>>> @@ -1266,6 +1266,7 @@
>>>     * vertical (two up/down buttons at the right side and text left aligned)
>>>     */
>>>
>>> +   typedef struct _Elm_Index_Item Elm_Index_Item;
>>>    EAPI Evas_Object *elm_index_add(Evas_Object *parent);
>>>    EAPI void         elm_index_active_set(Evas_Object *obj, Eina_Bool 
>>> active);
>>>    EAPI void         elm_index_item_level_set(Evas_Object *obj, int level);
>>> @@ -1275,9 +1276,14 @@
>>>    EAPI void         elm_index_item_prepend(Evas_Object *obj, const char 
>>> *letter, const void *item);
>>>    EAPI void         elm_index_item_append_relative(Evas_Object *obj, const 
>>> char *letter, const void *item, const void *relative);
>>>    EAPI void         elm_index_item_prepend_relative(Evas_Object *obj, 
>>> const char *letter, const void *item, const void *relative);
>>> +   EAPI void         elm_index_item_sorted_insert(Evas_Object *obj, const 
>>> char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb 
>>> cmp_data_func);
>>>    EAPI void         elm_index_item_del(Evas_Object *obj, const void *item);
>>> +   EAPI Elm_Index_Item *elm_index_item_find(Evas_Object *obj, const void 
>>> *item);
>>>    EAPI void         elm_index_item_clear(Evas_Object *obj);
>>>    EAPI void         elm_index_item_go(Evas_Object *obj, int level);
>>> +   EAPI void         *elm_index_item_data_get(const Elm_Index_Item *item);
>>> +   EAPI void         elm_index_item_data_set(Elm_Index_Item *it, const 
>>> void *data);
>>> +   EAPI const char   *elm_index_item_letter_get(const Elm_Index_Item 
>>> *item);
>>>    /* smart callbacks called:
>>>     * "changed" - when the selected index item changes
>>>     * "delay,changed" - when the selected index item changes, but after 
>>> some small idle period
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/elm_index.c
>>> ===
>>> --- trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:23:51 UTC 
>>> (rev 49170)
>>> +++ trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:41:32 UTC 
>>> (rev 49171)
>>> @@ -9,7 +9,6 @@
>>>  */
>>>
>>>  typedef struct _Widget_Data Widget_Data;
>>> -typedef struct _Item Item;
>>>
>>>  struct _Widget_Data
>>>  {
>>> @@ -26,7 +25,7 @@
>>>    Eina_Bool down : 1;
>>>  };
>>>
>>> -struct _Item
>>> +struct _Elm_Index_Item
>>>  {
>>>    Evas_Object *obj;
>>>    const char *letter;
>>> @@ -42,13 +41,13 @@
>>>  static void _sizing_eval(Evas_Object *obj);
>>>  static void _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int 
>>> level);
>>>  static void _index_box_clear(Evas_Object *obj, Evas_Object *box, int 
>>> level);
>>> -static void _item_free(Item *it);
>>> +static void _item_free(Elm_Index_Item *it);
>>>
>>>  static void
>>>  _del_hook(Evas_Object *obj)
>>>  {
>>>    Widget_Data *wd = elm_widget_data_get(obj);
>>> -   Item *it;
>>> +   Elm_Index_Item *it;
>>>    Eina_List *l, *clear = NULL;
>>>    if (!wd) return;
>>>    _index_box_clear(obj, wd->bx[wd->level], wd->level);
>>> @@ -138,13 +137,13 @@
>>>    evas_object_size_hint_max_set(obj, maxw, maxh);
>>>  }
>>>
>>> -static Item *
>>> +static Elm_Index_Item *
>>>  _item_new(Evas_Object *obj, const char *letter, const void *item)
>>>  {
>>>    Widget_Data *wd = elm_widget_data_get(obj);
>>> -   Item *it;
>>> +   Elm_Index_Item *it;
>>>    if (!wd) return NULL;
>>> -   it = calloc(1, sizeof(Item));
>>> +   it = calloc(1, sizeof(Elm_Index_Item));
>>>    if (!it) return NULL;
>>>    it->obj = obj;
>>>    it->letter = eina_stringshare_add(letter);
>>> @@ -153,12 +152,12 @@
>>>    return it;
>>>  }
>>>
>>> -static Item *
>>> +static Elm_Index_Item *
>>>  _item_find(Evas_Object *obj, const void *item)
>>>  {
>>>    Widget_Data *wd = elm_widget_data_get(obj);
>>>    Eina_List *l;
>>> -   Item *it;
>>> +   Elm_Index_Item *it;
>>>    if (!wd) return NULL;
>>>    EINA_LIST_FOREACH(wd->items, l, it)
>>>      if (it->data == item) return it;

Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-05-24 Thread Bruno Dilly
On Mon, May 24, 2010 at 12:06 AM, Iván Briano (Sachiel)
 wrote:
> On Mon, May 24, 2010 at 8:41 AM, Enlightenment SVN
>  wrote:
>> Log:
>>  Implement elm index sorted insert
>>   - Name index item as Elm_Index_Item
>>   - Add some other index functions:
>>     + Item find
>>     + Data get/set
>>     + Letter get
>>
>>  I think this stuff will make easier to create index for
>>  dynamically created lists.
>>
>> Author:       bdilly
>> Date:         2010-05-23 16:41:32 -0700 (Sun, 23 May 2010)
>> New Revision: 49171
>>
>> Modified:
>>  trunk/TMP/st/elementary/src/lib/Elementary.h.in 
>> trunk/TMP/st/elementary/src/lib/elm_index.c
>>
>> Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in
>> ===
>> --- trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:23:51 
>> UTC (rev 49170)
>> +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:41:32 
>> UTC (rev 49171)
>> @@ -1266,6 +1266,7 @@
>>     * vertical (two up/down buttons at the right side and text left aligned)
>>     */
>>
>> +   typedef struct _Elm_Index_Item Elm_Index_Item;
>>    EAPI Evas_Object *elm_index_add(Evas_Object *parent);
>>    EAPI void         elm_index_active_set(Evas_Object *obj, Eina_Bool 
>> active);
>>    EAPI void         elm_index_item_level_set(Evas_Object *obj, int level);
>> @@ -1275,9 +1276,14 @@
>>    EAPI void         elm_index_item_prepend(Evas_Object *obj, const char 
>> *letter, const void *item);
>>    EAPI void         elm_index_item_append_relative(Evas_Object *obj, const 
>> char *letter, const void *item, const void *relative);
>>    EAPI void         elm_index_item_prepend_relative(Evas_Object *obj, const 
>> char *letter, const void *item, const void *relative);
>> +   EAPI void         elm_index_item_sorted_insert(Evas_Object *obj, const 
>> char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb 
>> cmp_data_func);
>>    EAPI void         elm_index_item_del(Evas_Object *obj, const void *item);
>> +   EAPI Elm_Index_Item *elm_index_item_find(Evas_Object *obj, const void 
>> *item);
>>    EAPI void         elm_index_item_clear(Evas_Object *obj);
>>    EAPI void         elm_index_item_go(Evas_Object *obj, int level);
>> +   EAPI void         *elm_index_item_data_get(const Elm_Index_Item *item);
>> +   EAPI void         elm_index_item_data_set(Elm_Index_Item *it, const void 
>> *data);
>> +   EAPI const char   *elm_index_item_letter_get(const Elm_Index_Item *item);
>>    /* smart callbacks called:
>>     * "changed" - when the selected index item changes
>>     * "delay,changed" - when the selected index item changes, but after some 
>> small idle period
>>
>> Modified: trunk/TMP/st/elementary/src/lib/elm_index.c
>> ===
>> --- trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:23:51 UTC (rev 
>> 49170)
>> +++ trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:41:32 UTC (rev 
>> 49171)
>> @@ -9,7 +9,6 @@
>>  */
>>
>>  typedef struct _Widget_Data Widget_Data;
>> -typedef struct _Item Item;
>>
>>  struct _Widget_Data
>>  {
>> @@ -26,7 +25,7 @@
>>    Eina_Bool down : 1;
>>  };
>>
>> -struct _Item
>> +struct _Elm_Index_Item
>>  {
>>    Evas_Object *obj;
>>    const char *letter;
>> @@ -42,13 +41,13 @@
>>  static void _sizing_eval(Evas_Object *obj);
>>  static void _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int 
>> level);
>>  static void _index_box_clear(Evas_Object *obj, Evas_Object *box, int level);
>> -static void _item_free(Item *it);
>> +static void _item_free(Elm_Index_Item *it);
>>
>>  static void
>>  _del_hook(Evas_Object *obj)
>>  {
>>    Widget_Data *wd = elm_widget_data_get(obj);
>> -   Item *it;
>> +   Elm_Index_Item *it;
>>    Eina_List *l, *clear = NULL;
>>    if (!wd) return;
>>    _index_box_clear(obj, wd->bx[wd->level], wd->level);
>> @@ -138,13 +137,13 @@
>>    evas_object_size_hint_max_set(obj, maxw, maxh);
>>  }
>>
>> -static Item *
>> +static Elm_Index_Item *
>>  _item_new(Evas_Object *obj, const char *letter, const void *item)
>>  {
>>    Widget_Data *wd = elm_widget_data_get(obj);
>> -   Item *it;
>> +   Elm_Index_Item *it;
>>    if (!wd) return NULL;
>> -   it = calloc(1, sizeof(Item));
>> +   it = calloc(1, sizeof(Elm_Index_Item));
>>    if (!it) return NULL;
>>    it->obj = obj;
>>    it->letter = eina_stringshare_add(letter);
>> @@ -153,12 +152,12 @@
>>    return it;
>>  }
>>
>> -static Item *
>> +static Elm_Index_Item *
>>  _item_find(Evas_Object *obj, const void *item)
>>  {
>>    Widget_Data *wd = elm_widget_data_get(obj);
>>    Eina_List *l;
>> -   Item *it;
>> +   Elm_Index_Item *it;
>>    if (!wd) return NULL;
>>    EINA_LIST_FOREACH(wd->items, l, it)
>>      if (it->data == item) return it;
>> @@ -166,7 +165,7 @@
>>  }
>>
>>  static void
>> -_item_free(Item *it)
>> +_item_free(Elm_Index_Item *it)
>>  {
>>    Widget_Data *wd = elm_widget_data_get(it->obj);
>>    if (!wd) return;
>> @@ -18

Re: [E-devel] E SVN: bdilly trunk/TMP/st/elementary/src/lib

2010-05-23 Thread Sachiel
On Mon, May 24, 2010 at 8:41 AM, Enlightenment SVN
 wrote:
> Log:
>  Implement elm index sorted insert
>   - Name index item as Elm_Index_Item
>   - Add some other index functions:
>     + Item find
>     + Data get/set
>     + Letter get
>
>  I think this stuff will make easier to create index for
>  dynamically created lists.
>
> Author:       bdilly
> Date:         2010-05-23 16:41:32 -0700 (Sun, 23 May 2010)
> New Revision: 49171
>
> Modified:
>  trunk/TMP/st/elementary/src/lib/Elementary.h.in 
> trunk/TMP/st/elementary/src/lib/elm_index.c
>
> Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in
> ===
> --- trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:23:51 
> UTC (rev 49170)
> +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-05-23 23:41:32 
> UTC (rev 49171)
> @@ -1266,6 +1266,7 @@
>     * vertical (two up/down buttons at the right side and text left aligned)
>     */
>
> +   typedef struct _Elm_Index_Item Elm_Index_Item;
>    EAPI Evas_Object *elm_index_add(Evas_Object *parent);
>    EAPI void         elm_index_active_set(Evas_Object *obj, Eina_Bool active);
>    EAPI void         elm_index_item_level_set(Evas_Object *obj, int level);
> @@ -1275,9 +1276,14 @@
>    EAPI void         elm_index_item_prepend(Evas_Object *obj, const char 
> *letter, const void *item);
>    EAPI void         elm_index_item_append_relative(Evas_Object *obj, const 
> char *letter, const void *item, const void *relative);
>    EAPI void         elm_index_item_prepend_relative(Evas_Object *obj, const 
> char *letter, const void *item, const void *relative);
> +   EAPI void         elm_index_item_sorted_insert(Evas_Object *obj, const 
> char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb 
> cmp_data_func);
>    EAPI void         elm_index_item_del(Evas_Object *obj, const void *item);
> +   EAPI Elm_Index_Item *elm_index_item_find(Evas_Object *obj, const void 
> *item);
>    EAPI void         elm_index_item_clear(Evas_Object *obj);
>    EAPI void         elm_index_item_go(Evas_Object *obj, int level);
> +   EAPI void         *elm_index_item_data_get(const Elm_Index_Item *item);
> +   EAPI void         elm_index_item_data_set(Elm_Index_Item *it, const void 
> *data);
> +   EAPI const char   *elm_index_item_letter_get(const Elm_Index_Item *item);
>    /* smart callbacks called:
>     * "changed" - when the selected index item changes
>     * "delay,changed" - when the selected index item changes, but after some 
> small idle period
>
> Modified: trunk/TMP/st/elementary/src/lib/elm_index.c
> ===
> --- trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:23:51 UTC (rev 
> 49170)
> +++ trunk/TMP/st/elementary/src/lib/elm_index.c 2010-05-23 23:41:32 UTC (rev 
> 49171)
> @@ -9,7 +9,6 @@
>  */
>
>  typedef struct _Widget_Data Widget_Data;
> -typedef struct _Item Item;
>
>  struct _Widget_Data
>  {
> @@ -26,7 +25,7 @@
>    Eina_Bool down : 1;
>  };
>
> -struct _Item
> +struct _Elm_Index_Item
>  {
>    Evas_Object *obj;
>    const char *letter;
> @@ -42,13 +41,13 @@
>  static void _sizing_eval(Evas_Object *obj);
>  static void _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int 
> level);
>  static void _index_box_clear(Evas_Object *obj, Evas_Object *box, int level);
> -static void _item_free(Item *it);
> +static void _item_free(Elm_Index_Item *it);
>
>  static void
>  _del_hook(Evas_Object *obj)
>  {
>    Widget_Data *wd = elm_widget_data_get(obj);
> -   Item *it;
> +   Elm_Index_Item *it;
>    Eina_List *l, *clear = NULL;
>    if (!wd) return;
>    _index_box_clear(obj, wd->bx[wd->level], wd->level);
> @@ -138,13 +137,13 @@
>    evas_object_size_hint_max_set(obj, maxw, maxh);
>  }
>
> -static Item *
> +static Elm_Index_Item *
>  _item_new(Evas_Object *obj, const char *letter, const void *item)
>  {
>    Widget_Data *wd = elm_widget_data_get(obj);
> -   Item *it;
> +   Elm_Index_Item *it;
>    if (!wd) return NULL;
> -   it = calloc(1, sizeof(Item));
> +   it = calloc(1, sizeof(Elm_Index_Item));
>    if (!it) return NULL;
>    it->obj = obj;
>    it->letter = eina_stringshare_add(letter);
> @@ -153,12 +152,12 @@
>    return it;
>  }
>
> -static Item *
> +static Elm_Index_Item *
>  _item_find(Evas_Object *obj, const void *item)
>  {
>    Widget_Data *wd = elm_widget_data_get(obj);
>    Eina_List *l;
> -   Item *it;
> +   Elm_Index_Item *it;
>    if (!wd) return NULL;
>    EINA_LIST_FOREACH(wd->items, l, it)
>      if (it->data == item) return it;
> @@ -166,7 +165,7 @@
>  }
>
>  static void
> -_item_free(Item *it)
> +_item_free(Elm_Index_Item *it)
>  {
>    Widget_Data *wd = elm_widget_data_get(it->obj);
>    if (!wd) return;
> @@ -182,7 +181,7 @@
>  {
>    Widget_Data *wd = elm_widget_data_get(obj);
>    Eina_List *l;
> -   Item *it;
> +   Elm_Index_Item *it;
>    Evas_Coord mw, mh, w, h;
>    int i = 0;
>    if (!wd) return;
> @@ -235,7 +2