diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 1020a38ae..2dc416ef2 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -40,7 +40,6 @@ #include "lib/tty/tty.h" #include "lib/skin.h" -#include "lib/tty/mouse.h" #include "lib/tty/key.h" #include "lib/strutil.h" #include "lib/widget.h" @@ -375,6 +374,15 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event) return MOU_NORMAL; } + if (h->mouse != NULL) + { + int mou; + + mou = h->mouse (event, h); + if (mou != MOU_UNHANDLED) + return mou; + } + item = starting_widget; do { @@ -758,8 +766,8 @@ default_dlg_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, vo Dlg_head * create_dlg (gboolean modal, int y1, int x1, int lines, int cols, - const int *colors, dlg_cb_fn callback, const char *help_ctx, - const char *title, dlg_flags_t flags) + const int *colors, dlg_cb_fn callback, mouse_h mouse_handler, + const char *help_ctx, const char *title, dlg_flags_t flags) { Dlg_head *new_d; @@ -770,6 +778,7 @@ create_dlg (gboolean modal, int y1, int x1, int lines, int cols, memmove (new_d->color, colors, sizeof (dlg_colors_t)); new_d->help_ctx = help_ctx; new_d->callback = (callback != NULL) ? callback : default_dlg_callback; + new_d->mouse = mouse_handler; new_d->x = x1; new_d->y = y1; new_d->flags = flags; diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index db2cdf353..08f78d5f3 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -14,6 +14,7 @@ #include "lib/global.h" #include "lib/hook.h" /* hook_t */ #include "lib/keybind.h" /* global_keymap_t */ +#include "lib/tty/mouse.h" /* mouse_h */ /*** defined constants ***************************************************************************/ @@ -128,6 +129,7 @@ struct Dlg_head char *event_group; /* Name of event group for this dialog */ dlg_cb_fn callback; + mouse_h mouse; dlg_shortcut_str get_shortcut; /* Shortcut string */ dlg_title_str get_title; /* useless for modal dialogs */ }; @@ -155,7 +157,7 @@ void draw_box (Dlg_head * h, int y, int x, int ys, int xs, gboolean single); /* Creates a dialog head */ Dlg_head *create_dlg (gboolean modal, int y1, int x1, int lines, int cols, - const int *colors, dlg_cb_fn callback, + const int *colors, dlg_cb_fn callback, mouse_h mouse_handler, const char *help_ctx, const char *title, dlg_flags_t flags); void dlg_set_default_colors (void); diff --git a/lib/widget/history.c b/lib/widget/history.c index 4c7d618fa..bd843a6a6 100644 --- a/lib/widget/history.c +++ b/lib/widget/history.c @@ -320,7 +320,7 @@ history_show (GList ** history, Widget * widget) hist_data.maxlen = maxlen; query_dlg = - create_dlg (TRUE, 0, 0, 4, 4, dialog_colors, history_dlg_callback, + create_dlg (TRUE, 0, 0, 4, 4, dialog_colors, history_dlg_callback, NULL, "[History-query]", _("History"), DLG_COMPACT); query_dlg->data = &hist_data; diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index 486dcb248..3840c41bd 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -1323,7 +1323,7 @@ complete_engine (WInput * in, int what_to_do) query_height = h; query_width = w; query_dlg = create_dlg (TRUE, y, x, query_height, query_width, - dialog_colors, query_callback, + dialog_colors, query_callback, NULL, "[Completion]", NULL, DLG_COMPACT); query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL); add_widget (query_dlg, query_list); diff --git a/lib/widget/listbox-window.c b/lib/widget/listbox-window.c index 19c0483bb..9aa77577a 100644 --- a/lib/widget/listbox-window.c +++ b/lib/widget/listbox-window.c @@ -113,7 +113,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols, listbox->dlg = create_dlg (TRUE, ypos, xpos, lines + space, cols + space, - listbox_colors, NULL, help, title, DLG_REVERSE | DLG_TRYUP); + listbox_colors, NULL, NULL, help, title, DLG_REVERSE | DLG_TRYUP); listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL); add_widget (listbox->dlg, listbox->list); diff --git a/lib/widget/quick.c b/lib/widget/quick.c index c6b415a23..6b1379401 100644 --- a/lib/widget/quick.c +++ b/lib/widget/quick.c @@ -73,11 +73,12 @@ quick_dialog_skip (QuickDialog * qd, int nskip) if ((qd->xpos == -1) || (qd->ypos == -1)) dd = create_dlg (TRUE, 0, 0, qd->ylen, qd->xlen, - dialog_colors, qd->callback, qd->help, qd->title, + dialog_colors, qd->callback, qd->mouse, qd->help, qd->title, DLG_CENTER | DLG_TRYUP | DLG_REVERSE); else dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen, - dialog_colors, qd->callback, qd->help, qd->title, DLG_REVERSE); + dialog_colors, qd->callback, qd->mouse, qd->help, qd->title, + DLG_REVERSE); for (qw = qd->widgets; qw->widget_type != quick_end; qw++) { diff --git a/lib/widget/quick.h b/lib/widget/quick.h index 000b27eed..ba852a4f2 100644 --- a/lib/widget/quick.h +++ b/lib/widget/quick.h @@ -5,6 +5,8 @@ #ifndef MC__QUICK_H #define MC__QUICK_H +#include "lib/tty/mouse.h" + /*** typedefs(not structures) and defined constants **********************************************/ #define QUICK_CHECKBOX(x, xdiv, y, ydiv, txt, st) \ @@ -218,6 +220,7 @@ typedef struct const char *help; QuickWidget *widgets; dlg_cb_fn callback; + mouse_h mouse; gboolean i18n; /* If true, internationalization has happened */ } QuickDialog; diff --git a/lib/widget/wtools.c b/lib/widget/wtools.c index 1f54d5d81..3d902a247 100644 --- a/lib/widget/wtools.c +++ b/lib/widget/wtools.c @@ -244,7 +244,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help, { QuickDialog Quick_input = { len, lines + 6, -1, -1, header, - help, quick_widgets, NULL, TRUE + help, quick_widgets, NULL, NULL, TRUE }; for (i = 0; i < 4; i++) @@ -343,7 +343,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...) /* prepare dialog */ query_dlg = - create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback, + create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback, NULL, "[QueryBox]", header, dlg_flags); if (count > 0) diff --git a/src/diffviewer/search.c b/src/diffviewer/search.c index 7b89af792..00573a87f 100644 --- a/src/diffviewer/search.c +++ b/src/diffviewer/search.c @@ -135,7 +135,7 @@ mcdiffview_dialog_search (WDiff * dview) QuickDialog search_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"), "[Input Line Keys]", - search_widgets, NULL, FALSE + search_widgets, NULL, NULL, FALSE }; mcdiffview_dialog_fix_buttons_positions (&search_input); diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index 64d207e73..ff87b8ed3 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -2432,7 +2432,7 @@ dview_diff_options (WDiff * dview) QuickDialog diffopt = { OPTX, OPTY, -1, -1, N_("Diff Options"), "[Diff Options]", - diffopt_widgets, NULL, FALSE + diffopt_widgets, NULL, NULL, FALSE }; if (quick_dialog (&diffopt) != B_CANCEL) @@ -3308,7 +3308,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char /* Create dialog and widgets, put them on the dialog */ dview_dlg = - create_dlg (FALSE, 0, 0, LINES, COLS, NULL, dview_dialog_callback, + create_dlg (FALSE, 0, 0, LINES, COLS, NULL, dview_dialog_callback, NULL, "[Diff Viewer]", NULL, DLG_WANT_TAB); dview = g_new0 (WDiff, 1); diff --git a/src/editor/edit.c b/src/editor/edit.c index 87791d60a..c7f38aa93 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -208,7 +208,7 @@ edit_about (void) cols = max (win_len, cols) + 6; /* dialog */ - about_dlg = create_dlg (TRUE, 0, 0, lines, cols, dialog_colors, NULL, + about_dlg = create_dlg (TRUE, 0, 0, lines, cols, dialog_colors, NULL, NULL, "[Internal File Editor]", header, DLG_CENTER | DLG_TRYUP); add_widget (about_dlg, label_new (3, (cols - version_len) / 2, version)); diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index 24d225c3b..52905fabb 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -431,7 +431,7 @@ edit_get_save_file_as (WEdit * edit) QuickDialog Quick_options = { DLG_WIDTH, DLG_HEIGHT, -1, -1, N_("Save As"), "[Save File As]", - quick_widgets, NULL, FALSE + quick_widgets, NULL, NULL, FALSE }; if (quick_dialog (&Quick_options) != B_CANCEL) @@ -1596,7 +1596,7 @@ menu_save_mode_cmd (void) QuickDialog dialog = { DLG_X, DLG_Y, -1, -1, N_("Edit Save Mode"), - "[Edit Save Mode]", widgets, NULL, FALSE + "[Edit Save Mode]", widgets, NULL, NULL, FALSE }; size_t i; @@ -3214,7 +3214,7 @@ edit_mail_dialog (WEdit * edit) QuickDialog Quick_input = { 50, MAIL_DLG_HEIGHT, -1, -1, N_("Mail"), - "[Input Line Keys]", quick_widgets, NULL, FALSE + "[Input Line Keys]", quick_widgets, NULL, NULL, FALSE }; quick_widgets[2].u.input.text = mail_cc_last ? mail_cc_last : ""; diff --git a/src/editor/editcmd_dialogs.c b/src/editor/editcmd_dialogs.c index d5bfc97c0..a2630b059 100644 --- a/src/editor/editcmd_dialogs.c +++ b/src/editor/editcmd_dialogs.c @@ -137,7 +137,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha QuickDialog Quick_input = { REPLACE_DLG_WIDTH, REPLACE_DLG_HEIGHT, -1, -1, N_("Replace"), - "[Input Line Keys]", quick_widgets, NULL, FALSE + "[Input Line Keys]", quick_widgets, NULL, NULL, FALSE }; if (quick_dialog (&Quick_input) != B_CANCEL) @@ -213,7 +213,7 @@ editcmd_dialog_search_show (WEdit * edit) QuickDialog Quick_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"), - "[Input Line Keys]", quick_widgets, NULL, TRUE + "[Input Line Keys]", quick_widgets, NULL, NULL, TRUE }; #ifdef ENABLE_NLS @@ -340,7 +340,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 (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb, + create_dlg (TRUE, 0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb, NULL, NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB); add_widget (raw_dlg, input_new (3 - cancel, w - 5, input_get_default_colors (), 2, "", 0, INPUT_COMPLETE_DEFAULT)); @@ -392,7 +392,7 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len, /* create the dialog */ compl_dlg = create_dlg (TRUE, start_y, start_x, compl_dlg_h, compl_dlg_w, - dialog_colors, NULL, "[Completion]", NULL, DLG_COMPACT); + dialog_colors, NULL, NULL, "[Completion]", NULL, DLG_COMPACT); /* create the listbox */ compl_list = listbox_new (1, 1, compl_dlg_h - 2, compl_dlg_w - 2, FALSE, NULL); @@ -480,7 +480,7 @@ editcmd_dialog_select_definition_show (WEdit * edit, char *match_expr, int max_l /* create the dialog */ def_dlg = create_dlg (TRUE, start_y, start_x, def_dlg_h, def_dlg_w, - dialog_colors, NULL, "[Definitions]", match_expr, DLG_COMPACT); + dialog_colors, NULL, NULL, "[Definitions]", match_expr, DLG_COMPACT); /* create the listbox */ def_list = listbox_new (1, 1, def_dlg_h - 2, def_dlg_w - 2, FALSE, NULL); @@ -628,7 +628,7 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text { QuickDialog Quick_input = { dlg_width, dlg_height, 0, 0, N_("Confirm replace"), - "[Input Line Keys]", quick_widgets, NULL, FALSE + "[Input Line Keys]", quick_widgets, NULL, NULL, FALSE }; /* Sometimes menu can hide replaced text. I don't like it */ diff --git a/src/editor/editoptions.c b/src/editor/editoptions.c index 3f2bcdc96..0f9d4d874 100644 --- a/src/editor/editoptions.c +++ b/src/editor/editoptions.c @@ -125,7 +125,7 @@ edit_options_dialog (WEdit * edit) QuickDialog Quick_options = { OPT_DLG_W, OPT_DLG_H, -1, -1, N_("Editor options"), - "[Editor options]", quick_widgets, NULL, FALSE + "[Editor options]", quick_widgets, NULL, NULL, FALSE }; #ifdef ENABLE_NLS diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index 2314ba11f..9c46f4ef5 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -393,7 +393,7 @@ edit_file (const vfs_path_t * _file_vpath, int line) /* Create a new dialog and add it widgets to it */ edit_dlg = - create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback, + create_dlg (FALSE, 0, 0, LINES, COLS, NULL, edit_dialog_callback, NULL, "[Internal File Editor]", NULL, DLG_WANT_TAB); edit_dlg->get_shortcut = edit_get_shortcut; diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c index 6f932b16a..e3c76e941 100644 --- a/src/filemanager/achown.c +++ b/src/filemanager/achown.c @@ -317,7 +317,7 @@ do_enter_key (Dlg_head * h, int f_pos) chl_end = 0; chl_dlg = - create_dlg (TRUE, lyy, lxx, 13, 17, dialog_colors, chl_callback, + create_dlg (TRUE, lyy, lxx, 13, 17, dialog_colors, chl_callback, NULL, "[Advanced Chown]", title, DLG_COMPACT | DLG_REVERSE); /* get new listboxes */ @@ -663,7 +663,7 @@ init_chown_advanced (void) x_toggle = 070; ch_dlg = - create_dlg (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback, + create_dlg (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback, NULL, "[Advanced Chown]", _("Chown advanced command"), DLG_CENTER | DLG_REVERSE); #define XTRACT(i) BY+chown_advanced_but[i].y, BX+chown_advanced_but[i].x, \ diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index e0d6aef9e..742beb3a6 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -296,7 +296,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status) displays_status = _status; dd = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, - display_callback, "[Listing Mode...]", display_title, + display_callback, NULL, "[Listing Mode...]", display_title, DLG_CENTER | DLG_REVERSE); add_widget (dd, cancel_button); @@ -368,7 +368,7 @@ init_disp_bits_box (void) do_refresh (); dbits_dlg = - create_dlg (TRUE, 0, 0, DISPY, DISPX, dialog_colors, NULL, + create_dlg (TRUE, 0, 0, DISPY, DISPX, dialog_colors, NULL, NULL, "[Display bits]", _("Display bits"), DLG_CENTER | DLG_REVERSE); add_widget (dbits_dlg, label_new (3, 4, _("Input / display codepage:"))); @@ -622,7 +622,7 @@ sort_box (panel_sort_info_t * info) QuickDialog quick_dlg = { dlg_width, dlg_height, -1, -1, N_("Sort order"), "[Sort Order...]", - quick_widgets, NULL, TRUE + quick_widgets, NULL, NULL, TRUE }; quick_widgets[5].u.radio.items = sort_orders_names; @@ -751,7 +751,7 @@ confirm_box (void) { QuickDialog confirmation = { dlg_width, dlg_height, -1, -1, title, - "[Confirmation]", conf_widgets, NULL, TRUE + "[Confirmation]", conf_widgets, NULL, NULL, TRUE }; (void) quick_dialog (&confirmation); @@ -788,7 +788,7 @@ display_bits_box (void) /* AB:FIXME: test dialog */ QuickDialog display_bits = { DISPX, DISPY, -1, -1, _("Display bits"), - "[Display bits]", display_widgets, NULL, TRUE + "[Display bits]", display_widgets, NULL, NULL, TRUE }; int i; @@ -905,7 +905,7 @@ tree_box (const char *current_dir) /* Create the components */ dlg = create_dlg (TRUE, 0, 0, LINES - 9, COLS - 20, dialog_colors, - tree_callback, "[Directory Tree]", + tree_callback, NULL, "[Directory Tree]", _("Directory tree"), DLG_CENTER | DLG_REVERSE); mytree = tree_new (2, 2, dlg->lines - 6, dlg->cols - 5, FALSE); @@ -970,6 +970,7 @@ configure_vfs (void) #else NULL, #endif + NULL, FALSE }; @@ -1033,7 +1034,7 @@ cd_dialog (void) QuickDialog Quick_input = { xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"), - "[Quick cd]", quick_widgets, NULL, TRUE + "[Quick cd]", quick_widgets, NULL, NULL, TRUE }; return (quick_dialog (&Quick_input) != B_CANCEL) ? my_str : NULL; @@ -1062,7 +1063,7 @@ symlink_dialog (const vfs_path_t * existing_vpath, const vfs_path_t * new_vpath, QuickDialog Quick_input = { 64, 12, -1, -1, N_("Symbolic link"), - "[File Menu]", quick_widgets, NULL, FALSE + "[File Menu]", quick_widgets, NULL, NULL, FALSE }; if (quick_dialog (&Quick_input) == B_CANCEL) @@ -1109,7 +1110,7 @@ jobs_cmd (void) } #endif /* ENABLE_NLS */ - jobs_dlg = create_dlg (TRUE, 0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL, + jobs_dlg = create_dlg (TRUE, 0, 0, JOBS_Y, JOBS_X, dialog_colors, NULL, NULL, "[Background jobs]", _("Background Jobs"), DLG_CENTER | DLG_REVERSE); bg_list = listbox_new (2, 3, JOBS_Y - 9, JOBS_X - 7, FALSE, NULL); @@ -1194,7 +1195,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c title = g_strdup_printf (_("Password for \\\\%s\\%s"), host, share); - auth_dlg = create_dlg (TRUE, 0, 0, dialog_y, dialog_x, dialog_colors, NULL, + auth_dlg = create_dlg (TRUE, 0, 0, dialog_y, dialog_x, dialog_colors, NULL, NULL, "[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE); g_free (title); diff --git a/src/filemanager/chmod.c b/src/filemanager/chmod.c index a51b47ebc..b1b7607c9 100644 --- a/src/filemanager/chmod.c +++ b/src/filemanager/chmod.c @@ -306,7 +306,7 @@ init_chmod (const char *fname, const struct stat *sf_stat) ch_dlg = create_dlg (TRUE, 0, 0, lines, cols, dialog_colors, - chmod_callback, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE); + chmod_callback, NULL, "[Chmod]", _("Chmod command"), DLG_CENTER | DLG_REVERSE); for (i = 0; i < chmod_but_num; i++) { diff --git a/src/filemanager/chown.c b/src/filemanager/chown.c index 5953023b0..3dc6f2b08 100644 --- a/src/filemanager/chown.c +++ b/src/filemanager/chown.c @@ -177,7 +177,7 @@ init_chown (void) single_set = (current_panel->marked < 2) ? 3 : 0; ch_dlg = - create_dlg (TRUE, 0, 0, 18, 74, dialog_colors, chown_callback, "[Chown]", + create_dlg (TRUE, 0, 0, 18, 74, dialog_colors, chown_callback, NULL, "[Chown]", _("Chown command"), DLG_CENTER | DLG_REVERSE); for (i = 0; i < BUTTONS - single_set; i++) diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 7b8018ea5..f36782eae 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -267,7 +267,7 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se QuickDialog quick_dlg = { DX, DY, -1, -1, title, - "[Select/Unselect Files]", quick_widgets, NULL, FALSE + "[Select/Unselect Files]", quick_widgets, NULL, NULL, FALSE }; if (quick_dialog (&quick_dlg) == B_CANCEL) diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 42cf3199d..cc05dbac7 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -2390,7 +2390,7 @@ compute_dir_size_create_ui (void) ui = g_new (ComputeDirSizeUI, 1); - ui->dlg = create_dlg (TRUE, 0, 0, 8, COLS / 2, dialog_colors, NULL, + ui->dlg = create_dlg (TRUE, 0, 0, 8, COLS / 2, dialog_colors, NULL, NULL, NULL, _("Directory scanning"), DLG_CENTER); ui->dirname = label_new (3, 3, ""); add_widget (ui->dlg, ui->dirname); diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index 2cee13c1c..a7ad2d191 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -418,7 +418,7 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode) /* FIXME - missing help node */ ui->replace_dlg = - create_dlg (TRUE, 0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, "[Replace]", + create_dlg (TRUE, 0, 0, rd_ylen, rd_xlen, alarm_colors, NULL, NULL, "[Replace]", title, DLG_CENTER | DLG_REVERSE); /* prompt -- centered */ @@ -573,7 +573,8 @@ file_op_context_create_ui_without_init (FileOpContext * ctx, gboolean with_eta, ui->op_dlg = create_dlg (TRUE, 0, 0, dlg_height, dlg_width, - dialog_colors, NULL, NULL, op_names[ctx->operation], DLG_CENTER | DLG_REVERSE); + dialog_colors, NULL, NULL, NULL, op_names[ctx->operation], + DLG_CENTER | DLG_REVERSE); add_widget (ui->op_dlg, button_new (dlg_height - 3, dlg_width / 2 + 1, FILE_ABORT, @@ -1086,7 +1087,7 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation, QuickDialog Quick_input = { fmd_xlen, FMDY, -1, -1, op_names[operation], - "[Mask Copy/Rename]", fmd_widgets, NULL, TRUE + "[Mask Copy/Rename]", fmd_widgets, NULL, NULL, TRUE }; ask_file_mask: diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 0bea40b3b..07ee2adc5 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -550,7 +550,8 @@ find_parameters (char **start_dir, ssize_t * start_dir_len, find_dlg = create_dlg (TRUE, 0, 0, FIND_Y, FIND_X, dialog_colors, - find_parm_callback, "[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE); + find_parm_callback, NULL, "[Find File]", _("Find File"), + DLG_CENTER | DLG_REVERSE); add_widget (find_dlg, button_new (FIND_Y - 3, FIND_X * 3 / 4 - b1 / 2, B_CANCEL, NORMAL_BUTTON, buts[1], @@ -1499,7 +1500,7 @@ setup_gui (void) } find_dlg = - create_dlg (TRUE, 0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback, + create_dlg (TRUE, 0, 0, FIND2_Y, FIND2_X, dialog_colors, find_callback, NULL, "[Find File]", _("Find File"), DLG_CENTER | DLG_REVERSE); add_widget (find_dlg, diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index d844ea0a8..1b78d4e1f 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -777,7 +777,7 @@ init_hotlist (int list_type) hotlist_dlg = create_dlg (TRUE, 0, 0, LINES - 2, hotlist_cols, dialog_colors, - hotlist_callback, help_node, title, DLG_CENTER | DLG_REVERSE); + hotlist_callback, NULL, help_node, title, DLG_CENTER | DLG_REVERSE); for (i = 0; i < BUTTONS; i++) { @@ -842,7 +842,7 @@ init_movelist (int list_type, struct hotlist *item) movelist_dlg = create_dlg (TRUE, 0, 0, LINES - 6, movelist_cols, dialog_colors, - hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE); + hotlist_callback, NULL, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE); g_free (hdr); for (i = 0; i < BUTTONS; i++) @@ -1062,7 +1062,7 @@ add_new_entry_input (const char *header, const char *text1, const char *text2, { QuickDialog Quick_input = { len, lines1 + lines2 + 7, -1, -1, header, - help, quick_widgets, NULL, FALSE + help, quick_widgets, NULL, NULL, FALSE }; for (i = 0; i < 7; i++) @@ -1154,7 +1154,7 @@ add_new_group_input (const char *header, const char *label, char **result) { QuickDialog Quick_input = { len, lines + 6, -1, -1, header, - "[Hotlist]", quick_widgets, NULL, FALSE + "[Hotlist]", quick_widgets, NULL, NULL, FALSE }; int relative_y[] = { 1, 1, 1, 0, 2 }; /* the relative_x component from the diff --git a/src/filemanager/info.c b/src/filemanager/info.c index 06fc549b3..b57dd8b76 100644 --- a/src/filemanager/info.c +++ b/src/filemanager/info.c @@ -316,26 +316,6 @@ info_callback (Widget * w, widget_msg_t msg, int parm) } } -/* --------------------------------------------------------------------------------------------- */ - -static int -info_event (Gpm_Event * event, void *data) -{ - Widget *w = (Widget *) data; - Gpm_Event local; - - if (!mouse_global_in_widget (event, w)) - return MOU_UNHANDLED; - - local = mouse_get_local (event, w); - - /* rest of the upper frame, the menu is invisible - call menu */ - if ((local.type & GPM_DOWN) != 0 && local.y == 1 && !menubar_visible) - return the_menubar->widget.mouse (event, the_menubar); - - return MOU_NORMAL; -} - /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -345,7 +325,7 @@ info_new (int y, int x, int lines, int cols) { struct WInfo *info = g_new (struct WInfo, 1); - init_widget (&info->widget, y, x, lines, cols, info_callback, info_event); + init_widget (&info->widget, y, x, lines, cols, info_callback, NULL); /* We do not want the cursor */ widget_want_cursor (info->widget, 0); diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index 518b05b37..56d13a702 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -515,7 +515,7 @@ init_layout (void) layout_dlg = create_dlg (TRUE, 0, 0, 14, width, - dialog_colors, layout_callback, "[Layout]", + dialog_colors, layout_callback, NULL, "[Layout]", _("Layout"), DLG_CENTER | DLG_REVERSE); /* buttons */ diff --git a/src/filemanager/listmode.c b/src/filemanager/listmode.c index 84e6d9ff5..ded78c76e 100644 --- a/src/filemanager/listmode.c +++ b/src/filemanager/listmode.c @@ -198,7 +198,7 @@ init_listmode (char *oldlistformat) do_refresh (); listmode_dlg = - create_dlg (TRUE, 0, 0, 22, 74, dialog_colors, NULL, listmode_section, + create_dlg (TRUE, 0, 0, 22, 74, dialog_colors, NULL, NULL, listmode_section, "Listing format edit", DLG_CENTER | DLG_REVERSE); add_widget (listmode_dlg, groupbox_new (UY, UX, 4, 63, "General options")); diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index d819e66bf..3b1d0657b 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -1587,6 +1587,48 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void } } +/* --------------------------------------------------------------------------------------------- */ + +static int +midnight_event (Gpm_Event *event, void *data) +{ + Dlg_head *h = (Dlg_head *) data; + int ret = MOU_UNHANDLED; + + if (event->y == h->y + 1) + { + /* menubar */ + if (menubar_visible) + ret = ((Widget *) the_menubar)->mouse (event, the_menubar); + else + { + Widget *w; + + w = get_panel_widget (0); + ret = w->mouse (event, w); + + if (ret == MOU_UNHANDLED) + { + w = get_panel_widget (1); + ret = w->mouse (event, w); + } + + if (ret == MOU_UNHANDLED) + ret = ((Widget *) the_menubar)->mouse (event, the_menubar); + } + } + else if (event->y == h->y + h->lines && mc_global.keybar_visible) + { + /* buttonbar */ + + /* in general, this can be handled in default way (dlg_mouse_event) + * but let make it here to avoid walking in widget list */ + ret = ((Widget *) the_bar)->mouse (event, the_bar); + } + + return ret; +} + /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -1600,6 +1642,8 @@ update_menu (void) menubar_set_visible (the_menubar, menubar_visible); } +/* --------------------------------------------------------------------------------------------- */ + void midnight_set_buttonbar (WButtonBar * b) { @@ -1707,7 +1751,7 @@ do_nc (void) #endif midnight_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, midnight_colors, midnight_callback, - "[main]", NULL, DLG_WANT_IDLE); + midnight_event, "[main]", NULL, DLG_WANT_IDLE); if (mc_global.mc_run_mode == MC_RUN_FULL) setup_mc (); diff --git a/src/filemanager/option.c b/src/filemanager/option.c index cfebcdeb6..28240d394 100644 --- a/src/filemanager/option.c +++ b/src/filemanager/option.c @@ -177,7 +177,7 @@ configure_box (void) QuickDialog Quick_input = { dlg_width, dlg_height, -1, -1, N_("Configure options"), "[Configuration]", - quick_widgets, configure_callback, TRUE + quick_widgets, configure_callback, NULL, TRUE }; int b0_len, b1_len; @@ -367,7 +367,7 @@ panel_options_box (void) QuickDialog Quick_input = { dlg_width, dlg_height, -1, -1, N_("Panel options"), "[Panel options]", - quick_widgets, NULL, TRUE + quick_widgets, NULL, NULL, TRUE }; int b0_len, b1_len; diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index fd3f82bcf..cacbadd19 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -3536,18 +3536,20 @@ mouse_sort_col (WPanel * panel, int x) /* --------------------------------------------------------------------------------------------- */ /** * Mouse callback of the panel minus repainting. - * If the event is redirected to the menu, *redir is set to TRUE. */ -static inline int -do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) +static int +panel_event (Gpm_Event * event, void *data) { + WPanel *panel = (WPanel *) data; + Widget *w = (Widget *) data; + const int lines = llines (panel); const gboolean is_active = dlg_widget_active (panel); const gboolean mouse_down = (event->type & GPM_DOWN) != 0; - Widget *w = (Widget *) panel; Gpm_Event local; - *redir = FALSE; + if (!mouse_global_in_widget (event, (Widget *) data)) + return MOU_UNHANDLED; local = mouse_get_local (event, w); @@ -3558,47 +3560,41 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) if (local.x == 2) { directory_history_prev (panel); + goto finish; + } + + /* ">" button */ + if (local.x == w->cols - 1) + { + directory_history_next (panel); + goto finish; + } + + /* "^" button */ + if (local.x >= w->cols - 4 && local.x <= w->cols - 2) + { + directory_history_list (panel); + /* both panels have been redrawn */ return MOU_NORMAL; } /* "." button show/hide hidden files */ - if (local.x == panel->widget.cols - 5) + if (local.x == w->cols - 5) { midnight_dlg->callback (midnight_dlg, NULL, DLG_ACTION, CK_ShowHidden, NULL); - repaint_screen (); + /* both panels have been updated */ return MOU_NORMAL; } - /* ">" button */ - if (local.x == panel->widget.cols - 1) - { - directory_history_next (panel); - return MOU_NORMAL; - } - - /* "^" button */ - if (local.x >= panel->widget.cols - 4 && local.x <= panel->widget.cols - 2) - { - directory_history_list (panel); - return MOU_NORMAL; - } - - /* rest of the upper frame, the menu is invisible - call menu */ - if (!menubar_visible) - { - *redir = TRUE; - return the_menubar->widget.mouse (event, the_menubar); - } - /* no other events on 1st line */ - return MOU_NORMAL; + return MOU_UNHANDLED; } /* sort on clicked column; don't handle wheel events */ if (mouse_down && (local.buttons & (GPM_B_UP | GPM_B_DOWN)) == 0 && local.y == 2) { mouse_sort_col (panel, local.x); - return MOU_NORMAL; + goto finish; } /* Mouse wheel events */ @@ -3611,7 +3607,7 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) else /* We are in first page */ move_up (panel); } - return MOU_NORMAL; + goto finish; } if (mouse_down && (local.buttons & GPM_B_DOWN) != 0) @@ -3623,7 +3619,7 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) else /* We are in last page */ move_down (panel); } - return MOU_NORMAL; + goto finish; } local.y -= 2; @@ -3639,7 +3635,7 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) else { my_index = panel->top_file + local.y - 1; - if (panel->split && (local.x > ((panel->widget.cols - 2) / 2))) + if (panel->split && (local.x > (w->cols - 2) / 2)) my_index += llines (panel); if (my_index >= panel->count) @@ -3656,35 +3652,15 @@ do_panel_event (Gpm_Event * event, WPanel * panel, gboolean * redir) /* This one is new */ mark_if_marking (panel, &local); } - else if ((local.type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE)) - { - if (local.y > 0 && local.y <= lines) - do_enter (panel); - } + else if ((local.type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE) && + local.y > 0 && local.y <= lines) + do_enter (panel); + finish: + send_message (w, WIDGET_DRAW, 0); return MOU_NORMAL; } -/* --------------------------------------------------------------------------------------------- */ -/** Mouse callback of the panel */ - -static int -panel_event (Gpm_Event * event, void *data) -{ - WPanel *panel = (WPanel *) data; - int ret; - gboolean redir; - - if (!mouse_global_in_widget (event, (Widget *) data)) - return MOU_UNHANDLED; - - ret = do_panel_event (event, panel, &redir); - if (!redir) - send_message ((Widget *) panel, WIDGET_DRAW, 0); - - return ret; -} - /* --------------------------------------------------------------------------------------------- */ static void diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 55f4c65dc..52124591a 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -191,7 +191,7 @@ init_panelize (void) panelize_dlg = create_dlg (TRUE, 0, 0, 22, panelize_cols, dialog_colors, - panelize_callback, "[External panelize]", + panelize_callback, NULL, "[External panelize]", _("External panelize"), DLG_CENTER | DLG_REVERSE); for (i = 0; i < BUTTONS; i++) diff --git a/src/filemanager/tree.c b/src/filemanager/tree.c index 60a7e4a87..d8aff2e39 100644 --- a/src/filemanager/tree.c +++ b/src/filemanager/tree.c @@ -636,15 +636,15 @@ tree_event (Gpm_Event * event, void *data) Widget *w = (Widget *) data; Gpm_Event local; + /* rest of the upper frame - call menu */ + if (tree->is_panel && (event->type & GPM_DOWN) != 0 && event->y == w->owner->y + 1) + return MOU_UNHANDLED; + if (!mouse_global_in_widget (event, w)) return MOU_UNHANDLED; local = mouse_get_local (event, w); - /* rest of the upper frame, the menu is invisible - call menu */ - if (tree->is_panel && (local.type & GPM_DOWN) != 0 && local.y == 1 && !menubar_visible) - return the_menubar->widget.mouse (event, the_menubar); - if ((local.type & GPM_UP) == 0) return MOU_NORMAL; diff --git a/src/help.c b/src/help.c index febb70392..09835791c 100644 --- a/src/help.c +++ b/src/help.c @@ -1116,7 +1116,7 @@ help_interactive_display (const gchar * event_group_name, const gchar * event_na whelp = create_dlg (TRUE, 0, 0, help_lines + 4, HELP_WINDOW_WIDTH + 4, - help_colors, help_callback, "[Help]", _("Help"), + help_colors, help_callback, NULL, "[Help]", _("Help"), DLG_TRYUP | DLG_CENTER | DLG_WANT_TAB); selected_item = search_string_node (main_node, STRING_LINK_START) - 1; diff --git a/src/learn.c b/src/learn.c index 39a8f1f6c..6e29dcf00 100644 --- a/src/learn.c +++ b/src/learn.c @@ -300,7 +300,7 @@ init_learn (void) do_refresh (); learn_dlg = - create_dlg (TRUE, 0, 0, 23, 78, dialog_colors, learn_callback, + create_dlg (TRUE, 0, 0, 23, 78, dialog_colors, learn_callback, NULL, "[Learn keys]", learn_title, DLG_CENTER | DLG_REVERSE); for (i = 0; i < BUTTONS; i++) diff --git a/src/viewer/dialogs.c b/src/viewer/dialogs.c index 0d697c8b4..ed492616e 100644 --- a/src/viewer/dialogs.c +++ b/src/viewer/dialogs.c @@ -112,7 +112,7 @@ mcview_dialog_search (mcview_t * view) QuickDialog Quick_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"), "[Input Line Keys]", - quick_widgets, NULL, FALSE + quick_widgets, NULL, NULL, FALSE }; qd_result = quick_dialog (&Quick_input); @@ -201,7 +201,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset) QuickDialog Quick_input = { goto_dlg_width, goto_dlg_height, -1, -1, N_("Goto"), "[Input Line Keys]", - quick_widgets, NULL, FALSE + quick_widgets, NULL, NULL, FALSE }; #ifdef ENABLE_NLS diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c index 0601f8c53..b2de90937 100644 --- a/src/viewer/mcviewer.c +++ b/src/viewer/mcviewer.c @@ -93,18 +93,18 @@ do_mcview_event (mcview_t * view, Gpm_Event * event, int *result) { screen_dimen y, x; Gpm_Event local; + Widget *w = (Widget *) view; + + /* rest of the upper frame - call menu */ + if (mcview_is_in_panel (view) && (event->type & GPM_DOWN) != 0 && event->y == w->owner->y + 1) + { + *result = MOU_UNHANDLED; + return FALSE; /* don't draw viewer over menu */ + } *result = MOU_NORMAL; - local = mouse_get_local (event, (Widget *) view); - - /* rest of the upper frame, the menu is invisible - call menu */ - if (mcview_is_in_panel (view) && (local.type & GPM_DOWN) != 0 && local.y == 1 - && !menubar_visible) - { - *result = the_menubar->widget.mouse (event, the_menubar); - return FALSE; /* don't draw viewer over menu */ - } + local = mouse_get_local (event, w); /* We are not interested in the release events */ if ((local.type & (GPM_DOWN | GPM_DRAG)) == 0) @@ -114,13 +114,11 @@ do_mcview_event (mcview_t * view, Gpm_Event * event, int *result) if ((local.buttons & GPM_B_UP) != 0 && (local.type & GPM_DOWN) != 0) { mcview_move_up (view, 2); - *result = MOU_NORMAL; return TRUE; } if ((local.buttons & GPM_B_DOWN) != 0 && (local.type & GPM_DOWN) != 0) { mcview_move_down (view, 2); - *result = MOU_NORMAL; return TRUE; } @@ -135,7 +133,8 @@ do_mcview_event (mcview_t * view, Gpm_Event * event, int *result) mcview_move_left (view, 1); goto processed; } - else if (x < view->data_area.width * 3 / 4) + + if (x < view->data_area.width * 3 / 4) { /* ignore the click */ } @@ -240,7 +239,7 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin mcview_ret_t ret; /* Create dialog and widgets, put them on the dialog */ - view_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback, + view_dlg = create_dlg (FALSE, 0, 0, LINES, COLS, NULL, mcview_dialog_callback, NULL, "[Internal File Viewer]", NULL, DLG_WANT_TAB); lc_mcview = mcview_new (0, 0, LINES - 1, COLS, FALSE);