Modified dialog callback function.

Added two parameters:
  * Widget *sender -- to recognize the wiget that have sent message;
  * void *data -- to pass any user-defined data to the dialog.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-11-08 12:43:37 +03:00
parent ccabd60ffc
commit 11d21f1437
20 changed files with 164 additions and 139 deletions

View File

@ -34,10 +34,10 @@
#include "../src/search/search.h"
#include "../src/strutil.h"
#include "../src/dialog.h"
#include "../src/widget.h"
#include "../src/wtools.h"
#include "../src/dialog.h" /* do_refresh() */
#include "../src/strutil.h"
#include "../src/main.h"
#include "../src/history.h"
#include "../src/charsets.h"
@ -67,15 +67,16 @@
/*** file scope functions **********************************************/
static cb_ret_t
editcmd_dialog_raw_key_query_cb (struct Dlg_head *h, dlg_msg_t msg, int parm)
editcmd_dialog_raw_key_query_cb (struct Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_KEY:
dlg_stop (h);
h->ret_value = parm;
dlg_stop (h);
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -283,8 +284,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel
int w = str_term_width1 (query) + 7;
struct Dlg_head *raw_dlg =
create_dlg (0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
NULL, heading,
DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
add_widget (raw_dlg,
input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, INPUT_COMPLETE_DEFAULT));
add_widget (raw_dlg, label_new (3 - cancel, 2, query));

View File

@ -47,6 +47,7 @@
#include "edit-impl.h"
#include "edit-widget.h"
#include "../src/dialog.h"
#include "../src/widget.h" /* ButtonBar */
#include "../src/menu.h" /* menubar_new() */
#include "../src/cmddef.h"
@ -177,7 +178,8 @@ edit_adjust_size (Dlg_head *h)
/* Callback for the edit dialog */
static cb_ret_t
edit_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm)
edit_dialog_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
WEdit *edit;
@ -188,13 +190,12 @@ edit_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm)
case DLG_VALIDATE:
edit = (WEdit *) find_widget_type (h, edit_callback);
if (!edit_ok_to_exit (edit)) {
if (!edit_ok_to_exit (edit))
h->running = 1;
}
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -225,7 +225,8 @@ static void update_mode (Dlg_head * h)
}
static cb_ret_t
chl_callback (Dlg_head *h, dlg_msg_t msg, int parm)
chl_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_KEY:
@ -237,7 +238,7 @@ chl_callback (Dlg_head *h, dlg_msg_t msg, int parm)
}
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -398,7 +399,8 @@ static void b_setpos (int f_pos) {
}
static cb_ret_t
advanced_chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
advanced_chown_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
int i = 0, f_pos = BUTTONS - h->current->dlg_id - single_set - 1;
@ -525,20 +527,19 @@ advanced_chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
case '=':
case '+':
if (f_pos > 4)
break;
ch_flags[flag_pos] = parm;
update_mode (h);
advanced_chown_callback (h, DLG_KEY, KEY_RIGHT);
if (flag_pos > 8 || !(flag_pos % 3))
dlg_one_down (h);
if (f_pos <= 4) {
ch_flags[flag_pos] = parm;
update_mode (h);
advanced_chown_callback (h, sender, DLG_KEY, KEY_RIGHT, NULL);
if (flag_pos > 8 || !(flag_pos % 3))
dlg_one_down (h);
}
break;
}
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -78,7 +78,8 @@ static char **displays_status;
static int display_user_hotkey = 'u';
static cb_ret_t
display_callback (Dlg_head *h, dlg_msg_t msg, int parm)
display_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_UNFOCUS:
@ -119,7 +120,7 @@ display_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_NOT_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -636,7 +637,8 @@ display_bits_box (void)
#endif /* HAVE_CHARSET */
static cb_ret_t
tree_callback (Dlg_head *h, dlg_msg_t msg, int parm)
tree_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_POST_KEY:
@ -648,7 +650,7 @@ tree_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -160,7 +160,8 @@ static void chmod_refresh (Dlg_head *h)
}
static cb_ret_t
chmod_callback (Dlg_head *h, dlg_msg_t msg, int parm)
chmod_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
char buffer[BUF_TINY];
int id = h->current->dlg_id - BUTTONS + single_set * 2;
@ -190,7 +191,7 @@ chmod_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -137,7 +137,8 @@ next_file (void)
}
static cb_ret_t
chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
chown_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_DRAW:
@ -145,7 +146,7 @@ chown_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -900,11 +900,12 @@ static int insert_text (WInput *in, char *text, ssize_t size)
}
static cb_ret_t
query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
query_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
static char buff[MB_LEN_MAX] = "";
static int bl = 0;
switch (msg) {
case DLG_KEY:
switch (parm) {
@ -1023,7 +1024,7 @@ query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
break;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -204,9 +204,13 @@ dlg_set_size (Dlg_head *h, int lines, int cols)
}
/* Default dialog callback */
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm)
cb_ret_t
default_dlg_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
(void) sender;
(void) parm;
(void) data;
switch (msg) {
case DLG_DRAW:
@ -393,28 +397,25 @@ dlg_broadcast_msg (Dlg_head *h, widget_msg_t message, int reverse)
dlg_broadcast_msg_to (h, message, reverse, 0);
}
int dlg_focus (Dlg_head *h)
int
dlg_focus (Dlg_head *h)
{
if (!h->current)
return 0;
if (send_message (h->current, WIDGET_FOCUS, 0)){
(*h->callback) (h, DLG_FOCUS, 0);
return 1;
}
if ((h->current != NULL)
&& (send_message (h->current, WIDGET_FOCUS, 0) == MSG_HANDLED)) {
h->callback (h, h->current, DLG_FOCUS, 0, NULL);
return 1;
}
return 0;
}
static int
dlg_unfocus (Dlg_head *h)
{
if (!h->current)
return 0;
if (send_message (h->current, WIDGET_UNFOCUS, 0)){
(*h->callback) (h, DLG_UNFOCUS, 0);
return 1;
}
if ((h->current != NULL)
&& (send_message (h->current, WIDGET_UNFOCUS, 0) == MSG_HANDLED)) {
h->callback (h, h->current, DLG_UNFOCUS, 0, NULL);
return 1;
}
return 0;
}
@ -568,16 +569,16 @@ void update_cursor (Dlg_head *h)
/* Redraw the widgets in reverse order, leaving the current widget
* as the last one
*/
void dlg_redraw (Dlg_head *h)
void
dlg_redraw (Dlg_head *h)
{
(h->callback)(h, DLG_DRAW, 0);
h->callback (h, NULL, DLG_DRAW, 0, NULL);
dlg_broadcast_msg (h, WIDGET_DRAW, 1);
update_cursor (h);
}
void dlg_stop (Dlg_head *h)
void
dlg_stop (Dlg_head *h)
{
h->running = 0;
}
@ -705,26 +706,26 @@ dlg_key_event (Dlg_head *h, int d_key)
}
/* first can dlg_callback handle the key */
handled = (*h->callback) (h, DLG_KEY, d_key);
handled = h->callback (h, NULL, DLG_KEY, d_key, NULL);
/* next try the hotkey */
if (handled == MSG_NOT_HANDLED)
handled = dlg_try_hotkey (h, d_key);
if (handled == MSG_HANDLED)
(*h->callback) (h, DLG_HOTKEY_HANDLED, 0);
h->callback (h, NULL, DLG_HOTKEY_HANDLED, 0, NULL);
else
/* not used - then try widget_callback */
handled = send_message (h->current, WIDGET_KEY, d_key);
/* not used- try to use the unhandled case */
if (handled == MSG_NOT_HANDLED)
handled = (*h->callback) (h, DLG_UNHANDLED_KEY, d_key);
handled = h->callback (h, NULL, DLG_UNHANDLED_KEY, d_key, NULL);
if (handled == MSG_NOT_HANDLED)
dialog_handle_key (h, d_key);
(*h->callback) (h, DLG_POST_KEY, d_key);
h->callback (h, NULL, DLG_POST_KEY, d_key, NULL);
}
static int
@ -769,10 +770,11 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
/* Run dialog routines */
/* Init the process */
void init_dlg (Dlg_head *h)
void
init_dlg (Dlg_head *h)
{
/* Initialize dialog manager and widgets */
(*h->callback) (h, DLG_INIT, 0);
h->callback (h, NULL, DLG_INIT, 0, NULL);
dlg_broadcast_msg (h, WIDGET_INIT, 0);
if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES)
@ -796,15 +798,17 @@ void init_dlg (Dlg_head *h)
}
/* Shutdown the run_dlg */
void dlg_run_done (Dlg_head *h)
void
dlg_run_done (Dlg_head *h)
{
if (h->current)
(*h->callback) (h, DLG_END, 0);
if (h->current != NULL)
h->callback (h, h->current, DLG_END, 0, NULL);
current_dlg = h->parent;
}
void dlg_process_event (Dlg_head *h, int key, Gpm_Event *event)
void
dlg_process_event (Dlg_head *h, int key, Gpm_Event *event)
{
if (key == EV_NONE){
if (tty_got_interrupt ())
@ -835,7 +839,7 @@ frontend_run_dlg (Dlg_head *h)
execute_hooks (idle_hook);
while ((h->flags & DLG_WANT_IDLE) && is_idle ())
(*h->callback) (h, DLG_IDLE, 0);
h->callback (h, NULL, DLG_IDLE, 0, NULL);
/* Allow terminating the dialog from the idle handler */
if (!h->running)
@ -851,7 +855,7 @@ frontend_run_dlg (Dlg_head *h)
dlg_process_event (h, d_key, &event);
if (!h->running)
(*h->callback) (h, DLG_VALIDATE, 0);
h->callback (h, NULL, DLG_VALIDATE, 0, NULL);
}
}

View File

@ -65,26 +65,27 @@ typedef enum {
/* Dialog messages */
typedef enum {
DLG_KEY, /* Key before sending to widget */
DLG_INIT, /* Initialize dialog */
DLG_END, /* Shut down dialog */
DLG_ACTION, /* State of check- and radioboxes has changed
DLG_INIT = 0, /* Initialize dialog */
DLG_IDLE = 1, /* The idle state is active */
DLG_DRAW = 2, /* Draw dialog on screen */
DLG_FOCUS = 3, /* A widget has got focus */
DLG_UNFOCUS = 4, /* A widget has been unfocused */
DLG_RESIZE = 5, /* Window size has changed */
DLG_KEY = 6, /* Key before sending to widget */
DLG_HOTKEY_HANDLED = 7, /* A widget has got the hotkey */
DLG_POST_KEY = 8, /* The key has been handled */
DLG_UNHANDLED_KEY = 9, /* Key that no widget handled */
DLG_ACTION = 10, /* State of check- and radioboxes has changed
* and listbox current entry has changed */
DLG_DRAW, /* Draw dialog on screen */
DLG_FOCUS, /* A widget has got focus */
DLG_UNFOCUS, /* A widget has been unfocused */
DLG_RESIZE, /* Window size has changed */
DLG_POST_KEY, /* The key has been handled */
DLG_IDLE, /* The idle state is active */
DLG_UNHANDLED_KEY, /* Key that no widget handled */
DLG_HOTKEY_HANDLED, /* A widget has got the hotkey */
DLG_VALIDATE /* Dialog is to be closed */
DLG_VALIDATE = 11, /* Dialog is to be closed */
DLG_END = 12 /* Shut down dialog */
} dlg_msg_t;
/* Dialog callback */
typedef struct Dlg_head Dlg_head;
typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm);
typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
/* keybinding commands execution
sender: the widget that sent the command with data
@ -227,7 +228,8 @@ void init_widget (Widget *w, int y, int x, int lines, int cols,
callback_fn callback, mouse_h mouse_handler);
/* Default callback for dialogs */
cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm);
cb_ret_t default_dlg_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
/* Default paint routine for dialogs */
void common_dialog_repaint (struct Dlg_head *h);

View File

@ -222,7 +222,8 @@ find_check_regexp (const char *r)
* Validate regex, prevent closing the dialog if it's invalid.
*/
static cb_ret_t
find_parm_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
find_parm_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_VALIDATE:
@ -252,7 +253,7 @@ find_parm_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -982,7 +983,8 @@ view_edit_currently_selected_file (int unparsed_view, int edit)
}
static cb_ret_t
find_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
find_callback (struct Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_KEY:
@ -1000,7 +1002,7 @@ find_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -105,7 +105,8 @@ typedef struct Link_Area {
static Link_Area *link_area = NULL;
static gboolean inside_link_area = FALSE;
static cb_ret_t help_callback (struct Dlg_head *h, dlg_msg_t, int parm);
static cb_ret_t help_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
/* returns the position where text was found in the start buffer */
/* or 0 if not found */
@ -497,7 +498,7 @@ help_event (Gpm_Event *event, void *vp)
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
help_callback (w->parent, DLG_DRAW, 0);
help_callback (w->parent, NULL, DLG_DRAW, 0, NULL);
return 0;
}
@ -541,7 +542,7 @@ help_event (Gpm_Event *event, void *vp)
move_forward (1);
/* Show the new node */
help_callback (w->parent, DLG_DRAW, 0);
help_callback (w->parent, NULL, DLG_DRAW, 0, NULL);
return 0;
}
@ -561,7 +562,7 @@ help_help (void *vp)
if (p != NULL) {
currentpoint = p + 1; /* Skip the newline following the start of the node */
selected_item = NULL;
help_callback (h, DLG_DRAW, 0);
help_callback (h, NULL, DLG_DRAW, 0, NULL);
}
}
@ -583,7 +584,7 @@ help_index (void *vp)
currentpoint = new_item + 1; /* Skip the newline following the start of the node */
selected_item = NULL;
help_callback (h, DLG_DRAW, 0);
help_callback (h, NULL, DLG_DRAW, 0, NULL);
}
}
@ -604,7 +605,7 @@ help_back (void *vp)
if (history_ptr < 0)
history_ptr = HISTORY_SIZE - 1;
help_callback (h, DLG_DRAW, 0); /* FIXME: unneeded? */
help_callback (h, NULL, DLG_DRAW, 0, NULL); /* FIXME: unneeded? */
}
static void
@ -807,12 +808,12 @@ help_handle_key (Dlg_head *h, int c)
return MSG_NOT_HANDLED;
}
help_callback (h, DLG_DRAW, 0);
help_callback (h, NULL, DLG_DRAW, 0, NULL);
return MSG_HANDLED;
}
static cb_ret_t
help_callback (Dlg_head *h, dlg_msg_t msg, int parm)
help_callback (Dlg_head *h, Widget *sender, dlg_msg_t msg, int parm, void *data)
{
WButtonBar *bb;
@ -833,7 +834,7 @@ help_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return help_handle_key (h, parm);
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -436,7 +436,8 @@ hotlist_button_callback (int action)
}
static cb_ret_t
hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
hotlist_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_DRAW:
@ -511,7 +512,7 @@ hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -528,7 +529,7 @@ static int l_call (WListbox *list)
return LISTBOX_DONE;
} else {
hotlist_button_callback (B_ENTER);
hotlist_callback (dlg, DLG_POST_KEY, '\n');
hotlist_callback (dlg, NULL, DLG_POST_KEY, '\n', NULL);
return LISTBOX_CONT;
}
} else {
@ -539,7 +540,7 @@ static int l_call (WListbox *list)
}
hotlist_button_callback (B_UP_GROUP);
hotlist_callback (dlg, DLG_POST_KEY, 'u');
hotlist_callback (dlg, NULL, DLG_POST_KEY, 'u', NULL);
return LISTBOX_CONT;
}

View File

@ -294,7 +294,8 @@ static int bminus_cback (int action)
}
static cb_ret_t
layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
layout_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_DRAW:
@ -366,7 +367,7 @@ layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -762,7 +763,7 @@ change_screen_size (void)
/* Inform all running dialogs */
d = current_dlg;
while (d != NULL) {
(*d->callback) (d, DLG_RESIZE, 0);
(*d->callback) (d, NULL, DLG_RESIZE, 0, NULL);
d = d->parent;
}

View File

@ -212,7 +212,8 @@ learn_check_key (int c)
}
static cb_ret_t
learn_callback (Dlg_head *h, dlg_msg_t msg, int parm)
learn_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_DRAW:
@ -223,7 +224,7 @@ learn_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return learn_check_key (parm);
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -1586,7 +1586,8 @@ done_mc_profile (void)
}
static cb_ret_t
midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
midnight_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
unsigned long command;
@ -1724,7 +1725,7 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -99,24 +99,24 @@ update_command (void)
}
static cb_ret_t
panelize_callback (Dlg_head *h, dlg_msg_t msg, int parm)
panelize_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_INIT:
case DLG_POST_KEY:
tty_setcolor (MENU_ENTRY_COLOR);
update_command ();
return MSG_HANDLED;
case DLG_DRAW:
common_dialog_repaint (h);
tty_setcolor (COLOR_NORMAL);
draw_box (h, UY, UX, h->lines - 10, h->cols - 10);
return MSG_HANDLED;
case DLG_POST_KEY:
/* fall */
case DLG_INIT:
tty_setcolor (MENU_ENTRY_COLOR);
update_command ();
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -557,7 +557,8 @@ mcview_callback (Widget * w, widget_msg_t msg, int parm)
/* --------------------------------------------------------------------------------------------- */
cb_ret_t
mcview_dialog_callback (Dlg_head * h, dlg_msg_t msg, int parm)
mcview_dialog_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_RESIZE:
@ -565,7 +566,7 @@ mcview_dialog_callback (Dlg_head * h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}

View File

@ -8,8 +8,10 @@
#include "../src/global.h"
#include "../src/widget.h"
#include "../src/search/search.h"
#include "../src/dialog.h"
#include "../src/widget.h"
#include "../src/keybind.h" /* global_keymap_t */
/*** typedefs(not structures) and defined constants ********************/
@ -210,7 +212,8 @@ void mcview_search_cmd (mcview_t *view);
void mcview_toggle_magic_mode_cmd (mcview_t *view);
void mcview_toggle_nroff_mode_cmd (mcview_t *view);
cb_ret_t mcview_callback (Widget *w, widget_msg_t msg, int parm);
cb_ret_t mcview_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm);
cb_ret_t mcview_dialog_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data);
/* coord_cache.c: */
gboolean mcview_coord_cache_entry_less (const struct coord_cache_entry *,

View File

@ -284,11 +284,11 @@ button_event (Gpm_Event *event, void *data)
WButton *b = data;
if (event->type & (GPM_DOWN|GPM_UP)){
Dlg_head *h=b->widget.parent;
Dlg_head *h = b->widget.parent;
dlg_select_widget (b);
if (event->type & GPM_UP){
button_callback ((Widget *) data, WIDGET_KEY, ' ');
(*h->callback) (h, DLG_POST_KEY, ' ');
h->callback (h, &b->widget, DLG_POST_KEY, ' ', NULL);
return MOU_NORMAL;
}
}
@ -392,7 +392,7 @@ radio_callback (Widget *w, widget_msg_t msg, int parm)
switch (parm) {
case ' ':
r->sel = r->pos;
(*h->callback) (h, DLG_ACTION, 0);
h->callback (h, w, DLG_ACTION, 0, NULL);
radio_callback (w, WIDGET_FOCUS, ' ');
return MSG_HANDLED;
@ -414,7 +414,7 @@ radio_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_NOT_HANDLED;
case WIDGET_CURSOR:
(*h->callback) (h, DLG_ACTION, 0);
h->callback (h, w, DLG_ACTION, 0, NULL);
radio_callback (w, WIDGET_FOCUS, ' ');
widget_move (&r->widget, r->pos, 1);
return MSG_HANDLED;
@ -450,14 +450,14 @@ radio_event (Gpm_Event *event, void *data)
Widget *w = data;
if (event->type & (GPM_DOWN|GPM_UP)){
Dlg_head *h = r->widget.parent;
Dlg_head *h = r->widget.parent;
r->pos = event->y - 1;
dlg_select_widget (r);
if (event->type & GPM_UP){
radio_callback (w, WIDGET_KEY, ' ');
radio_callback (w, WIDGET_FOCUS, 0);
(*h->callback) (h, DLG_POST_KEY, ' ');
h->callback (h, w, DLG_POST_KEY, ' ', NULL);
return MOU_NORMAL;
}
}
@ -519,7 +519,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_NOT_HANDLED;
c->state ^= C_BOOL;
c->state ^= C_CHANGE;
(*h->callback) (h, DLG_ACTION, 0);
h->callback (h, w, DLG_ACTION, 0, NULL);
check_callback (w, WIDGET_FOCUS, ' ');
return MSG_HANDLED;
@ -552,13 +552,13 @@ check_event (Gpm_Event *event, void *data)
Widget *w = data;
if (event->type & (GPM_DOWN|GPM_UP)){
Dlg_head *h = c->widget.parent;
Dlg_head *h = c->widget.parent;
dlg_select_widget (c);
if (event->type & GPM_UP){
check_callback (w, WIDGET_KEY, ' ');
check_callback (w, WIDGET_FOCUS, 0);
(*h->callback) (h, DLG_POST_KEY, ' ');
h->callback (h, w, DLG_POST_KEY, ' ', NULL);
return MOU_NORMAL;
}
}
@ -1159,14 +1159,15 @@ dlg_hist_reposition (Dlg_head *dlg_head)
}
static cb_ret_t
dlg_hist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
dlg_hist_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_RESIZE:
return dlg_hist_reposition (h);
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -1215,7 +1216,7 @@ show_hist (GList *history, Widget *widget)
The main idea - create 4x4 dialog and add 2x2 list in
center of it, and let dialog function resize it to needed
size. */
dlg_hist_callback (query_dlg, DLG_RESIZE, 0);
dlg_hist_callback (query_dlg, NULL, DLG_RESIZE, 0, NULL);
if (query_dlg->y < widget->y) {
/* traverse */
@ -2415,8 +2416,7 @@ listbox_callback (Widget *w, widget_msg_t msg, int parm)
int action;
listbox_select_entry (l, e);
(*h->callback) (h, DLG_ACTION, l->pos);
h->callback (h, w, DLG_ACTION, l->pos, NULL);
if (l->cback)
action = (*l->cback) (l);
@ -2435,13 +2435,13 @@ listbox_callback (Widget *w, widget_msg_t msg, int parm)
ret_code = listbox_key (l, parm);
if (ret_code != MSG_NOT_HANDLED) {
listbox_draw (l, TRUE);
(*h->callback) (h, DLG_ACTION, l->pos);
h->callback (h, w, DLG_ACTION, l->pos, NULL);
}
return ret_code;
case WIDGET_CURSOR:
widget_move (&l->widget, l->cursor_y, 0);
(*h->callback) (h, DLG_ACTION, l->pos);
h->callback (h, w, DLG_ACTION, l->pos, NULL);
return MSG_HANDLED;
case WIDGET_FOCUS:

View File

@ -130,7 +130,8 @@ run_listbox (Listbox *l)
/* default query callback, used to reposition query */
static cb_ret_t
default_query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
default_query_callback (Dlg_head *h, Widget *sender,
dlg_msg_t msg, int parm, void *data)
{
switch (msg) {
case DLG_RESIZE:
@ -144,7 +145,7 @@ default_query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
default:
return default_dlg_callback (h, msg, parm);
return default_dlg_callback (h, sender, msg, parm, data);
}
}
@ -216,7 +217,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
add_widget (query_dlg, label_new (2, 3, text));
/* do resize before running and selecting any widget */
default_query_callback (query_dlg, DLG_RESIZE, 0);
default_query_callback (query_dlg, NULL, DLG_RESIZE, 0, NULL);
if (defbutton)
dlg_select_widget (defbutton);
@ -260,7 +261,7 @@ do_create_message (int flags, const char *title, const char *text)
d = last_query_dlg;
/* do resize before initing and running */
default_query_callback (d, DLG_RESIZE, 0);
default_query_callback (d, NULL, DLG_RESIZE, 0, NULL);
init_dlg (d);
g_free (p);