Re: [E-devel] [PATCH] e ilist fix

2007-05-11 Thread The Rasterman
On Fri, 11 May 2007 19:01:32 +0200 Laurent Ghigonis <[EMAIL PROTECTED]>
babbled:

> Hi
> 
> Here is a patch to fix some wrong behavior of E_Ilist and
> E_Widget_Ilist.
> 
> Each E_Wiget_Ilist has an E_Widget_Callback list, wich contains
> callbacks for each item of the list. It must have the same order /
> same number of items than the real items list. And that was not the
> case before :
> now we update the E_Widget_Callback list on ilist_clear,
> ilist_remove_num and when creating a header item, add an empty
> E_Widget_Callback to the list.
> 
> I also removed a function : ilist_remove_label. It needed a rewrite,
> and i didn't see the use of that function, and its not used in e.
> Of course that's my opinion and if someone needs it, i'll write it.

indeed there seems to have been some bit-rot there with expanding api's and
things not doing memory management right. patch in cvs.

-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)[EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] [PATCH] e ilist fix

2007-05-11 Thread Laurent Ghigonis
Hi

Here is a patch to fix some wrong behavior of E_Ilist and
E_Widget_Ilist.

Each E_Wiget_Ilist has an E_Widget_Callback list, wich contains
callbacks for each item of the list. It must have the same order /
same number of items than the real items list. And that was not the
case before :
now we update the E_Widget_Callback list on ilist_clear,
ilist_remove_num and when creating a header item, add an empty
E_Widget_Callback to the list.

I also removed a function : ilist_remove_label. It needed a rewrite,
and i didn't see the use of that function, and its not used in e.
Of course that's my opinion and if someone needs it, i'll write it.

laurent? e_confirm_dialog.patch
? ilist.patch
Index: e_ilist.c
===
RCS file: /cvs/e/e17/apps/e/src/bin/e_ilist.c,v
retrieving revision 1.32
diff -u -r1.32 e_ilist.c
--- e_ilist.c	9 May 2007 12:54:57 -	1.32
+++ e_ilist.c	9 May 2007 21:21:57 -
@@ -332,35 +332,6 @@
E_FREE(si);
 }
 
-EAPI void 
-e_ilist_remove_label(Evas_Object *obj, const char *label) 
-{
-   Evas_List *l;
-   
-   API_ENTRY return;
-   if (!sd->items) return;
-   if (!label) return;
-   for (l = sd->items; l; l = l->next) 
- {
-	E_Ilist_Item *si;
-	char *t;
-	
-	si = l->data;
-	if (!si) continue;
-	t = strdup(edje_object_part_text_get(si->o_base, "e.text.label"));
-	if (!strcmp(t, label)) 
-	  {
-	 if (si->o_icon) evas_object_del(si->o_icon);
-	 evas_object_del(si->o_base);
-	 sd->items = evas_list_remove(sd->items, si);
-	 E_FREE(si);
-	 free(t);
-	 break;
-	  }
-	free(t);
- }
-}
-
 EAPI const char *
 e_ilist_nth_label_get(Evas_Object *obj, int n) 
 {
Index: e_ilist.h
===
RCS file: /cvs/e/e17/apps/e/src/bin/e_ilist.h,v
retrieving revision 1.16
diff -u -r1.16 e_ilist.h
--- e_ilist.h	8 Jan 2007 19:23:21 -	1.16
+++ e_ilist.h	9 May 2007 21:21:57 -
@@ -39,7 +39,6 @@
 EAPI Evas_Object *e_ilist_selected_icon_get (Evas_Object *obj);
 EAPI void e_ilist_selected_geometry_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
 EAPI void e_ilist_remove_num(Evas_Object *obj, int n);
-EAPI void e_ilist_remove_label  (Evas_Object *obj, const char *label);
 EAPI const char  *e_ilist_nth_label_get (Evas_Object *obj, int n);
 EAPI void e_ilist_nth_label_set (Evas_Object *obj, int n, const char *label);
 EAPI Evas_Object *e_ilist_nth_icon_get  (Evas_Object *obj, int n);
Index: e_widget_ilist.c
===
RCS file: /cvs/e/e17/apps/e/src/bin/e_widget_ilist.c,v
retrieving revision 1.33
diff -u -r1.33 e_widget_ilist.c
--- e_widget_ilist.c	9 May 2007 19:07:58 -	1.33
+++ e_widget_ilist.c	9 May 2007 21:21:57 -
@@ -103,8 +103,12 @@
 e_widget_ilist_header_append(Evas_Object *obj, Evas_Object *icon, const char *label)
 {
E_Widget_Data *wd;
+   E_Widget_Callback *wcb;

wd = e_widget_data_get(obj);
+   wcb = E_NEW(E_Widget_Callback, 1);
+   if (!wcb) return;
+   wd->callbacks = evas_list_append(wd->callbacks, wcb);
e_ilist_append(wd->o_ilist, icon, label, 1, NULL, NULL, NULL, NULL);
if (icon) evas_object_show(icon);
 }
@@ -145,8 +149,18 @@
 e_widget_ilist_clear(Evas_Object *obj) 
 {
E_Widget_Data *wd;
+
wd = e_widget_data_get(obj);
e_ilist_clear(wd->o_ilist);
+   while (wd->callbacks)
+ {
+	E_Widget_Callback *wcb;
+	
+	wcb = wd->callbacks->data;
+	if (wcb->value) free(wcb->value);
+	free(wcb);
+	wd->callbacks = evas_list_remove_list(wd->callbacks, wd->callbacks);
+ }
 }
 
 EAPI int
@@ -281,18 +295,15 @@
 e_widget_ilist_remove_num(Evas_Object *obj, int n)
 {
E_Widget_Data *wd;
+   E_Widget_Callback *wcb;

wd = e_widget_data_get(obj);
e_ilist_remove_num(wd->o_ilist, n);
-}
-
-EAPI void
-e_widget_ilist_remove_label(Evas_Object *obj, const char *label)
-{
-   E_Widget_Data *wd;
-   
-   wd = e_widget_data_get(obj);
-   e_ilist_remove_label(wd->o_ilist, label);
+   wcb = evas_list_nth(wd->callbacks, n);
+   if (!wcb) return;
+   if (wcb->value) free(wcb->value);
+   free(wcb);
+   wd->callbacks = evas_list_remove(wd->callbacks, wcb);
 }
 
 EAPI void 
Index: e_widget_ilist.h
===
RCS file: /cvs/e/e17/apps/e/src/bin/e_widget_ilist.h,v
retrieving revision 1.18
diff -u -r1.18 e_widget_ilist.h
--- e_widget_ilist.h	9 May 2007 19:07:58 -	1.18
+++ e_widget_ilist.h	9 May 2007 21:21:57 -
@@ -28,7 +28,6 @@
 EAPI Evas_Object *e_widget_ilist_selected_icon_get(Evas_Object *obj);
 EAPI void e_widget_ilist_unselect(Evas_Object *obj);
 EAPI void e_widget_ilist_remove_num(Evas_Object *obj, int n);
-EAPI void e_widget_ilist_remove_label(Evas_Object *obj, const char *label);
 EAPI void e_widget_ilist_multi_select_set(Evas_Object *obj, int multi);
 EAPI int