static cb_ret_t help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: { WButtonBar *bb; help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18)); dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4); bb = find_buttonbar (h); widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS); return MSG_HANDLED; } case MSG_DRAW: dlg_default_repaint (h); help_show (h, currentpoint); return MSG_HANDLED; case MSG_KEY: return help_handle_key (h, parm); case MSG_ACTION: /* Handle shortcuts and buttonbar. */ return help_execute_cmd (parm); default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: { Widget *bar; /* simply call dlg_set_size() with new size */ dlg_set_size (h, LINES - 9, COLS - 20); bar = WIDGET (find_buttonbar (h)); bar->x = 0; bar->y = LINES - 1; return MSG_HANDLED; } case MSG_ACTION: return send_message (find_tree (h), NULL, MSG_ACTION, parm, NULL); default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_NOTIFY: if (sender != NULL && sender->id == panel_listing_types_id) { WCheck *ch; WInput *in1, *in2, *in3; in1 = INPUT (dlg_find_by_id (h, panel_user_format_id)); in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id)); ch = CHECK (dlg_find_by_id (h, mini_user_status_id)); in3 = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (!(ch->state & C_BOOL)) input_assign_text (in3, status_format[RADIO (sender)->sel]); input_update (in1, FALSE); input_update (in2, FALSE); input_update (in3, FALSE); widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx); widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx); return MSG_HANDLED; } if (sender != NULL && sender->id == mini_user_status_id) { WInput *in; in = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (CHECK (sender)->state & C_BOOL) { widget_disable (WIDGET (in), FALSE); input_assign_text (in, status_format[3]); } else { WRadio *r; r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); widget_disable (WIDGET (in), TRUE); input_assign_text (in, status_format[r->sel]); } /* input_update (in, FALSE); */ return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t learn_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_KEY: return learn_check_key (parm) ? MSG_HANDLED : MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_DRAW: chown_refresh (DIALOG (w)); return MSG_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t panelize_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_INIT: case MSG_NOTIFY: /* MSG_NOTIFY is fired by the listbox to tell us the item has changed. */ update_command (); return MSG_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: if ((h->flags & DLG_CENTER) == 0) { WDialog *prev_dlg = NULL; int ypos, xpos; /* get dialog under h */ if (top_dlg != NULL) { if (top_dlg->data != (void *) h) prev_dlg = DIALOG (top_dlg->data); else { GList *p; /* Top dialog is current if it is visible. Get previous dialog in stack */ p = g_list_next (top_dlg); if (p != NULL) prev_dlg = DIALOG (p->data); } } /* if previous dialog is not fullscreen'd -- overlap it */ if (prev_dlg == NULL || prev_dlg->fullscreen) ypos = LINES / 3 - (w->lines - 3) / 2; else ypos = WIDGET (prev_dlg)->y + 2; xpos = COLS / 2 - w->cols / 2; /* set position */ dlg_set_position (h, ypos, xpos, ypos + w->lines, xpos + w->cols); return MSG_HANDLED; } /* fallthrough */ default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t panelize_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_INIT: case MSG_POST_KEY: case MSG_FOCUS: tty_setcolor (MENU_ENTRY_COLOR); update_command (); return MSG_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t editcmd_dialog_raw_key_query_cb (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_KEY: h->ret_value = parm; dlg_stop (h); return MSG_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: { WButtonBar *bb; help_lines = min (LINES - 4, max (2 * LINES / 3, 18)); dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4); bb = find_buttonbar (h); widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS); return MSG_HANDLED; } case MSG_DRAW: dlg_default_repaint (h); help_show (h, currentpoint); return MSG_HANDLED; case MSG_KEY: return help_handle_key (h, parm); case MSG_ACTION: /* shortcut */ if (sender == NULL) return help_execute_cmd (parm); /* message from buttonbar */ if (sender == WIDGET (find_buttonbar (h))) { if (data != NULL) return send_message (data, NULL, MSG_ACTION, parm, NULL); return help_execute_cmd (parm); } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t panelize_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_INIT: update_command (); return MSG_HANDLED; case MSG_ACTION: if (sender == NULL) return MSG_NOT_HANDLED; /* The listbox tells us the item has changed. */ update_command (); return MSG_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t chl_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_KEY: switch (parm) { case KEY_LEFT: case KEY_RIGHT: { WDialog *h = DIALOG (w); h->ret_value = parm; dlg_stop (h); } } default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t confvfs_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_ACTION: /* message from "Always use ftp proxy" checkbutton */ if (sender != NULL && sender->id == ftpfs_always_use_proxy_id) { const gboolean not_use = !(CHECK (sender)->state & C_BOOL); Widget *wi; /* input */ wi = dlg_find_by_id (DIALOG (w), ftpfs_proxy_host_id); widget_disable (wi, not_use); return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { switch (msg) { case MSG_ACTION: /* message from "Single press" checkbutton */ if (sender != NULL && sender->id == configure_old_esc_mode_id) { const gboolean not_single = !(CHECK (sender)->state & C_BOOL); Widget *ww; /* input line */ ww = dlg_find_by_id (DIALOG (w), configure_time_out_id); widget_disable (ww, not_single); return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t edit_dialog_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WMenuBar *menubar; WButtonBar *buttonbar; WDialog *h = DIALOG (w); switch (msg) { case MSG_INIT: edit_dlg_init (); return MSG_HANDLED; case MSG_DRAW: /* don't use dlg_default_repaint() -- we don't need a frame */ tty_setcolor (EDITOR_BACKGROUND); dlg_erase (h); return MSG_HANDLED; case MSG_RESIZE: menubar = find_menubar (h); buttonbar = find_buttonbar (h); /* dlg_set_size() is surplus for this case */ w->lines = LINES; w->cols = COLS; widget_set_size (WIDGET (buttonbar), w->lines - 1, w->x, 1, w->cols); widget_set_size (WIDGET (menubar), w->y, w->x, 1, w->cols); menubar_arrange (menubar); g_list_foreach (h->widgets, (GFunc) edit_dialog_resize_cb, NULL); return MSG_HANDLED; case MSG_ACTION: { /* Handle shortcuts, menu, and buttonbar. */ cb_ret_t result; result = edit_dialog_command_execute (h, parm); /* We forward any commands coming from the menu, and which haven't been handled by the dialog, to the focused WEdit window. */ if (result == MSG_NOT_HANDLED && sender == WIDGET (find_menubar (h))) result = send_message (h->current->data, NULL, MSG_ACTION, parm, NULL); return result; } case MSG_KEY: { Widget *we = WIDGET (h->current->data); cb_ret_t ret = MSG_NOT_HANDLED; if (edit_widget_is_editor (we)) { WEdit *e = (WEdit *) we; long command; if (!e->extmod) command = keybind_lookup_keymap_command (editor_map, parm); else command = keybind_lookup_keymap_command (editor_x_map, parm); if (command == CK_IgnoreKey) e->extmod = FALSE; else { ret = edit_dialog_command_execute (h, command); /* if command was not handled, keep the extended mode for the further key processing */ if (ret == MSG_HANDLED) e->extmod = FALSE; } } /* * Due to the "end of bracket" escape the editor sees input with is_idle() == false * (expects more characters) and hence doesn't yet refresh the screen, but then * no further characters arrive (there's only an "end of bracket" which is swallowed * by tty_get_event()), so you end up with a screen that's not refreshed after pasting. * So let's trigger an IDLE signal. */ if (!is_idle ()) widget_idle (w, TRUE); return ret; } /* hardcoded menu hotkeys (see edit_drop_hotkey_menu) */ case MSG_UNHANDLED_KEY: return edit_drop_hotkey_menu (h, parm) ? MSG_HANDLED : MSG_NOT_HANDLED; case MSG_VALIDATE: edit_quit (h); return MSG_HANDLED; case MSG_END: edit_dlg_deinit (); return MSG_HANDLED; case MSG_IDLE: widget_idle (w, FALSE); return send_message (h->current->data, NULL, MSG_IDLE, 0, NULL); default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_DRAW: /* When repainting the whole dialog (e.g. with C-l) we have to update everything */ dlg_default_repaint (h); old_output_lines = -1; update_split (h); if (old_output_lines != _output_lines) { old_output_lines = _output_lines; tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR); widget_move (h, 9, 5); tty_print_string (output_lines_label); widget_move (h, 9, 5 + 3 + output_lines_label_len); tty_printf ("%02d", _output_lines); } return MSG_HANDLED; case MSG_POST_KEY: _menubar_visible = check_options[1].widget->state & C_BOOL; _command_prompt = (check_options[2].widget->state & C_BOOL) != 0; _keybar_visible = check_options[3].widget->state & C_BOOL; _message_visible = check_options[4].widget->state & C_BOOL; _xterm_title = (check_options[5].widget->state & C_BOOL) != 0; _free_space = check_options[6].widget->state & C_BOOL; if (mc_global.tty.console_flag != '\0') { int minimum; if (_output_lines < 0) _output_lines = 0; height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) - _menubar_visible - _output_lines - _message_visible; minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); if (height < minimum) { _output_lines -= minimum - height; height = minimum; } } else height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) - _menubar_visible - _output_lines - _message_visible; if (old_output_lines != _output_lines) { old_output_lines = _output_lines; tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR); widget_move (h, 9, 5 + 3 + output_lines_label_len); tty_printf ("%02d", _output_lines); } return MSG_HANDLED; case MSG_ACTION: if (sender == WIDGET (radio_widget)) { if (panels_layout.horizontal_split != radio_widget->sel) { int eq; panels_layout.horizontal_split = radio_widget->sel; if (panels_layout.horizontal_split) { eq = panels_layout.horizontal_equal; if (eq) panels_layout.top_panel_size = height / 2; } else { eq = panels_layout.vertical_equal; if (eq) panels_layout.left_panel_size = COLS / 2; } widget_disable (WIDGET (bleft_widget), eq); widget_disable (WIDGET (bright_widget), eq); update_split (h); layout_change (); do_refresh (); } else update_split (h); return MSG_HANDLED; } if (sender == WIDGET (check_options[0].widget)) { int eq; if (panels_layout.horizontal_split) { panels_layout.horizontal_equal = check_options[0].widget->state & C_BOOL; eq = panels_layout.horizontal_equal; } else { panels_layout.vertical_equal = check_options[0].widget->state & C_BOOL; eq = panels_layout.vertical_equal; } widget_disable (WIDGET (bleft_widget), eq); widget_disable (WIDGET (bright_widget), eq); update_split (h); layout_change (); do_refresh (); return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); int i; int f_pos; unsigned long id; id = dlg_get_current_widget_id (h); for (i = 0; i < BUTTONS_PERM; i++) if (chown_advanced_but[i].id == id) break; f_pos = i; i = 0; switch (msg) { case MSG_DRAW: chown_refresh (); chown_info_update (); return MSG_HANDLED; case MSG_POST_KEY: if (f_pos < 3) b_setpos (f_pos); return MSG_HANDLED; case MSG_FOCUS: if (f_pos < 3) { if ((flag_pos / 3) != f_pos) flag_pos = f_pos * 3; b_setpos (f_pos); } else if (f_pos < BUTTONS_PERM) flag_pos = f_pos + 6; return MSG_HANDLED; case MSG_KEY: switch (parm) { case XCTRL ('b'): case KEY_LEFT: if (f_pos < BUTTONS_PERM) return (dec_flag_pos (f_pos)); break; case XCTRL ('f'): case KEY_RIGHT: if (f_pos < BUTTONS_PERM) return (inc_flag_pos (f_pos)); break; case ' ': if (f_pos < 3) return MSG_HANDLED; break; case '\n': case KEY_ENTER: if (f_pos <= 2 || f_pos >= BUTTONS_PERM) break; do_enter_key (h, f_pos); return MSG_HANDLED; case ALT ('x'): i++; case ALT ('w'): i++; case ALT ('r'): parm = i + 3; for (i = 0; i < 3; i++) ch_flags[i * 3 + parm - 3] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, MSG_DRAW); send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL); break; case XCTRL ('x'): i++; case XCTRL ('w'): i++; case XCTRL ('r'): parm = i; for (i = 0; i < 3; i++) ch_flags[i * 3 + parm] = (x_toggle & (1 << parm)) ? '-' : '+'; x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, MSG_DRAW); send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL); break; case 'x': i++; case 'w': i++; case 'r': if (f_pos > 2) break; flag_pos = f_pos * 3 + i; /* (strchr(ch_perm,parm)-ch_perm); */ if (BUTTON (h->current->data)->text.start[(flag_pos % 3)] == '-') ch_flags[flag_pos] = '+'; else ch_flags[flag_pos] = '-'; update_mode (h); break; case '4': i++; case '2': i++; case '1': if (f_pos <= 2) { flag_pos = i + f_pos * 3; ch_flags[flag_pos] = '='; update_mode (h); } break; case '-': if (f_pos > 2) break; case '*': if (parm == '*') parm = '='; case '=': case '+': if (f_pos <= 4) { ch_flags[flag_pos] = parm; update_mode (h); send_message (h, sender, MSG_KEY, KEY_RIGHT, NULL); if (flag_pos > 8 || (flag_pos % 3) == 0) dlg_one_down (h); } break; default: break; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_KEY: if (parm == '\n') { Widget *wi; wi = dlg_find_by_id (h, panel_listing_types_id); if (widget_is_active (wi)) { WInput *in; in = INPUT (dlg_find_by_id (h, mini_user_format_id)); input_assign_text (in, status_format[RADIO (wi)->sel]); dlg_stop (h); return MSG_HANDLED; } wi = dlg_find_by_id (h, panel_user_format_id); if (widget_is_active (wi)) { h->ret_value = B_USER + 6; dlg_stop (h); return MSG_HANDLED; } wi = dlg_find_by_id (h, mini_user_format_id); if (widget_is_active (wi)) { h->ret_value = B_USER + 7; dlg_stop (h); return MSG_HANDLED; } } if (g_ascii_tolower (parm) == listing_user_hotkey) { Widget *wi; wi = dlg_find_by_id (h, panel_user_format_id); if (widget_is_active (wi)) { wi = dlg_find_by_id (h, mini_user_format_id); if (widget_is_active (wi)) { WRadio *r; r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); r->pos = r->sel = panel_listing_user_idx; dlg_select_widget (WIDGET (r)); /* force redraw */ send_message (h, r, MSG_ACTION, 0, NULL); return MSG_HANDLED; } } } return MSG_NOT_HANDLED; case MSG_ACTION: if (sender != NULL && sender->id == panel_listing_types_id) { WCheck *ch; WInput *in1, *in2, *in3; in1 = INPUT (dlg_find_by_id (h, panel_user_format_id)); in2 = INPUT (dlg_find_by_id (h, panel_brief_cols_id)); ch = CHECK (dlg_find_by_id (h, mini_user_status_id)); in3 = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (!(ch->state & C_BOOL)) input_assign_text (in3, status_format[RADIO (sender)->sel]); input_update (in1, FALSE); input_update (in2, FALSE); input_update (in3, FALSE); widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx); widget_disable (WIDGET (in2), RADIO (sender)->sel != panel_listing_brief_idx); return MSG_HANDLED; } if (sender != NULL && sender->id == mini_user_status_id) { WInput *in; in = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (CHECK (sender)->state & C_BOOL) { widget_disable (WIDGET (in), FALSE); input_assign_text (in, status_format[3]); } else { WRadio *r; r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); widget_disable (WIDGET (in), TRUE); input_assign_text (in, status_format[r->sel]); } /* input_update (in, FALSE); */ return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }