
Example 12-6. The notice.c program (continued)
xv_set(panel, PANEL_LAYOUT, PANEL_HORIZONTAL, NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Commit...",
PANEL_NOTIFY_PROC, my_notify_proc,
XV_KEY_DATA, MSG_ITEM, msg_item,
/*
* attach a prompt specific for this button used by
* notices
*/
XV_KEY_DATA, NOTICE_PROMPT, "Update all changes?",
/*
* Note there is no callback func here, but one could be
* written
*/
NULL);
window_fit(panel);
window_fit(frame);
xv_main_loop(frame);
}
/*
* my_notify_proc()
* The "key data" associated with the panel item is extracted via
* xv_get(). The resulting choice is displayed in the panel
* message item.
*/
Xv_opaque
my_notify_proc(item, event)
Panel_item item;
Event *event;
{
int result;
int (*func)();
char *prompt;
Panel_item msg_item;
Panel panel;
static Xv_notice notice = NULL;
func = (int(*)())xv_get(item, XV_KEY_DATA, CALLBACK_FUNC);
prompt = (char *)xv_get(item, XV_KEY_DATA, NOTICE_PROMPT);
msg_item = (Panel_item)xv_get(item, XV_KEY_DATA, MSG_ITEM);
panel = (Panel)xv_get(item, PANEL_PARENT_PANEL);
/*
* Create the notice and get a response.
*/
if (!notice) {
notice = xv_create(panel, NOTICE,
NOTICE_LOCK_SCREEN, TRUE,
NOTICE_STATUS, &result,
XV_SHOW, TRUE,
NOTICE_MESSAGE_STRINGS,
prompt,
"Press YES to confirm",
"Press NO to cancel",
NULL,
322 XView Programming Manual