/* * delete the internal menu for the files */ static void wdg_file_menu_destroy(struct wdg_object *wo) { WDG_WO_EXT(struct wdg_file_handle, ww); int i = 0; /* nothing to free */ if (ww->nitems == 0) return; unpost_menu(ww->m); free_menu(ww->m); /* free all the items */ while(ww->items[i] != NULL) free_item(ww->items[i++]); for (i = 0; i < ww->nlist; i++) WDG_SAFE_FREE(ww->namelist[i]); /* free the array */ WDG_SAFE_FREE(ww->items); WDG_SAFE_FREE(ww->namelist); /* reset the counter */ ww->nitems = 0; }
/* * called to destroy a window */ static int wdg_dialog_destroy(struct wdg_object *wo) { WDG_WO_EXT(struct wdg_dialog, ww); WDG_DEBUG_MSG("wdg_dialog_destroy"); /* erase the window */ wbkgd(ww->win, COLOR_PAIR(wo->screen_color)); wbkgd(ww->sub, COLOR_PAIR(wo->screen_color)); werase(ww->sub); werase(ww->win); wnoutrefresh(ww->sub); wnoutrefresh(ww->win); /* dealloc the structures */ delwin(ww->sub); delwin(ww->win); /* free the text string */ WDG_SAFE_FREE(ww->text); WDG_BUG_IF(ww->text != NULL); WDG_SAFE_FREE(wo->extend); return WDG_ESUCCESS; }
/* * called to destroy the menu */ static int wdg_input_destroy(struct wdg_object *wo) { WDG_WO_EXT(struct wdg_input_handle, ww); size_t i = 0; WDG_DEBUG_MSG("wdg_input_destroy"); /* erase the window */ wbkgd(ww->win, COLOR_PAIR(wo->screen_color)); werase(ww->win); wnoutrefresh(ww->win); /* destroy the internal form */ wdg_input_form_destroy(wo); /* dealloc the structures */ delwin(ww->win); /* free all the items */ while(ww->fields[i] != NULL) free_field(ww->fields[i++]); /* free the array */ WDG_SAFE_FREE(ww->fields); /* free the buffer array */ WDG_SAFE_FREE(ww->buffers); WDG_SAFE_FREE(wo->extend); return WDG_E_SUCCESS; }
/* * destroy the dialog and * call the function associated to the file open dialog */ static void wdg_file_callback(struct wdg_object *wo, const char *path, char *file) { WDG_WO_EXT(struct wdg_file_handle, ww); void (*callback)(const char *, char *); char *p, *f; WDG_DEBUG_MSG("wdg_file_callback"); /* save the values before destroying the object */ callback = ww->callback; WDG_SAFE_STRDUP(p, path); WDG_SAFE_STRDUP(f, file); /* destroy the object */ wdg_destroy_object(&wo); wdg_redraw_all(); /* call the callback */ WDG_EXECUTE(callback, p, f); /* free saved data */ WDG_SAFE_FREE(f); WDG_SAFE_FREE(p); }
/* * called to destroy a window */ static int wdg_window_destroy(struct wdg_object *wo) { WDG_WO_EXT(struct wdg_window, ww); WDG_DEBUG_MSG("wdg_window_destroy (%p)", wo); /* erase the window */ wbkgd(ww->win, COLOR_PAIR(wo->screen_color)); wbkgd(ww->sub, COLOR_PAIR(wo->screen_color)); werase(ww->sub); werase(ww->win); wnoutrefresh(ww->sub); wnoutrefresh(ww->win); /* dealloc the structures */ delwin(ww->sub); delwin(ww->win); WDG_SAFE_FREE(wo->extend); return WDG_ESUCCESS; }
/* * called to destroy the file dialog */ static int wdg_file_destroy(struct wdg_object *wo) { WDG_WO_EXT(struct wdg_file_handle, ww); WDG_DEBUG_MSG("wdg_file_destroy"); /* erase the window */ wbkgd(ww->win, COLOR_PAIR(wo->screen_color)); werase(ww->win); wnoutrefresh(ww->win); /* destroy the internal menu */ wdg_file_menu_destroy(wo); /* dealloc the structures */ delwin(ww->win); /* restore the initial working directory */ chdir(ww->initpath); WDG_SAFE_FREE(wo->extend); return WDG_E_SUCCESS; }