1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Factor query_delete_selected_item out of push_hierbox_delete_button.

This commit is contained in:
Miciah Dashiel Butler Masters 2006-02-19 07:11:51 +00:00 committed by Miciah Dashiel Butler Masters
parent d87a90da6b
commit 6683f14bc1

View File

@ -719,38 +719,24 @@ push_ok_delete_button(void *context_)
listbox_sel_move(context->widget_data, -1); listbox_sel_move(context->widget_data, -1);
} }
widget_handler_status_T static widget_handler_status_T
push_hierbox_delete_button(struct dialog_data *dlg_data, query_delete_selected_item(void *context_)
struct widget_data *button)
{ {
/* [gettext_accelerator_context(push_hierbox_delete_button)] */ /* [gettext_accelerator_context(query_delete_selected_item)] */
struct terminal *term = dlg_data->win->term; struct listbox_context *context, *oldcontext = context_;
struct listbox_data *box = get_dlg_listbox_data(dlg_data); struct terminal *term = oldcontext->term;
struct listbox_data *box = oldcontext->box;
struct listbox_ops *ops = box->ops; struct listbox_ops *ops = box->ops;
struct listbox_item *item = box->sel; struct listbox_item *item = box->sel;
struct listbox_context *context;
unsigned char *text; unsigned char *text;
enum delete_error delete; enum delete_error delete;
if (!item) return EVENT_PROCESSED; assert(item);
assert(ops && ops->can_delete && ops->delete); context = init_listbox_context(box, term, item, NULL);
context = init_listbox_context(box, term, item, scan_for_marks);
if (!context) return EVENT_PROCESSED; if (!context) return EVENT_PROCESSED;
context->widget_data = dlg_data->widgets_data; context->widget_data = oldcontext->widget_data;
if (!context->item) {
msg_box(term, getml(context, NULL), 0,
listbox_message(delete_marked_items_title),
ALIGN_CENTER,
listbox_message(delete_marked_items),
context, 2,
N_("~Yes"), push_ok_delete_button, B_ENTER,
N_("~No"), done_listbox_context, B_ESC);
return EVENT_PROCESSED;
}
delete = ops->can_delete(item) delete = ops->can_delete(item)
? DELETE_LOCKED : DELETE_IMPOSSIBLE; ? DELETE_LOCKED : DELETE_IMPOSSIBLE;
@ -794,6 +780,45 @@ push_hierbox_delete_button(struct dialog_data *dlg_data,
return EVENT_PROCESSED; return EVENT_PROCESSED;
} }
widget_handler_status_T
push_hierbox_delete_button(struct dialog_data *dlg_data,
struct widget_data *button)
{
/* [gettext_accelerator_context(push_hierbox_delete_button)] */
struct terminal *term = dlg_data->win->term;
struct listbox_data *box = get_dlg_listbox_data(dlg_data);
struct listbox_ops *ops = box->ops;
struct listbox_item *item = box->sel;
struct listbox_context *context;
widget_handler_status_T status;
if (!item) return EVENT_PROCESSED;
assert(ops && ops->can_delete && ops->delete);
context = init_listbox_context(box, term, item, scan_for_marks);
if (!context) return EVENT_PROCESSED;
context->widget_data = dlg_data->widgets_data;
if (!context->item) {
msg_box(term, getml(context, NULL), 0,
listbox_message(delete_marked_items_title),
ALIGN_CENTER,
listbox_message(delete_marked_items),
context, 2,
N_("~Yes"), push_ok_delete_button, B_ENTER,
N_("~No"), done_listbox_context, B_ESC);
return EVENT_PROCESSED;
}
status = query_delete_selected_item(context);
mem_free(context);
return status;
}
/* Clear action */ /* Clear action */