mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Refactoring of editor initialization.
Since button bar is a part of editor dialog, its initialization was moved from WIDGET_INIT stage to DLG_INIT one. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
71bb255b2c
commit
06311a3e40
@ -187,6 +187,23 @@ edit_command_execute (WEdit *edit, unsigned long command)
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
static void
|
||||
edit_set_buttonbar (WEdit *edit)
|
||||
{
|
||||
WButtonBar *bb = find_buttonbar (edit->widget.parent);
|
||||
|
||||
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 4, Q_("ButtonBar|Replac"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 5, Q_("ButtonBar|Copy"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 6, Q_("ButtonBar|Move"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 7, Q_("ButtonBar|Search"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 8, Q_("ButtonBar|Delete"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 9, Q_("ButtonBar|PullDn"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 10, Q_("ButtonBar|Quit"), editor_map, (Widget *) edit);
|
||||
}
|
||||
|
||||
/* Callback for the edit dialog */
|
||||
static cb_ret_t
|
||||
edit_dialog_callback (Dlg_head *h, Widget *sender,
|
||||
@ -199,6 +216,10 @@ edit_dialog_callback (Dlg_head *h, Widget *sender,
|
||||
edit = (WEdit *) find_widget_type (h, edit_callback);
|
||||
|
||||
switch (msg) {
|
||||
case DLG_INIT:
|
||||
edit_set_buttonbar (edit);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case DLG_RESIZE:
|
||||
edit_adjust_size (h);
|
||||
return MSG_HANDLED;
|
||||
@ -270,23 +291,6 @@ edit_get_file_name (const WEdit *edit)
|
||||
return edit->filename;
|
||||
}
|
||||
|
||||
static void
|
||||
edit_set_buttonbar (WEdit *edit)
|
||||
{
|
||||
WButtonBar *bb = find_buttonbar (edit->widget.parent);
|
||||
|
||||
buttonbar_set_label (bb, 1, Q_("ButtonBar|Help"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 2, Q_("ButtonBar|Save"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 3, Q_("ButtonBar|Mark"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 4, Q_("ButtonBar|Replac"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 5, Q_("ButtonBar|Copy"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 6, Q_("ButtonBar|Move"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 7, Q_("ButtonBar|Search"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 8, Q_("ButtonBar|Delete"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 9, Q_("ButtonBar|PullDn"), editor_map, (Widget *) edit);
|
||||
buttonbar_set_label (bb, 10, Q_("ButtonBar|Quit"), editor_map, (Widget *) edit);
|
||||
}
|
||||
|
||||
void
|
||||
edit_update_screen (WEdit * e)
|
||||
{
|
||||
@ -311,11 +315,6 @@ edit_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
WEdit *e = (WEdit *) w;
|
||||
|
||||
switch (msg) {
|
||||
case WIDGET_INIT:
|
||||
e->force |= REDRAW_COMPLETELY;
|
||||
edit_set_buttonbar (e);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DRAW:
|
||||
e->force |= REDRAW_COMPLETELY;
|
||||
e->num_widget_lines = LINES - 2;
|
||||
@ -329,22 +328,22 @@ edit_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
case WIDGET_KEY:
|
||||
{
|
||||
int cmd, ch;
|
||||
cb_ret_t ret = MSG_NOT_HANDLED;
|
||||
|
||||
/* The user may override the access-keys for the menu bar. */
|
||||
if (edit_translate_key (e, parm, &cmd, &ch)) {
|
||||
edit_execute_key_command (e, cmd, ch);
|
||||
edit_update_screen (e);
|
||||
return MSG_HANDLED;
|
||||
} else if (edit_drop_hotkey_menu (e, parm)) {
|
||||
return MSG_HANDLED;
|
||||
} else {
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
ret = MSG_HANDLED;
|
||||
} else if (edit_drop_hotkey_menu (e, parm))
|
||||
ret = MSG_HANDLED;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
case WIDGET_COMMAND:
|
||||
/* command from menubar or buttonbar */
|
||||
return edit_command_execute (wedit, parm);
|
||||
return edit_command_execute (e, parm);
|
||||
|
||||
case WIDGET_CURSOR:
|
||||
widget_move (&e->widget, e->curs_row + EDIT_TEXT_VERTICAL_OFFSET,
|
||||
|
Loading…
Reference in New Issue
Block a user