/* * 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); }
/* * set the dialog attributes and text message */ void wdg_dialog_text(wdg_t *wo, size_t flags, const char *text) { WDG_WO_EXT(struct wdg_dialog, ww); int first = 1; ww->flags = flags; WDG_SAFE_STRDUP(ww->text, text); /* mark the buttons to be used */ if (ww->flags & WDG_OK) { ww->buttons[0].selected = 1; if (first) { ww->focus_button = 0; first = 0; } } if (ww->flags & WDG_YES) { ww->buttons[1].selected = 1; if (first) { ww->focus_button = 1; first = 0; } } if (ww->flags & WDG_NO) { ww->buttons[2].selected = 1; if (first) { ww->focus_button = 2; first = 0; } } if (ww->flags & WDG_CANCEL) { ww->buttons[3].selected = 1; if (first) { ww->focus_button = 3; first = 0; } } }