Enlightenment CVS committal

Author  : jethomas
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_cell.c ewl_cell.h ewl_events.h ewl_filelist.c ewl_list.c 
        ewl_mvc.c ewl_row.c ewl_tree.c ewl_widget.c 


Log Message:
Fix bug 391 and render bug 203 invalid.  Remove seperate highlight widgets from 
use in ewl, and add event data for EWL_CALLBACK_STATE_CHANGED.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_cell.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- ewl_cell.c  15 Feb 2008 23:52:22 -0000      1.20
+++ ewl_cell.c  26 Apr 2008 21:07:35 -0000      1.21
@@ -5,6 +5,8 @@
 #include "ewl_private.h"
 #include "ewl_debug.h"
 
+static void ewl_cell_cb_state_changed(Ewl_Widget *w, void *ev, void *data);
+
 /**
  * @return Returns a newly allocated cell on success, NULL on failure.
  * @brief Allocate and initialize a new cell
@@ -155,3 +157,79 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @internal
+ * @param cell: The cell to work with
+ * @return: Returns no value
+ * @brief Adds the callback to send state changes on to the cell's children
+ */
+void
+ewl_cell_state_change_cb_add(Ewl_Cell *cell)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR(cell);
+       DCHECK_TYPE(cell, EWL_CELL_TYPE);
+
+       ewl_callback_append(EWL_WIDGET(cell), EWL_CALLBACK_STATE_CHANGED,
+                       ewl_cell_cb_state_changed, NULL);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param cell: The cell to work with
+ * @return: Returns no value
+ * @brief Removes the callback to send state changes on to the cell's children
+ */
+void
+ewl_cell_state_change_cb_del(Ewl_Cell *cell)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR(cell);
+       DCHECK_TYPE(cell, EWL_CELL_TYPE);
+
+       ewl_callback_del(EWL_WIDGET(cell), EWL_CALLBACK_STATE_CHANGED,
+                       ewl_cell_cb_state_changed);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param w: The widget to work with
+ * @ev: The Ewl_Event_State_Change struct
+ * @data: UNUSED
+ * @return Returns no value
+ * @brief Sends the state on to the cell's children
+ */
+void
+ewl_cell_cb_state_changed(Ewl_Widget *w, void *ev, void *data __UNUSED__)
+{
+       Ewl_Widget *o;
+       Ewl_Event_State_Change *e;
+       const char *send_state;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR(w);
+       DCHECK_PARAM_PTR(ev);
+       DCHECK_TYPE(w, EWL_CELL_TYPE);
+
+       e = EWL_EVENT_STATE_CHANGE(ev);
+
+       /* Only want this for selected signals */
+       if (!strcmp(e->state, "selected"))
+               send_state = "parent,selected";
+       else if (!strcmp(e->state, "deselect"))
+               send_state = "parent,deselect";
+       else if ((!strcmp(e->state, "parent,selected")) ||
+                       (!strcmp(e->state, "parent,deselect")))
+               send_state = e->state;
+       else
+               DRETURN(DLEVEL_STABLE);
+
+       ewl_container_child_iterate_begin(EWL_CONTAINER(w));
+       while ((o = ewl_container_child_next(EWL_CONTAINER(w))))
+               ewl_widget_state_set(o, send_state, e->flag);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_cell.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- ewl_cell.h  11 Nov 2007 06:07:46 -0000      1.15
+++ ewl_cell.h  26 Apr 2008 21:07:35 -0000      1.16
@@ -52,6 +52,8 @@
 
 Ewl_Widget     *ewl_cell_new(void);
 int             ewl_cell_init(Ewl_Cell *cell);
+void            ewl_cell_state_change_cb_add(Ewl_Cell *cell);
+void            ewl_cell_state_change_cb_del(Ewl_Cell *cell);
 
 /*
  * Internally used callbacks, override at your own risk.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_events.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- ewl_events.h        23 Aug 2007 05:26:50 -0000      1.29
+++ ewl_events.h        26 Apr 2008 21:07:35 -0000      1.30
@@ -352,6 +352,26 @@
        unsigned int response; /**< The response ID */
 };
 
+/**
+ * @def EWL_EVENT_STATE_CHANGE(e)
+ * Typedefs a pointer to an Ewl_Event_State_Change pointer
+ */
+#define EWL_EVENT_STATE_CHANGE(e) ((Ewl_Event_State_Change*)(e))
+
+/**
+ * The Ewl_Event_State_Change type
+ */
+typedef struct Ewl_Event_State_Change Ewl_Event_State_Change;
+
+/**
+ * @brief Provides information about the changed state
+ */
+struct Ewl_Event_State_Change
+{
+       const char *state;
+       Ewl_State_Type flag;
+};
+
 unsigned int   ewl_ev_modifiers_get(void);
 void           ewl_ev_modifiers_set(unsigned int modifiers);
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -3 -r1.56 -r1.57
--- ewl_filelist.c      21 Apr 2008 23:22:23 -0000      1.56
+++ ewl_filelist.c      26 Apr 2008 21:07:35 -0000      1.57
@@ -118,6 +118,8 @@
        fl->controller = ewl_tree_new();
        ewl_mvc_view_set(EWL_MVC(fl->controller), fl->view);
        ewl_mvc_model_set(EWL_MVC(fl->controller), fl->model);
+       ewl_tree_selection_type_set(EWL_TREE(fl->controller),
+                       EWL_TREE_SELECTION_TYPE_ROW);
        ewl_container_child_append(EWL_CONTAINER(fl), fl->controller);
        ewl_callback_append(EWL_WIDGET(fl->controller),
                        EWL_CALLBACK_CLICKED, ewl_filelist_cb_clicked, fl);
@@ -158,8 +160,6 @@
                                                                TRUE);
                ewl_tree_alternate_row_colors_set
                                (EWL_TREE(fl->controller), TRUE);
-               ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-                                       EWL_TREE_SELECTION_TYPE_CELL);
                ewl_model_expansion_data_fetch_set(fl->model,
                        ewl_filelist_model_data_expansion_data_fetch);
                ewl_model_data_expandable_set(fl->model,
@@ -173,8 +173,6 @@
                                                                TRUE);
                ewl_tree_alternate_row_colors_set
                                (EWL_TREE(fl->controller), TRUE);
-               ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-                                       EWL_TREE_SELECTION_TYPE_ROW);
                view = ewl_tree_view_scrolled_get();
        }
        /* Until column view is written just default and throw a warning */
@@ -185,8 +183,6 @@
                                                                FALSE);
                ewl_tree_alternate_row_colors_set
                                (EWL_TREE(fl->controller), FALSE);
-               ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-                                       EWL_TREE_SELECTION_TYPE_ROW);
                view = ewl_tree_view_freebox_get();
                DWARNING("Column view not implemented");
        }
@@ -201,8 +197,6 @@
                                                                FALSE);
                ewl_tree_alternate_row_colors_set
                                (EWL_TREE(fl->controller), FALSE);
-               ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-                                       EWL_TREE_SELECTION_TYPE_ROW);
                view = ewl_tree_view_freebox_get();
                fl->view_flag = EWL_FILELIST_VIEW_ICON;
        }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ewl_list.c  20 Apr 2008 15:06:32 -0000      1.30
+++ ewl_list.c  26 Apr 2008 21:07:35 -0000      1.31
@@ -56,8 +56,6 @@
        ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_CONFIGURE,
                                                ewl_list_cb_configure, NULL);
 
-       ewl_container_add_notify_set(EWL_CONTAINER(list), 
ewl_list_cb_child_add);
-
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
@@ -99,12 +97,19 @@
        ewl_container_reset(EWL_CONTAINER(list));
        for (i = 0; i < (int)model->count(mvc_data); i++)
        {
-               Ewl_Widget *o;
+               Ewl_Widget *o, *cell;
+
+               cell = ewl_cell_new();
+               ewl_cell_state_change_cb_add(EWL_CELL(cell));
+               ewl_container_child_append(EWL_CONTAINER(list), cell);
+               ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
+                               ewl_list_cb_item_clicked, list);
+               ewl_widget_show(cell);
 
                o = view->fetch(model->fetch(mvc_data, i, 0), i, 0);
                ewl_widget_show(o);
 
-               ewl_container_child_append(EWL_CONTAINER(list), o);
+               ewl_container_child_append(EWL_CONTAINER(cell), o);
        }
 
        ewl_list_cb_selected_change(EWL_MVC(list));
@@ -115,32 +120,6 @@
 
 /**
  * @internal
- * @param c: The container to work with
- * @param w: The widget that was added
- * @return Returns no value
- * @brief Adds the needed callbacks to the widget
- */
-void
-ewl_list_cb_child_add(Ewl_Container *c, Ewl_Widget *w)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR(c);
-       DCHECK_PARAM_PTR(w);
-       DCHECK_TYPE(c, EWL_LIST_TYPE);
-       DCHECK_TYPE(w, EWL_WIDGET_TYPE);
-
-       if (ewl_mvc_selection_mode_get(EWL_MVC(c)) ==
-                                       EWL_SELECTION_MODE_NONE)
-               DRETURN(DLEVEL_STABLE);
-
-       ewl_callback_append(w, EWL_CALLBACK_CLICKED,
-                               ewl_list_cb_item_clicked, c);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @internal
  * @param w: The widget that was clicked
  * @param ev: The event data
  * @param data: The list widget
@@ -160,6 +139,10 @@
        DCHECK_TYPE(w, EWL_WIDGET_TYPE);
        DCHECK_TYPE(data, EWL_LIST_TYPE);
 
+       if (ewl_mvc_selection_mode_get(EWL_MVC(data)) ==
+                                       EWL_SELECTION_MODE_NONE)
+               DRETURN(DLEVEL_STABLE);
+
        model = ewl_mvc_model_get(EWL_MVC(data));
        mvc_data = ewl_mvc_data_get(EWL_MVC(data));
        row = ewl_container_child_index_get(EWL_CONTAINER(data), w);
@@ -167,17 +150,8 @@
 
        if ((unsigned int) row > model->count(mvc_data))
        {
-               if (!EWL_HIGHLIGHT_IS(w))
-               {
-                       DWARNING("Unknown widget clicked for container.");
-                       DRETURN(DLEVEL_STABLE);
-               }
-
-               /* our row is the index that corresponds to the followed
-                * widget for this highlight widget */
-               row = ewl_container_child_index_get(EWL_CONTAINER(data),
-                               ewl_highlight_follow_get(EWL_HIGHLIGHT(w)));
-               if (row < 0) DRETURN(DLEVEL_STABLE);
+               DWARNING("Don't use container function on MVC widget!");
+               DRETURN(DLEVEL_STABLE);
        }
 
        ewl_mvc_handle_click(EWL_MVC(data), NULL, mvc_data, row, 0);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_mvc.c   20 Apr 2008 15:06:32 -0000      1.40
+++ ewl_mvc.c   26 Apr 2008 21:07:35 -0000      1.41
@@ -456,7 +456,8 @@
        DCHECK_PARAM_PTR(mvc);
        DCHECK_TYPE(mvc, EWL_MVC_TYPE);
 
-       if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+       if ((mvc->selection_mode == EWL_SELECTION_MODE_NONE) ||
+                       (ewl_mvc_selected_is(mvc, data, row, column)))
                DRETURN(DLEVEL_STABLE);
 
        ewl_mvc_selected_clear_private(mvc);
@@ -572,7 +573,10 @@
                sel = ecore_list_current(mvc->selected);
 
                if (sel->type == EWL_SELECTION_TYPE_INDEX)
-                       ecore_list_remove(mvc->selected);
+               {
+                       sel = ecore_list_remove(mvc->selected);
+                       ewl_mvc_selection_free(sel);
+               }
                else
                        ewl_mvc_selected_range_split(mvc,
                                EWL_SELECTION_RANGE(sel), row, column);
@@ -742,6 +746,7 @@
        ecore_list_first_goto(mvc->selected);
        while ((cur = ecore_list_current(mvc->selected)))
        {
+               /* ecore_list_remove updates the index by itself */
                if (ewl_mvc_selection_intersects(range, cur))
                {
                        ecore_list_remove(mvc->selected);
@@ -749,14 +754,13 @@
                        /* just free indexes as their covered by the
                         * range and don't need to be re-inserted */
                        if (cur->type == EWL_SELECTION_TYPE_INDEX)
-                       {
                                ewl_mvc_selection_free(cur);
-                       }
                        else
                                ecore_list_append(intersections, cur);
 
                }
-               ecore_list_next(mvc->selected);
+               else
+                       ecore_list_next(mvc->selected);
        }
 
        /* if we intersect nothing just add ourselves to the list
@@ -1082,6 +1086,7 @@
                                                        row, range->end.column);
                ecore_list_append(mvc->selected, sel);
        }
+
        ewl_mvc_selection_free(EWL_SELECTION(range));
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1249,8 +1254,6 @@
 ewl_mvc_highlight_do(Ewl_MVC *mvc __UNUSED__, Ewl_Container *c,
                                Ewl_Selection *sel, Ewl_Widget *w)
 {
-       Ewl_Widget *h;
-
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(c);
        DCHECK_PARAM_PTR(sel);
@@ -1258,20 +1261,17 @@
        DCHECK_TYPE(c, EWL_CONTAINER_TYPE);
        DCHECK_TYPE(w, EWL_WIDGET_TYPE);
 
-       h = ewl_highlight_new();
-       ewl_highlight_follow_set(EWL_HIGHLIGHT(h), w);
-       ewl_container_child_append(EWL_CONTAINER(c), h);
-       ewl_callback_prepend(h, EWL_CALLBACK_DESTROY,
+       ewl_widget_state_set(w, "selected", EWL_STATE_PERSISTENT);
+       ewl_callback_prepend(w, EWL_CALLBACK_DESTROY,
                        ewl_mvc_cb_highlight_destroy, sel);
-       ewl_widget_show(h);
 
        if (sel->type == EWL_SELECTION_TYPE_INDEX)
-               sel->highlight = h;
+               sel->highlight = w;
        else
        {
                if (!sel->highlight)
                        sel->highlight = ecore_list_new();
-               ecore_list_append(sel->highlight, h);
+               ecore_list_append(sel->highlight, w);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1392,7 +1392,8 @@
                {
                        ewl_callback_del(sel->highlight, EWL_CALLBACK_DESTROY,
                                        ewl_mvc_cb_highlight_destroy);
-                       ewl_widget_destroy(sel->highlight);
+                       ewl_widget_state_set(sel->highlight, "deselect",
+                                       EWL_STATE_PERSISTENT);
                }
                else
                {
@@ -1402,12 +1403,12 @@
                        {
                                ewl_callback_del(w, EWL_CALLBACK_DESTROY,
                                                ewl_mvc_cb_highlight_destroy);
-                               ewl_widget_destroy(w);
+                               ewl_widget_state_set(w, "deselect",
+                                       EWL_STATE_PERSISTENT);
                        }
 
                        IF_FREE_LIST(sel->highlight);
                }
-               sel->highlight = NULL;
        }
        FREE(sel);
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_row.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- ewl_row.c   12 Nov 2007 22:42:22 -0000      1.28
+++ ewl_row.c   26 Apr 2008 21:07:36 -0000      1.29
@@ -5,6 +5,8 @@
 #include "ewl_private.h"
 #include "ewl_debug.h"
 
+static void ewl_row_cb_state_changed(Ewl_Widget *w, void *ev, void *data);
+
 /**
  * @return Returns a newly allocated row on success, NULL on failure.
  * @brief Allocate and initialize a new row
@@ -56,6 +58,8 @@
 
        ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE,
                                ewl_row_cb_configure, NULL);
+       ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_STATE_CHANGED,
+                               ewl_row_cb_state_changed, NULL);
 
        ewl_widget_focusable_set(EWL_WIDGET(row), FALSE);
 
@@ -371,6 +375,43 @@
        else
                ewl_object_preferred_inner_w_set(EWL_OBJECT(c),
                                PREFERRED_W(c) + size);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param w: The widget to work with
+ * @ev: The Ewl_Event_State_Change struct
+ * @data: UNUSED
+ * @return Returns no value
+ * @brief Sends the state on to the row's children
+ */
+static void
+ewl_row_cb_state_changed(Ewl_Widget *w, void *ev, void *data __UNUSED__)
+{
+       Ewl_Widget *o;
+       Ewl_Event_State_Change *e;
+       const char *send_state;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR(w);
+       DCHECK_PARAM_PTR(ev);
+       DCHECK_TYPE(w, EWL_ROW_TYPE);
+
+       e = EWL_EVENT_STATE_CHANGE(ev);
+
+       /* Only want this for selected signals */
+       if (!strcmp(e->state, "selected"))
+               send_state = "parent,selected";
+       else if (!strcmp(e->state, "deselect"))
+               send_state = "parent,deselect";
+       else
+               DRETURN(DLEVEL_STABLE);
+
+       ewl_container_child_iterate_begin(EWL_CONTAINER(w));
+       while ((o = ewl_container_child_next(EWL_CONTAINER(w))))
+               ewl_widget_state_set(o, send_state, e->flag);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -3 -r1.69 -r1.70
--- ewl_tree.c  22 Apr 2008 08:53:07 -0000      1.69
+++ ewl_tree.c  26 Apr 2008 21:07:36 -0000      1.70
@@ -819,6 +819,7 @@
        DCHECK_TYPE(row, EWL_ROW_TYPE);
 
        cell = ewl_cell_new();
+       ewl_cell_state_change_cb_add(EWL_CELL(cell));
        ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_ALL);
        ewl_container_child_append(EWL_CONTAINER(row), cell);
        ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
@@ -1134,13 +1135,14 @@
 
        /* find the row in the container */
        r = ewl_container_child_get(c, row);
+       r = EWL_WIDGET(EWL_TREE_NODE(r)->row);
+
        if (tree->type == EWL_TREE_SELECTION_TYPE_ROW)
-               w = EWL_WIDGET(r);
+               w = r;
        else
        {
                /* infact our row is a node so we have to get the row
                 * to search for the right container */
-               r = EWL_WIDGET(EWL_TREE_NODE(r)->row);
                w = ewl_container_child_get(EWL_CONTAINER(r), column);
        }
 
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_widget.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -3 -r1.160 -r1.161
--- ewl_widget.c        8 Apr 2008 15:28:12 -0000       1.160
+++ ewl_widget.c        26 Apr 2008 21:07:36 -0000      1.161
@@ -754,6 +754,8 @@
 void
 ewl_widget_state_set(Ewl_Widget *w, const char *state, Ewl_State_Type flag)
 {
+       Ewl_Event_State_Change ev;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(w);
        DCHECK_PARAM_PTR(state);
@@ -774,7 +776,10 @@
                edje_object_signal_emit(w->theme_object, state, "EWL");
        }
 
-       ewl_callback_call(w, EWL_CALLBACK_STATE_CHANGED);
+       ev.state = state;
+       ev.flag = flag;
+
+       ewl_callback_call_with_event_data(w, EWL_CALLBACK_STATE_CHANGED, &ev);
 
        DRETURN(DLEVEL_STABLE);
 }



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to