Enlightenment CVS committal Author : jethomas Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_entry.c ewl_entry.h ewl_filelist.c ewl_filepicker.c Log Message: Add _view_get for entry widget, and make the path combo in filepicker editable. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -3 -r1.81 -r1.82 --- ewl_entry.c 16 Nov 2007 18:50:57 -0000 1.81 +++ ewl_entry.c 6 Jan 2008 19:17:12 -0000 1.82 @@ -10,6 +10,10 @@ #endif /* HAVE_LANGINFO_H */ #include "ewl_debug.h" +static Ewl_Widget *ewl_entry_view_cb_widget_fetch(void *data, unsigned int row, + unsigned int col); +static Ewl_Widget *ewl_entry_view_cb_header_fetch(void *data, unsigned int col); + #ifdef _WIN32 # include <locale.h> @@ -910,3 +914,49 @@ DRETURN_INT(ewl_text_cursor_position_get(EWL_TEXT(c->parent)), DLEVEL_STABLE); } + +/** + * @return Returns a view that can be used to display Ewl_Entry widgets + * @brief Creates and returns a view to be used by Ewl_Entry widgets + */ +Ewl_View * +ewl_entry_view_get(void) +{ + Ewl_View *view; + + DENTER_FUNCTION(DLEVEL_STABLE); + + view = ewl_view_new(); + ewl_view_widget_fetch_set(view, ewl_entry_view_cb_widget_fetch); + ewl_view_header_fetch_set(view, ewl_entry_view_cb_header_fetch); + + DRETURN_PTR(view, DLEVEL_STABLE); +} + +static Ewl_Widget * +ewl_entry_view_cb_widget_fetch(void *data, unsigned int row __UNUSED__, + unsigned int col __UNUSED__) +{ + Ewl_Widget *entry; + + DENTER_FUNCTION(DLEVEL_STABLE); + + entry = ewl_entry_new(); + ewl_text_text_set(EWL_TEXT(entry), data); + + DRETURN_PTR(entry, DLEVEL_STABLE); +} + +static Ewl_Widget * +ewl_entry_view_cb_header_fetch(void *data, unsigned int col __UNUSED__) +{ + Ewl_Widget *entry; + + DENTER_FUNCTION(DLEVEL_STABLE); + + entry = ewl_entry_new(); + ewl_text_text_set(EWL_TEXT(entry), data); + + DRETURN_PTR(entry, DLEVEL_STABLE); +} + =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_entry.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ewl_entry.h 11 Nov 2007 06:07:46 -0000 1.30 +++ ewl_entry.h 6 Jan 2008 19:17:12 -0000 1.31 @@ -3,6 +3,7 @@ #define EWL_ENTRY_H #include "ewl_text.h" +#include "ewl_view.h" /** * @addtogroup Ewl_Entry Ewl_Entry: A text entry widget @@ -74,6 +75,7 @@ unsigned int ewl_entry_editable_get(Ewl_Entry *e); unsigned int ewl_entry_selection_clear(Ewl_Entry *e); +Ewl_View *ewl_entry_view_get(void); /* * Internal stuff =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -3 -r1.49 -r1.50 --- ewl_filelist.c 26 Dec 2007 04:46:25 -0000 1.49 +++ ewl_filelist.c 6 Jan 2008 19:17:12 -0000 1.50 @@ -266,9 +266,7 @@ IF_FREE(fl->directory); fl->directory = NULL; } - else if (((!fl->directory) || (strcmp(dir, fl->directory))) - && (ecore_file_is_dir(dir)) - && (ecore_file_can_read(dir))) + else if ((!fl->directory) || (strcmp(dir, fl->directory))) { Ewl_Filelist_Directory *data; Ewl_Event_Action_Response ev_data; =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filepicker.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -3 -r1.43 -r1.44 --- ewl_filepicker.c 30 Dec 2007 19:34:40 -0000 1.43 +++ ewl_filepicker.c 6 Jan 2008 19:17:12 -0000 1.44 @@ -24,6 +24,9 @@ void *data); static void ewl_filepicker_cb_filter_change(Ewl_Widget *w, void *ev, void *data); +static void ewl_filepicker_cb_path_entry_change(Ewl_Widget *w, void *ev, + void *data); + static void ewl_filepicker_cb_type_change(Ewl_Widget *w, void *ev, void *data); @@ -32,6 +35,13 @@ static unsigned int ewl_filepicker_cb_type_count(void *data); static Ewl_Widget *ewl_filepicker_cb_type_header(void *data, unsigned int col); +static void *ewl_filepicker_cb_path_fetch(void *data, unsigned int row, + unsigned int col); +static unsigned int ewl_filepicker_cb_path_count(void *data); + +static Ewl_Widget *ewl_filepicker_cb_path_header(void *data, + unsigned int col); + static void ewl_filepicker_filter_free_cb(Ewl_Filelist_Filter *filter); /** @@ -83,21 +93,28 @@ ewl_object_preferred_inner_size_set(EWL_OBJECT(fp), 400, 300); - fp->mvc_path.model = ewl_model_ecore_list_get(); + fp->mvc_path.model = ewl_model_new(); + ewl_model_data_fetch_set(fp->mvc_path.model, + ewl_filepicker_cb_path_fetch); + ewl_model_data_count_set(fp->mvc_path.model, + ewl_filepicker_cb_path_count); fp->mvc_path.view = ewl_label_view_get(); + ewl_view_header_fetch_set(fp->mvc_path.view, + ewl_filepicker_cb_path_header); fp->path = ecore_list_new(); ecore_list_free_cb_set(fp->path, ECORE_FREE_CB(free)); fp->mvc_path.combo = ewl_combo_new(); + ewl_combo_editable_set(EWL_COMBO(fp->mvc_path.combo), TRUE); ewl_container_child_append(EWL_CONTAINER(fp), fp->mvc_path.combo); ewl_mvc_model_set(EWL_MVC(fp->mvc_path.combo), fp->mvc_path.model); ewl_mvc_view_set(EWL_MVC(fp->mvc_path.combo), fp->mvc_path.view); - ewl_mvc_data_set(EWL_MVC(fp->mvc_path.combo), fp->path); + ewl_mvc_data_set(EWL_MVC(fp->mvc_path.combo), fp); ewl_callback_append(fp->mvc_path.combo, EWL_CALLBACK_VALUE_CHANGED, ewl_filepicker_cb_path_change, fp); @@ -313,8 +330,12 @@ else tmp = strdup(dir); - ewl_filepicker_path_populate(fp, tmp); - ewl_filelist_directory_set(EWL_FILELIST(fp->file_list), tmp); + if ((ecore_file_is_dir(tmp)) && (ecore_file_can_read(tmp))) + { + ewl_filepicker_path_populate(fp, tmp); + ewl_filelist_directory_set(EWL_FILELIST(fp->file_list), tmp); + } + FREE(tmp); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -644,8 +665,7 @@ DCHECK_PARAM_PTR_RET(data, NULL); fp = data; - ecore_list_index_goto(fp->filters, row); - filter = ecore_list_current(fp->filters); + filter = ecore_list_index_goto(fp->filters, row); DRETURN_PTR(filter->name, DLEVEL_STABLE); } @@ -682,11 +702,58 @@ ewl_text_text_set(EWL_TEXT(w), filter->name); ewl_callback_append(w, EWL_CALLBACK_VALUE_CHANGED, ewl_filepicker_cb_filter_change, fp); - ewl_widget_show(w); DRETURN_PTR(w, DLEVEL_STABLE); } +static void * +ewl_filepicker_cb_path_fetch(void *data, unsigned int row, + unsigned int col __UNUSED__) +{ + Ewl_Filepicker *fp; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(data, NULL); + + fp = data; + + DRETURN_PTR(ecore_list_index_goto(fp->path, row), DLEVEL_STABLE); +} + +static unsigned int +ewl_filepicker_cb_path_count(void *data) +{ + Ewl_Filepicker *fp; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(data, FALSE); + + fp = data; + + DRETURN_INT(ecore_list_count(fp->path), DLEVEL_STABLE); +} + +static Ewl_Widget * +ewl_filepicker_cb_path_header(void *data, unsigned int col __UNUSED__) +{ + Ewl_Filepicker *fp; + Ewl_Widget *entry; + char *path; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(data, NULL); + + fp = data; + path = ecore_list_index_goto(fp->path, col); + + entry = ewl_entry_new(); + ewl_text_text_set(EWL_TEXT(entry), path); + ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED, + ewl_filepicker_cb_path_entry_change, fp); + + DRETURN_PTR(entry, DLEVEL_STABLE); +} + static void ewl_filepicker_path_populate(Ewl_Filepicker *fp, char *path) { @@ -771,6 +838,30 @@ ewl_filepicker_filter_add(fp, name, name, NULL); ewl_filepicker_cb_type_change(fp->mvc_filters.combo, NULL, fp); FREE(name); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +static void +ewl_filepicker_cb_path_entry_change(Ewl_Widget *w, void *ev __UNUSED__, + void *data) +{ + Ewl_Filepicker *fp; + char *path; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(w); + DCHECK_PARAM_PTR(data); + DCHECK_TYPE(w, EWL_WIDGET_TYPE); + + fp = data; + path = ewl_text_text_get(EWL_TEXT(w)); + + if (!path) + DRETURN(DLEVEL_STABLE); + + ewl_filepicker_directory_set(fp, path); + FREE(path); DLEAVE_FUNCTION(DLEVEL_STABLE); } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs