Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_attach.c ewl_border.c ewl_entry.c ewl_fileselector.c ewl_fileselector.h ewl_iconbox.c ewl_tree2.h Log Message: Prepend most destroy callbacks to do valid type checking. Avoid a hash table per-row in the fileselector. A couple more function prototypes in the new tree header. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_attach.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- ewl_attach.c 16 Nov 2005 04:38:00 -0000 1.17 +++ ewl_attach.c 16 Nov 2005 23:36:28 -0000 1.18 @@ -646,7 +646,7 @@ ewl_container_child_append(EWL_CONTAINER(emb), ewl_attach_tooltip->win); ewl_widget_layer_set(ewl_attach_tooltip->win, 1000); - ewl_callback_append(ewl_attach_tooltip->win, EWL_CALLBACK_DESTROY, + ewl_callback_prepend(ewl_attach_tooltip->win, EWL_CALLBACK_DESTROY, ewl_attach_cb_tooltip_win_destroy, NULL); ewl_object_fill_policy_set(EWL_OBJECT(ewl_attach_tooltip->win), EWL_FLAG_FILL_NONE); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_border.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- ewl_border.c 9 Nov 2005 15:48:18 -0000 1.9 +++ ewl_border.c 16 Nov 2005 23:36:28 -0000 1.10 @@ -58,7 +58,7 @@ ewl_container_child_append(EWL_CONTAINER(b), b->body); ewl_widget_show(b->body); - b->label_position = EWL_POSITION_LEFT; + b->label_position = EWL_POSITION_TOP; ewl_container_redirect_set(EWL_CONTAINER(b), EWL_CONTAINER(b->body)); @@ -132,13 +132,14 @@ EWL_ORIENTATION_VERTICAL); break; } - ewl_container_child_remove(EWL_CONTAINER(b), b->label); ewl_widget_appearance_set(EWL_WIDGET(b), "border"); /* need to remove the redirect so the label gets added back into the * border and not into the body. We put the redirect back on after */ ewl_container_redirect_set(EWL_CONTAINER(b), NULL); + ewl_container_child_remove(EWL_CONTAINER(b), b->label); + if ((b->label_position == EWL_POSITION_LEFT) || (b->label_position == EWL_POSITION_TOP)) ewl_container_child_prepend(EWL_CONTAINER(b), b->label); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- ewl_entry.c 15 Nov 2005 22:57:09 -0000 1.34 +++ ewl_entry.c 16 Nov 2005 23:36:28 -0000 1.35 @@ -87,7 +87,7 @@ ewl_entry_cb_mouse_down, NULL); ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP, ewl_entry_cb_mouse_up, NULL); - ewl_callback_append(w, EWL_CALLBACK_DESTROY, + ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_entry_cb_destroy, NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_fileselector.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- ewl_fileselector.c 14 Nov 2005 06:54:53 -0000 1.31 +++ ewl_fileselector.c 16 Nov 2005 23:36:28 -0000 1.32 @@ -11,7 +11,7 @@ */ static void ewl_fileselector_tooltip_add(Ewl_Widget *w, Ewl_Fileselector_Data *d); -static char *ewl_fileselector_str_append(char *s1, char *s2); +static char *ewl_fileselector_str_append(const char *s1, const char *s2); static char *ewl_fileselector_path_up_get(char *path); static char *ewl_fileselector_path_home_get(void); static char *ewl_fileselector_size_string_get(off_t st_size); @@ -20,15 +20,11 @@ char *dfilter, Ecore_List *flist, Ecore_List *dlist); -static void ewl_fileselector_path_setup(Ewl_Fileselector *fs, char *path); +static void ewl_fileselector_path_setup(Ewl_Fileselector *fs, const char *path); static void ewl_fileselector_show_cb(Ewl_Widget *entry, void *ev_data, void *user_data); static void ewl_fileselector_destroy_cb(Ewl_Widget *entry, void *ev_data, void *user_data); -static void ewl_fileselector_dir_data_cleanup_cb(Ewl_Widget *entry, - void *ev_data, void *user_data); -static void ewl_fileselector_file_data_cleanup_cb(Ewl_Widget *entry, - void *ev_data, void *user_data); static void ewl_fileselector_files_free_cb(void *data); @@ -265,7 +261,7 @@ * @brief Prosess the given directory / change the fileselector dir */ void -ewl_fileselector_path_set(Ewl_Fileselector *fs, char *path) +ewl_fileselector_path_set(Ewl_Fileselector *fs, const char *path) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("fs", fs); @@ -335,7 +331,7 @@ /* if non NULL, result must be freed */ static char * -ewl_fileselector_str_append(char *s1, char *s2) +ewl_fileselector_str_append(const char *s1, const char *s2) { char *s; int l; @@ -646,9 +642,11 @@ void ewl_fileselector_select_file_cb(Ewl_Widget *w, void *ev_data, void *data) { + Ewl_Container *row; Ewl_Event_Mouse_Up *ev; Ewl_Fileselector *fs; - char *name = NULL; + Ewl_Widget *label = NULL; + const char *name = NULL; char *full_name = NULL; DENTER_FUNCTION(DLEVEL_STABLE); @@ -656,9 +654,17 @@ DCHECK_PARAM_PTR("data", data); DCHECK_TYPE("w", w, "widget"); + row = EWL_CONTAINER(w); ev = ev_data; fs = data; - name = ewl_widget_data_get(w, "FILESELECTOR_FILE"); + + /* + * Retrieve the file name from the label. + */ + ewl_container_child_iterate_begin(row); + if ((label = ewl_container_child_next(row))) { + name = ewl_label_text_get(EWL_LABEL(label)); + } full_name = ewl_fileselector_str_append(fs->path, name); if (!full_name) { @@ -699,10 +705,12 @@ void ewl_fileselector_select_dir_cb(Ewl_Widget *w, void *ev_data, void *data) { + Ewl_Container *row; Ewl_Fileselector *fs; - char *path; + const char *path = NULL; char *new_path; Ewl_Event_Mouse_Down *ev; + Ewl_Widget *label = NULL; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); @@ -712,8 +720,16 @@ if (ev->clicks < 2) DRETURN(DLEVEL_STABLE); + row = EWL_CONTAINER(w); fs = data; - path = ewl_widget_data_get(w, "FILESELECTOR_DIR"); + + /* + * Retrieve the file name from the label. + */ + ewl_container_child_iterate_begin(row); + if ((label = ewl_container_child_next(row))) { + path = ewl_label_text_get(EWL_LABEL(label)); + } if (!strcmp(path, "..")) { new_path = ewl_fileselector_path_up_get(fs->path); @@ -764,7 +780,7 @@ } static void -ewl_fileselector_path_setup(Ewl_Fileselector *fs, char *path) +ewl_fileselector_path_setup(Ewl_Fileselector *fs, const char *path) { Ewl_Fileselector_Data *d; Ewl_Widget *parent_win; @@ -772,7 +788,8 @@ Ewl_Widget *prow = NULL; Ecore_List *dirs, *files; char *path2; - char *title; + char *headers[1]; + char title[PATH_MAX]; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("fs", fs); @@ -814,13 +831,9 @@ if (cont) ewl_container_redirect_set(EWL_CONTAINER(parent_win), NULL); - title = malloc(PATH_MAX); - if (!title) { - DRETURN(DLEVEL_STABLE); - } - snprintf(title, PATH_MAX, "Files (%d)", ecore_list_nodes(files)); - ewl_tree_headers_set(EWL_TREE(fs->list_files), &title); + headers[0] = title; + ewl_tree_headers_set(EWL_TREE(fs->list_files), headers); ecore_list_goto_first(files); while ((d = ecore_list_current(files))) { @@ -837,20 +850,18 @@ ewl_container_child_append(EWL_CONTAINER(prow), label); ewl_widget_show(label); - ewl_widget_data_set(prow, "FILESELECTOR_FILE", strdup(d->name)); ewl_fileselector_tooltip_add(prow, d); ewl_fileselector_data_free(d); ewl_callback_append(prow, EWL_CALLBACK_CLICKED, ewl_fileselector_select_file_cb, fs); - ewl_callback_prepend(prow, EWL_CALLBACK_DESTROY, - ewl_fileselector_file_data_cleanup_cb, NULL); ecore_list_next(files); } snprintf(title, PATH_MAX, "Directories (%d)", ecore_list_nodes(dirs)); - ewl_tree_headers_set(EWL_TREE(fs->list_dirs), &title); + headers[0] = title; + ewl_tree_headers_set(EWL_TREE(fs->list_dirs), headers); ecore_list_goto_first(dirs); while ((d = ecore_list_current(dirs))) { @@ -867,14 +878,11 @@ ewl_container_child_append(EWL_CONTAINER(prow), label); ewl_widget_show(label); - ewl_widget_data_set(prow, "FILESELECTOR_DIR", strdup(d->name)); ewl_fileselector_tooltip_add(prow, ecore_list_current(dirs)); ewl_fileselector_data_free(d); ewl_callback_append(prow, EWL_CALLBACK_CLICKED, ewl_fileselector_select_dir_cb, fs); - ewl_callback_append(prow, EWL_CALLBACK_DESTROY, - ewl_fileselector_dir_data_cleanup_cb, NULL); ecore_list_next(dirs); } @@ -882,7 +890,6 @@ if (cont) ewl_container_redirect_set(EWL_CONTAINER(parent_win), cont); - FREE(title); ecore_list_destroy(files); ecore_list_destroy(dirs); @@ -976,38 +983,6 @@ } static void -ewl_fileselector_file_data_cleanup_cb(Ewl_Widget *w, void *ev __UNUSED__, - void *data __UNUSED__) -{ - char *v; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("w", w); - DCHECK_TYPE("w", w, "widget"); - - v = ewl_widget_data_get(w, "FILESELECTOR_FILE"); - IF_FREE(v); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -static void -ewl_fileselector_dir_data_cleanup_cb(Ewl_Widget *w, void *ev __UNUSED__, - void *data __UNUSED__) -{ - char *v; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("w", w); - DCHECK_TYPE("w", w, "widget"); - - v = ewl_widget_data_get(w, "FILESELECTOR_DIR"); - IF_FREE(v); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -static void ewl_fileselector_files_free_cb(void *data) { char *v; @@ -1020,6 +995,3 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } - - - =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_fileselector.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- ewl_fileselector.h 23 Oct 2005 23:46:48 -0000 1.12 +++ ewl_fileselector.h 16 Nov 2005 23:36:28 -0000 1.13 @@ -57,7 +57,7 @@ char *ewl_fileselector_path_get(Ewl_Fileselector *fs); char *ewl_fileselector_file_get(Ewl_Fileselector *fs); -void ewl_fileselector_path_set(Ewl_Fileselector *fs, char *path); +void ewl_fileselector_path_set(Ewl_Fileselector *fs, const char *path); void ewl_fileselector_multiselect_set(Ewl_Fileselector *fs, unsigned int val); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_iconbox.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -3 -r1.74 -r1.75 --- ewl_iconbox.c 16 Nov 2005 07:51:21 -0000 1.74 +++ ewl_iconbox.c 16 Nov 2005 23:36:28 -0000 1.75 @@ -772,7 +772,7 @@ /* Add a callback to the border box label, for editing purposes... */ ewl_callback_prepend(EWL_ICONBOX_ICON(ib)->w_label, EWL_CALLBACK_MOUSE_DOWN, ewl_iconbox_icon_label_mouse_down_cb, ib); - ewl_callback_append(EWL_WIDGET(ib), EWL_CALLBACK_DESTROY, + ewl_callback_prepend(EWL_WIDGET(ib), EWL_CALLBACK_DESTROY, ewl_iconbox_icon_destroy_cb, NULL); /* Add this icon to the icon list */ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_tree2.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_tree2.h 8 Nov 2005 17:17:42 -0000 1.7 +++ ewl_tree2.h 16 Nov 2005 23:36:28 -0000 1.8 @@ -56,17 +56,17 @@ * @themekey /tree/group */ -typedef void *(*data_get)(void *data, int row, int column) Ewl_Model_Data_Get; +typedef void *(*get)(void *data, int row, int column) Ewl_Model_Fetch; -#define EWL_MODEL_DATA_GET(f) ((Ewl_Model_Data_Get *)f) +#define EWL_MODEL_DATA_GET(f) ((Ewl_Model_Fetch *)f) -typedef int (*data_sort)(void *data, int column) Ewl_Model_Data_Sort; +typedef int (*sort)(void *data, int column) Ewl_Model_Sort; -#define EWL_MODEL_DATA_SORT(f) ((Ewl_Model_Data_Sort *)f) +#define EWL_MODEL_DATA_SORT(f) ((Ewl_Model_Sort *)f) -typedef int (*data_count)(void *data) Ewl_Model_Data_Count; +typedef int (*count)(void *data) Ewl_Model_Count; -#define EWL_MODEL_DATA_COUNT(f) ((Ewl_Model_Data_Count *)f) +#define EWL_MODEL_DATA_COUNT(f) ((Ewl_Model_Count *)f) /** * @def EWL_MODEL(model) @@ -78,10 +78,10 @@ struct Ewl_Model { - Ewl_Model_Data_Get data_get; /**< Retrieve data for a cell */ - Ewl_Model_Data_Get subdata_get; /**< Check for subdata */ - Ewl_Model_Data_Sort column_sort; /**< Trigger sort on column */ - Ewl_Model_Data_Count row_count; /**< Count of data items */ + Ewl_Model_Fetch fetch; /**< Retrieve data for a cell */ + Ewl_Model_Fetch subfetch; /**< Check for subdata */ + Ewl_Model_Sort sort; /**< Trigger sort on column */ + Ewl_Model_Count count; /**< Count of data items */ }; /** @@ -95,7 +95,7 @@ struct Ewl_View { Ewl_View_Constructor constructor; /**< Create a widget for display */ - Ewl_View_Data_Assign data_set; /**< Assign data to a widget */ + Ewl_View_Assign assign; /**< Assign data to a widget */ }; typedef struct Ewl_Tree2 Ewl_Tree2; @@ -128,8 +128,8 @@ Ewl_Widget *ewl_tree2_new(void); int ewl_tree2_init(Ewl_Tree2 *tree); -void ewl_tree2_data_set(Ewl_Tree2 *m, void *data); -void *ewl_tree2_data_get(Ewl_Tree2 *m); +void ewl_tree2_set(Ewl_Tree2 *m, void *data); +void *ewl_tree2_fetch(Ewl_Tree2 *m); void ewl_tree2_column_append(Ewl_Tree2 *t, Ewl_Model *m, Ewl_View *v); void ewl_tree2_column_prepend(Ewl_Tree2 *t, Ewl_Model *m, Ewl_View *v); @@ -149,18 +149,34 @@ int ewl_tree2_fixed_rows_get(Ewl_Tree2 *tree); /* + * View manipulation + */ +Ewl_View *ewl_view_new(); +int *ewl_view_init(Ewl_View *view); + +void ewl_view_constructor_set(Ewl_View *view, Ewl_View_Constructor construct); +Ewl_View_Constructor ewl_view_constructor_get(Ewl_View *view); + +void ewl_view_assign_set(Ewl_View *view, Ewl_View_Assign assign); +Ewl_View_Assign ewl_view_constructor_get(Ewl_View *view); + +/* * Model manipulation. */ -Ewl_Model *ewl_model_new(void); +Ewl_Model *ewl_model_new(void); +int *ewl_model_init(Ewl_Model *model); + +void ewl_model_fetch_set(Ewl_Model *m, Ewl_Model_Fetch get); +Ewl_Model_Fetch ewl_model_fetch_get(Ewl_Model *m); -void ewl_model_data_get_set(Ewl_Model *m, Ewl_Model_Data_Get get); -Ewl_Model_Data_Get ewl_model_data_get_get(Ewl_Model *m); +void ewl_model_subfetch_set(Ewl_Model *m, Ewl_Model_Fetch get); +Ewl_Model_Fetch ewl_model_subfetch_get(Ewl_Model *m); -void ewl_model_subdata_get_set(Ewl_Model *m, Ewl_Model_Data_Get get); -Ewl_Model_Data_Get ewl_model_subdata_get_get(Ewl_Model *m); +void ewl_model_sort_set(Ewl_Model *m, Ewl_Model_Sort sort); +Ewl_Model_Sort ewl_model_sort_get(Ewl_Model *m); -void ewl_model_data_sort_set(Ewl_Model *m, Ewl_Model_Data_Sort sort); -Ewl_Model_Data_Sort ewl_model_data_sort_get(Ewl_Model *m); +void ewl_model_count_set(Ewl_Model *m, Ewl_Model_Count count); +Ewl_Model_Count ewl_model_count_get(Ewl_Model *m); /** * @} ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit: http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs