Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_container.c ewl_container.h ewl_list.c ewl_list.h Log Message: - make ewl_list use an index for the selected widget instead of a pointer. the children don't have to be created to set one selected now =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_container.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -3 -r1.48 -r1.49 --- ewl_container.c 30 Sep 2006 18:41:01 -0000 1.48 +++ ewl_container.c 3 Oct 2006 03:58:16 -0000 1.49 @@ -532,11 +532,11 @@ DRETURN_PTR(w, DLEVEL_STABLE); } -static unsigned int +static int ewl_container_child_index_helper_get(Ewl_Container *parent, Ewl_Widget *w, unsigned int skip) { - unsigned int idx = 0; + unsigned int idx = 0, ret = -1; Ewl_Container *container; Ewl_Widget *child; @@ -552,23 +552,28 @@ ecore_dlist_goto_first(container->children); while ((child = ecore_dlist_next(container->children))) { if (skip && ewl_widget_internal_is(child)) continue; - if (child == w) break; + if (child == w) + { + ret = idx; + break; + } idx ++; } - DRETURN_INT(idx, DLEVEL_STABLE); + DRETURN_INT(ret, DLEVEL_STABLE); } /** * @param parent: The container to search * @param w: The child to search for - * @return Returns the index of the child in the parent - * @brief Retrieves the index of the given child in the container + * @return Returns the index of the child in the parent or -1 if not found + * @brief Retrieves the index of the given child in the container or -1 if + * not found */ -unsigned int +int ewl_container_child_index_get(Ewl_Container *parent, Ewl_Widget *w) { - unsigned int idx = 0; + int idx = 0; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("parent", parent, idx); @@ -585,14 +590,14 @@ * @param parent: The container to search * @param w: The child to search for * @return Returns the index of the child in the parent including internal - * widgets + * widgets or -1 if not found * @brief Retrieves the index of the given child in the container taking - * internal widgets into account + * internal widgets into account or -1 if not found */ -unsigned int +int ewl_container_child_index_internal_get(Ewl_Container *parent, Ewl_Widget *w) { - unsigned int idx = 0; + int idx = 0; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("parent", parent, idx); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_container.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- ewl_container.h 30 Sep 2006 18:41:01 -0000 1.24 +++ ewl_container.h 3 Oct 2006 03:58:16 -0000 1.25 @@ -121,9 +121,9 @@ Ewl_Orientation o); Ewl_Widget *ewl_container_child_get(Ewl_Container *parent, int index); Ewl_Widget *ewl_container_child_internal_get(Ewl_Container *parent, int index); -unsigned int ewl_container_child_index_get(Ewl_Container *parent, +int ewl_container_child_index_get(Ewl_Container *parent, Ewl_Widget *child); -unsigned int ewl_container_child_index_internal_get(Ewl_Container *parent, +int ewl_container_child_index_internal_get(Ewl_Container *parent, Ewl_Widget *child); void ewl_container_child_iterate_begin(Ewl_Container *c); Ewl_Widget *ewl_container_child_next(Ewl_Container *c); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_list.c 24 Sep 2006 20:26:50 -0000 1.6 +++ ewl_list.c 3 Oct 2006 03:58:16 -0000 1.7 @@ -63,18 +63,18 @@ void ewl_list_selected_widget_set(Ewl_List *list, Ewl_Widget *w) { + int idx; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("list", list); DCHECK_TYPE("list", list, EWL_LIST_TYPE); - if (list->selected == w) - DRETURN(DLEVEL_STABLE); + if (!w) + idx = -1; + else + idx = ewl_container_child_index_get(EWL_CONTAINER(list), w); - /* XXX probably need to do some theme thing here to highlight as - * selected */ - list->selected = w; - - ewl_callback_call(EWL_WIDGET(list), EWL_CALLBACK_VALUE_CHANGED); + ewl_list_selected_index_set(list, idx); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -91,7 +91,11 @@ DCHECK_PARAM_PTR_RET("list", list, NULL); DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, NULL); - DRETURN_PTR(list->selected, DLEVEL_STABLE); + if (list->selected == -1) + DRETURN_PTR(NULL, DLEVEL_STABLE); + + DRETURN_PTR(ewl_container_child_get(EWL_CONTAINER(list), + list->selected), DLEVEL_STABLE); } /** @@ -107,14 +111,12 @@ DCHECK_PARAM_PTR("list", list); DCHECK_TYPE("list", list, EWL_LIST_TYPE); - if (idx < 0) - { - ewl_list_selected_widget_set(list, NULL); + if (list->selected == idx) DRETURN(DLEVEL_STABLE); - } - ewl_list_selected_widget_set(list, - ewl_container_child_get(EWL_CONTAINER(list), idx)); + list->selected = idx; + + ewl_callback_call(EWL_WIDGET(list), EWL_CALLBACK_VALUE_CHANGED); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -127,18 +129,11 @@ int ewl_list_selected_index_get(Ewl_List *list) { - int idx; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("list", list, -1); DCHECK_TYPE_RET("list", list, EWL_LIST_TYPE, -1); - if (!list->selected) - DRETURN_INT(-1, DLEVEL_STABLE); - - idx = ewl_container_child_index_get(EWL_CONTAINER(list), list->selected); - - DRETURN_INT(idx, DLEVEL_STABLE); + DRETURN_INT(list->selected, DLEVEL_STABLE); } /** @@ -188,6 +183,8 @@ ewl_container_child_append(EWL_CONTAINER(list), o); } + /* XXX mark the selected widget here */ + ewl_mvc_dirty_set(EWL_MVC(list), FALSE); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -224,19 +221,17 @@ * @brief Removes the selected status from the widget */ void -ewl_list_cb_child_del(Ewl_Container *c, Ewl_Widget *w, int idx __UNUSED__) +ewl_list_cb_child_del(Ewl_Container *c, Ewl_Widget *w __UNUSED__, int idx) { Ewl_List *list; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("c", c); - DCHECK_PARAM_PTR("w", w); DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); - DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); list = EWL_LIST(c); - if (list->selected == w) - ewl_list_selected_widget_set(list, NULL); + if (list->selected == idx) + ewl_list_selected_index_set(list, -1); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -252,6 +247,7 @@ ewl_list_cb_child_hide(Ewl_Container *c, Ewl_Widget *w) { Ewl_List *list; + Ewl_Widget *sel; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("c", c); @@ -260,8 +256,9 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); list = EWL_LIST(c); - if (list->selected == w) - ewl_list_selected_widget_set(list, NULL); + sel = ewl_list_selected_widget_get(list); + if (sel == w) + ewl_list_selected_index_set(list, -1); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_list.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_list.h 24 Sep 2006 20:26:50 -0000 1.6 +++ ewl_list.h 3 Oct 2006 03:58:16 -0000 1.7 @@ -31,8 +31,7 @@ struct Ewl_List { Ewl_MVC mvc; /**< The mvc parent */ - - Ewl_Widget *selected; /**< The selected widget */ + int selected; /**< The selected widget */ }; Ewl_Widget *ewl_list_new(void); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs