Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_filepicker.c ewl_model.c ewl_model.h Log Message: - add a helper function to get a ewl_model that uses ecore_lists. this will setup the fetch/count functions for you so if you'r just displaying a list, like in a combo, this should make your life easier. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filepicker.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_filepicker.c 13 Apr 2006 15:28:25 -0000 1.6 +++ ewl_filepicker.c 20 Apr 2006 02:13:43 -0000 1.7 @@ -25,10 +25,6 @@ static void ewl_filepicker_cb_type_change(Ewl_Widget *w, void *ev, void *data); -static void *ewl_filepicker_cb_path_fetch(void *data, unsigned int row, - unsigned int col); -static int ewl_filepicker_cb_path_count(void *data); - static void *ewl_filepicker_cb_type_fetch(void *data, unsigned int row, unsigned int col); static int ewl_filepicker_cb_type_count(void *data); @@ -85,9 +81,7 @@ ewl_object_preferred_inner_size_set(EWL_OBJECT(fp), 400, 300); - model = ewl_model_new(); - ewl_model_fetch_set(model, ewl_filepicker_cb_path_fetch); - ewl_model_count_set(model, ewl_filepicker_cb_path_count); + model = ewl_model_ecore_list_get(); view = ewl_view_new(); ewl_view_constructor_set(view, ewl_label_new); @@ -626,34 +620,6 @@ /* XXX Write me */ DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -static void * -ewl_filepicker_cb_path_fetch(void *data, unsigned int row, - unsigned int col __UNUSED__) -{ - Ecore_List *list; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("data", data, NULL); - - list = data; - ecore_list_goto_index(list, row); - - DRETURN_PTR(ecore_list_current(list), DLEVEL_STABLE); -} - -static int -ewl_filepicker_cb_path_count(void *data) -{ - Ecore_List *list; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("data", data, 0); - - list = data; - - DRETURN_INT(ecore_list_nodes(list), DLEVEL_STABLE); } static void * =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_model.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_model.c 13 Mar 2006 22:26:08 -0000 1.6 +++ ewl_model.c 20 Apr 2006 02:13:43 -0000 1.7 @@ -25,6 +25,28 @@ } /** + * @return Returns a model that is setup to work with an ecore_list + * @brief Retrieves a model pre-initialized to work with an ecore list. This + * will setup the fetch and count methods for you + */ +Ewl_Model * +ewl_model_ecore_list_get(void) +{ + Ewl_Model *model; + + DENTER_FUNCTION(DLEVEL_STABLE); + + model = ewl_model_new(); + if (model) + { + ewl_model_fetch_set(model, ewl_model_cb_ecore_list_fetch); + ewl_model_count_set(model, ewl_model_cb_ecore_list_count); + } + + DRETURN_PTR(model, DLEVEL_STABLE); +} + +/** * @param model: The Ewl_Model to initialize * @return Returns TRUE on success or FALSE on failure * @brief Set the model to the default values @@ -161,5 +183,44 @@ DCHECK_PARAM_PTR_RET("m", m, NULL); DRETURN_INT(m->count, DLEVEL_STABLE); +} + +/** + * @param data: The ecore_list to get the data from + * @param row: The row to get the data from + * @return Returns the data at the given row + * @brief This will return the @a row data element from the list + */ +void * +ewl_model_cb_ecore_list_fetch(void *data, unsigned int row, + unsigned int col __UNUSED__) +{ + Ecore_List *list; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("data", data, NULL); + + list = data; + ecore_list_goto_index(list, row); + + DRETURN_PTR(ecore_list_current(list), DLEVEL_STABLE); +} + +/** + * @param data: The ecore_list to get the count from + * @return Returns the number of elements in the list + * @brief This will return the number of elements in the ecore_list + */ +int +ewl_model_cb_ecore_list_count(void *data) +{ + Ecore_List *list; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("data", data, 0); + + list = data; + + DRETURN_INT(ecore_list_nodes(list), DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_model.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_model.h 14 Mar 2006 06:00:43 -0000 1.7 +++ ewl_model.h 20 Apr 2006 02:13:43 -0000 1.8 @@ -54,6 +54,8 @@ Ewl_Model *ewl_model_new(void); int ewl_model_init(Ewl_Model *model); +Ewl_Model *ewl_model_ecore_list_get(void); + void ewl_model_fetch_set(Ewl_Model *m, Ewl_Model_Fetch get); Ewl_Model_Fetch ewl_model_fetch_get(Ewl_Model *m); @@ -69,6 +71,9 @@ /** * @} */ +void *ewl_model_cb_ecore_list_fetch(void *data, unsigned int row, + unsigned int col); +int ewl_model_cb_ecore_list_count(void *data); #endif ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs