From d391813325fc4fae81f4f75b45ee7847ceb119fd Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 28 Apr 2010 16:54:20 +0400 Subject: [PATCH] Optimization: rid of edit_menubar global variable. Signed-off-by: Andrew Borodin --- src/editor/edit-impl.h | 2 -- src/editor/editmenu.c | 18 +++++++++++------- src/editor/editwidget.c | 18 +++++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index bfcdea6a1..4088892b0 100644 --- a/src/editor/edit-impl.h +++ b/src/editor/edit-impl.h @@ -316,8 +316,6 @@ extern edit_search_options_t edit_search_options; extern int edit_stack_iterator; extern edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO]; -extern struct WMenuBar *edit_menubar; - extern const global_keymap_t *editor_map; extern const global_keymap_t *editor_x_map; diff --git a/src/editor/editmenu.c b/src/editor/editmenu.c index 518061276..31d60858e 100644 --- a/src/editor/editmenu.c +++ b/src/editor/editmenu.c @@ -198,14 +198,18 @@ edit_init_menu (struct WMenuBar *menubar) static void edit_drop_menu_cmd (WEdit *e, int which) { - if (!edit_menubar->is_active) { - edit_menubar->is_active = TRUE; - edit_menubar->is_dropped = (drop_menus != 0); - if (which >= 0) - edit_menubar->selected = which; + WMenuBar *menubar; - edit_menubar->previous_widget = e->widget.parent->current->dlg_id; - dlg_select_widget (edit_menubar); + menubar = find_menubar (e->widget.parent); + + if (!menubar->is_active) { + menubar->is_active = TRUE; + menubar->is_dropped = (drop_menus != 0); + if (which >= 0) + menubar->selected = which; + + menubar->previous_widget = e->widget.parent->current->dlg_id; + dlg_select_widget (menubar); } } diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index 725957d3b..82d7d5bed 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -52,8 +52,6 @@ #include "src/menu.h" /* menubar_new() */ #include "src/cmddef.h" -struct WMenuBar *edit_menubar; - int column_highlighting = 0; static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm); @@ -87,8 +85,13 @@ edit_event (Gpm_Event *event, void *data) return MOU_NORMAL; /* rest of the upper frame, the menu is invisible - call menu */ - if ((event->type & GPM_DOWN) && (event->y == 1)) - return edit_menubar->widget.mouse (event, edit_menubar); + if ((event->type & GPM_DOWN) && (event->y == 1)) { + WMenuBar *menubar; + + menubar = find_menubar (edit->widget.parent); + + return menubar->widget.mouse (event, menubar); + } edit_update_curs_row (edit); edit_update_curs_col (edit); @@ -231,6 +234,7 @@ edit_file (const char *_file, int line) static gboolean made_directory = FALSE; Dlg_head *edit_dlg; WEdit *wedit; + WMenuBar *menubar; if (!made_directory) { char *dir = concat_dir_and_file (home_dir, EDIT_DIR); @@ -249,9 +253,9 @@ edit_file (const char *_file, int line) "[Internal File Editor]", NULL, DLG_WANT_TAB); edit_dlg->get_shortcut = edit_get_shortcut; - edit_menubar = menubar_new (0, 0, COLS, NULL); - add_widget (edit_dlg, edit_menubar); - edit_init_menu (edit_menubar); + menubar = menubar_new (0, 0, COLS, NULL); + add_widget (edit_dlg, menubar); + edit_init_menu (menubar); init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS, edit_callback, edit_event);