Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_box.c ewl_misc.c ewl_misc.h ewl_paned.c Log Message: - add a way for widgets to hook into the shutdown system to cleanup and global data they've got hanging around =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_box.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 --- ewl_box.c 6 Dec 2006 16:27:10 -0000 1.32 +++ ewl_box.c 22 Dec 2006 19:24:59 -0000 1.33 @@ -34,6 +34,8 @@ static Box_Orientation *ewl_box_vertical = NULL; static Box_Orientation *ewl_box_horizontal = NULL; +static void ewl_box_cb_shutdown(void); + /* * And a pointer to the currently used orientation */ @@ -962,6 +964,8 @@ { DENTER_FUNCTION(DLEVEL_STABLE); + ewl_shutdown_add(ewl_box_cb_shutdown); + if (!ewl_box_vertical) { ewl_box_vertical = NEW(Box_Orientation, 1); if (!ewl_box_vertical) @@ -1046,4 +1050,16 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } + +static void +ewl_box_cb_shutdown(void) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + + IF_FREE(ewl_box_horizontal); + IF_FREE(ewl_box_vertical); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_misc.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -3 -r1.74 -r1.75 --- ewl_misc.c 16 Nov 2006 16:12:14 -0000 1.74 +++ ewl_misc.c 22 Dec 2006 19:24:59 -0000 1.75 @@ -38,6 +38,8 @@ static Ecore_List *free_evas_list = NULL; static Ecore_List *free_evas_object_list = NULL; +static Ecore_List *shutdown_hooks = NULL; + static int ewl_idle_render(void *data); static void ewl_init_parse_options(int *argc, char **argv); static void ewl_init_remove_option(int *argc, char **argv, int i); @@ -170,11 +172,12 @@ child_add_list = ecore_list_new(); ewl_embed_list = ecore_list_new(); ewl_window_list = ecore_list_new(); + shutdown_hooks = ecore_list_new(); if ((!reveal_list) || (!obscure_list) || (!configure_list) || (!realize_list) || (!destroy_list) || (!free_evas_list) || (!free_evas_object_list) || (!child_add_list) || (!ewl_embed_list) - || (!ewl_window_list)) { + || (!ewl_window_list) || (!shutdown_hooks)) { fprintf(stderr, "Unable to initialize internal configuration." " Out of memory?\n"); goto ERROR; @@ -264,6 +267,7 @@ int ewl_shutdown(void) { + Ewl_Shutdown_Hook hook; void (*shutdown)(void); DENTER_FUNCTION(DLEVEL_STABLE); @@ -271,6 +275,10 @@ if (--ewl_init_count) DRETURN_INT(ewl_init_count, DLEVEL_STABLE); + while ((hook = ecore_list_remove_first(shutdown_hooks))) + hook(); + IF_FREE_LIST(shutdown_hooks); + /* * Destroy all existing widgets. */ @@ -1093,4 +1101,16 @@ return indent; } + +void +ewl_shutdown_add(Ewl_Shutdown_Hook hook) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("hook", hook); + + ecore_list_prepend(shutdown_hooks, hook); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_misc.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_misc.h 6 Dec 2006 20:14:52 -0000 1.19 +++ ewl_misc.h 22 Dec 2006 19:24:59 -0000 1.20 @@ -22,6 +22,12 @@ void ewl_evas_object_destroy(Evas_Object *obj); char *ewl_debug_indent_get(int mod_dir); +/* + * Internal stuff + */ +typedef void (*Ewl_Shutdown_Hook)(void); +void ewl_shutdown_add(Ewl_Shutdown_Hook hook); + #undef DEBUG_MALLOCDEBUG #ifdef DEBUG_MALLOCDEBUG char *strdup(const char *str); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_paned.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- ewl_paned.c 14 Aug 2006 22:00:19 -0000 1.35 +++ ewl_paned.c 22 Dec 2006 19:24:59 -0000 1.36 @@ -20,6 +20,8 @@ static Ewl_Paned_Layout *vertical_layout = NULL; static Ewl_Paned_Layout *layout = NULL; +static void ewl_paned_cb_shutdown(void); + static void ewl_paned_grabber_cb_mouse_down(Ewl_Widget *w, void *ev, void *data); static void ewl_paned_grabber_cb_mouse_up(Ewl_Widget *w, void *ev, @@ -907,6 +909,8 @@ { DENTER_FUNCTION(DLEVEL_STABLE); + ewl_shutdown_add(ewl_paned_cb_shutdown); + horizontal_layout = NEW(Ewl_Paned_Layout, 1); if (!horizontal_layout) DRETURN(DLEVEL_STABLE); @@ -1011,3 +1015,13 @@ DRETURN_INT(ret, DLEVEL_STABLE); } +static void +ewl_paned_cb_shutdown(void) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + + IF_FREE(horizontal_layout); + IF_FREE(vertical_layout); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} ------------------------------------------------------------------------- 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