Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_container.c ewl_container.h ewl_embed.c ewl_image.c 
        ewl_misc.c ewl_misc.h ewl_text.c ewl_widget.c ewl_window.c 


Log Message:
Minor refactoring of container call to it's add and remove callbacks, as well
as reorganizing cleanup of evas objects.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- ewl_container.c     6 Oct 2003 17:39:54 -0000       1.45
+++ ewl_container.c     7 Oct 2003 21:26:23 -0000       1.46
@@ -10,9 +10,6 @@
 void            __ewl_container_unrealize(Ewl_Widget *w, void *ev_data,
                                          void *user_data);
 
-void            __ewl_evas_clip_box_del(void *data, Evas *e, Evas_Object *obj,
-                                       void *event_info);
-
 /**
  * @param c: the container to initialize
  * @param appearance: the appearance key for this container
@@ -141,9 +138,7 @@
        DCHECK_PARAM_PTR("child", child);
 
        ewd_list_append(pc->children, child);
-
        ewl_widget_set_parent(child, EWL_WIDGET(pc));
-       ewl_container_call_child_add(pc, child);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -164,9 +159,7 @@
        DCHECK_PARAM_PTR("child", child);
 
        ewd_list_prepend(pc->children, child);
-
        ewl_widget_set_parent(child, EWL_WIDGET(pc));
-       ewl_container_call_child_add(pc, child);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -191,9 +184,7 @@
 
        ewd_list_goto_index(pc->children, index);
        ewd_list_insert(pc->children, child);
-
        ewl_widget_set_parent(child, EWL_WIDGET(pc));
-       ewl_container_call_child_add(pc, child);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -238,8 +229,7 @@
         * Remove the child from the parent and set the childs parent to NULL
         */
        ewd_list_remove(pc->children);
-       if (pc->child_remove && VISIBLE(child))
-               pc->child_remove(pc, child);
+       ewl_container_call_child_remove(pc, child);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -522,6 +512,18 @@
 }
 
 /**
+ * @param c: the container removing a child widget
+ * @param w: the child widget removed from the container
+ * @return Returns no value.
+ * @brief Triggers the child_remove callback for the container @a c.
+ */
+void ewl_container_call_child_remove(Ewl_Container *c, Ewl_Widget *w)
+{
+       if (c->child_remove && VISIBLE(w))
+               c->child_remove(c, w);
+}
+
+/**
  * @param c: the container to destroy children
  * @return Returns no value.
  * @brief Destroy all the sub-children of the container.
@@ -605,8 +607,6 @@
         */
        c->clip_box = evas_object_rectangle_add(emb->evas);
 
-       evas_object_event_callback_add(c->clip_box, EVAS_CALLBACK_FREE,
-                       __ewl_evas_clip_box_del, c);
        evas_object_move(c->clip_box, CURRENT_X(w), CURRENT_Y(w));
        evas_object_resize(c->clip_box, CURRENT_W(w), CURRENT_H(w));
        evas_object_clip_set(c->clip_box, w->fx_clip_box);
@@ -674,19 +674,9 @@
         * Clean up the clip box of the container.
         */
        if (c->clip_box) {
-               evas_object_del(c->clip_box);
+               ewl_evas_object_destroy(c->clip_box);
                c->clip_box = NULL;
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-__ewl_evas_clip_box_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       Ewl_Container *c;
-
-       c = EWL_CONTAINER(data);
-       c->clip_box = NULL;
-       ewl_widget_destroy(EWL_WIDGET(c));
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ewl_container.h     29 Sep 2003 21:46:50 -0000      1.24
+++ ewl_container.h     7 Oct 2003 21:26:23 -0000       1.25
@@ -91,6 +91,7 @@
 void            ewl_container_prefer_largest(Ewl_Container *c,
                                             Ewl_Orientation o);
 void            ewl_container_call_child_add(Ewl_Container *c, Ewl_Widget *w);
+void            ewl_container_call_child_remove(Ewl_Container *c, Ewl_Widget *w);
 
 /**
  * @}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_embed.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_embed.c 29 Sep 2003 21:46:50 -0000      1.6
+++ ewl_embed.c 7 Oct 2003 21:26:23 -0000       1.7
@@ -148,7 +148,7 @@
        }
 
        if (emb->smart) {
-               evas_object_del(emb->smart);
+               ewl_evas_object_destroy(emb->smart);
                emb->smart = NULL;
        }
 
@@ -303,7 +303,7 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        if (EWL_EMBED(w)->smart) {
-               evas_object_del(EWL_EMBED(w)->smart);
+               ewl_evas_object_destroy(EWL_EMBED(w)->smart);
                EWL_EMBED(w)->smart = NULL;
        }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_image.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ewl_image.c 29 Sep 2003 21:46:50 -0000      1.30
+++ ewl_image.c 7 Oct 2003 21:26:23 -0000       1.31
@@ -121,7 +121,7 @@
                         */
                        evas_object_hide(i->image);
                        evas_object_clip_unset(i->image);
-                       evas_object_del(i->image);
+                       ewl_evas_object_destroy(i->image);
                        i->image = NULL;
                }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_misc.c  6 Oct 2003 17:39:55 -0000       1.40
+++ ewl_misc.c  7 Oct 2003 21:26:23 -0000       1.41
@@ -11,6 +11,9 @@
 Ewd_List *realize_list = NULL;
 Ewd_List *destroy_list = NULL;
 
+Ewd_List *free_evas_list = NULL;
+Ewd_List *free_evas_object_list = NULL;
+
 void            __ewl_init_parse_options(int argc, char **argv);
 void            __ewl_parse_option_array(int argc, char **argv);
 int             __ewl_ecore_exit(void *data, int type, void *event);
@@ -48,6 +51,8 @@
        configure_list = ewd_list_new();
        realize_list = ewd_list_new();
        destroy_list = ewd_list_new();
+       free_evas_list = ewd_list_new();
+       free_evas_object_list = ewd_list_new();
        __ewl_init_parse_options(argc, argv);
 
        ecore_init();
@@ -544,9 +549,21 @@
                ewl_container_destroy(EWL_CONTAINER(w));
 }
 
+void ewl_evas_destroy(Evas *evas)
+{
+       ewd_list_append(free_evas_list, evas);
+}
+
+void ewl_evas_object_destroy(Evas_Object *obj)
+{
+       ewd_list_append(free_evas_object_list, obj);
+}
+
 void ewl_garbage_collect()
 {
+       Evas *evas;
        Ewl_Widget *w;
+       Evas_Object *obj;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
@@ -555,6 +572,12 @@
                ewl_callback_del_type(w, EWL_CALLBACK_DESTROY);
                FREE(w);
        }
+
+       while ((obj = ewd_list_remove_first(free_evas_object_list)))
+               evas_object_del(obj);
+
+       while ((evas = ewd_list_remove_first(free_evas_object_list)))
+               evas_free(evas);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_misc.h  6 Oct 2003 17:39:55 -0000       1.19
+++ ewl_misc.h  7 Oct 2003 21:26:23 -0000       1.20
@@ -28,5 +28,7 @@
 void            ewl_enter_realize_phase();
 void            ewl_exit_realize_phase();
 int             ewl_in_realize_phase();
+void            ewl_evas_destroy(Evas *evas);
+void            ewl_evas_object_destroy(Evas_Object *obj);
 
 #endif                         /* __EWL_MISC_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_text.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- ewl_text.c  29 Sep 2003 21:46:51 -0000      1.52
+++ ewl_text.c  7 Oct 2003 21:26:23 -0000       1.53
@@ -645,7 +645,7 @@
        t = EWL_TEXT(w);
 
        if (t->estyle) {
-               evas_object_del(t->estyle);
+               ewl_evas_object_destroy(t->estyle);
                t->estyle = NULL;
        }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -3 -r1.74 -r1.75
--- ewl_widget.c        6 Oct 2003 17:39:55 -0000       1.74
+++ ewl_widget.c        7 Oct 2003 21:26:23 -0000       1.75
@@ -40,11 +40,6 @@
                                     void *user_data);
  */
 
-void __ewl_evas_object_del(void *data, Evas *e, Evas_Object *obj,
-               void *event_info);
-void __ewl_evas_clip_del(void *data, Evas *e, Evas_Object *obj,
-               void *event_info);
-
 void __ewl_widget_get_theme_padding(Ewl_Widget *w, int *l, int *r, int *t,
                int *b);
 void __ewl_widget_get_theme_insets(Ewl_Widget *w, int *l, int *r, int *t,
@@ -224,8 +219,8 @@
                DRETURN(DLEVEL_STABLE);
 
        pc = EWL_CONTAINER(w->parent);
-       if (pc && pc->child_remove)
-               pc->child_remove(EWL_CONTAINER(w->parent), w);
+       if (pc)
+               ewl_container_call_child_remove(pc, w);
 
        ewl_object_remove_visible(EWL_OBJECT(w), EWL_FLAG_VISIBLE_SHOWN);
        ewl_callback_call(w, EWL_CALLBACK_HIDE);
@@ -496,6 +491,9 @@
        DCHECK_PARAM_PTR("w", w);
 
        op = EWL_CONTAINER(w->parent);
+       if (op == EWL_CONTAINER(p))
+               DRETURN(DLEVEL_STABLE);
+
        w->parent = p;
 
        /*
@@ -509,11 +507,17 @@
                                 __ewl_widget_child_destroy);
        }
 
+       /*
+        * A widget that has not had a previous parent needs the parent
+        * destruction callback added.
+        */
        if (p) {
                if (!op)
                        ewl_callback_prepend(w, EWL_CALLBACK_DESTROY,
                                        __ewl_widget_child_destroy, NULL);
                ewl_callback_call(w, EWL_CALLBACK_REPARENT);
+               if (REALIZED(w) && VISIBLE(w))
+                       ewl_container_call_child_add(EWL_CONTAINER(p), w);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -718,7 +722,7 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
-       if (w->fx_clip_box)
+       if (w->fx_clip_box && (w->theme_object || RECURSIVE(w)))
                evas_object_show(w->fx_clip_box);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -764,8 +768,6 @@
         * entire contents of the widget
         */
        w->fx_clip_box = evas_object_rectangle_add(emb->evas);
-       evas_object_event_callback_add(w->fx_clip_box, EVAS_CALLBACK_FREE,
-                       __ewl_evas_clip_del, w);
        evas_object_layer_set(w->fx_clip_box, ewl_widget_get_layer_sum(w));
 
        pc = EWL_CONTAINER(w->parent);
@@ -828,8 +830,6 @@
                 * Load the theme object
                 */
                w->theme_object = edje_object_add(emb->evas);
-               evas_object_event_callback_add(w->theme_object,
-                               EVAS_CALLBACK_FREE, __ewl_evas_object_del, w);
                
                edje_object_file_set(w->theme_object, i, group);
                FREE(i);
@@ -908,15 +908,15 @@
         * Destroy the clip box used for fx.
         */
        if (w->fx_clip_box) {
-               evas_object_del(w->fx_clip_box);
+               ewl_evas_object_destroy(w->fx_clip_box);
+               w->fx_clip_box = NULL;
        }
 
        /*
         * Destroy old image (if any) 
         */
        if (w->theme_object) {
-               evas_object_del(w->theme_object);
-               w->theme_object = NULL;
+               ewl_evas_object_destroy(w->theme_object);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1148,24 +1148,4 @@
                ewl_container_remove_child(EWL_CONTAINER(w->parent), w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-__ewl_evas_object_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       Ewl_Widget *w;
-
-       w = EWL_WIDGET(data);
-       w->theme_object = NULL;
-       ewl_widget_destroy(w);
-}
-
-void
-__ewl_evas_clip_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       Ewl_Widget *w;
-
-       w = EWL_WIDGET(data);
-       w->fx_clip_box = NULL;
-       ewl_widget_destroy(w);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_window.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -3 -r1.55 -r1.56
--- ewl_window.c        29 Sep 2003 21:46:51 -0000      1.55
+++ ewl_window.c        7 Oct 2003 21:26:23 -0000       1.56
@@ -293,7 +293,7 @@
        embed = EWL_EMBED(w);
        o = EWL_OBJECT(w);
 
-       evas_free(embed->evas);
+       ewl_evas_destroy(embed->evas);
        embed->evas = NULL;
 
        ecore_x_window_del(EWL_WINDOW(embed)->window);




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to