mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
* menu.h (WMenu): Save pointer to the previous widget, not its
number. Adjust all dependencies. * menu.c (menubar_finish): Restore focus on the saved widget. * dlg.c (dlg_item_number): Remove, it's unused now. (dlg_select_nth_widget): Likewise.
This commit is contained in:
parent
5373948a01
commit
824a5256c1
@ -448,12 +448,9 @@ edit_drop_menu_cmd (WEdit * e, int which)
|
||||
edit_menubar->dropped = drop_menus;
|
||||
if (which >= 0) {
|
||||
edit_menubar->selected = which;
|
||||
edit_menubar->previous_selection = which;
|
||||
} else {
|
||||
edit_menubar->previous_selection =
|
||||
dlg_item_number (e->widget.parent);
|
||||
}
|
||||
|
||||
edit_menubar->previous_widget = e->widget.parent->current->widget;
|
||||
dlg_select_widget (e->widget.parent, edit_menubar);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
2003-09-12 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* menu.h (WMenu): Save pointer to the previous widget, not its
|
||||
number. Adjust all dependencies.
|
||||
* menu.c (menubar_finish): Restore focus on the saved widget.
|
||||
* dlg.c (dlg_item_number): Remove, it's unused now.
|
||||
(dlg_select_nth_widget): Likewise.
|
||||
|
||||
* help.c (interactive_display): User straight widget order.
|
||||
|
||||
* complete.c (complete_engine): Don't need DLG_REVERSE.
|
||||
|
31
src/dlg.c
31
src/dlg.c
@ -837,34 +837,3 @@ void dlg_replace_widget (Dlg_head *h, Widget *old, Widget *new)
|
||||
p = p->next;
|
||||
} while (p != h->current);
|
||||
}
|
||||
|
||||
/* Returns the index of h->current from h->first */
|
||||
int dlg_item_number (Dlg_head *h)
|
||||
{
|
||||
Widget_Item *p;
|
||||
int i = 0;
|
||||
|
||||
p = h->first;
|
||||
|
||||
do {
|
||||
if (p == h->current)
|
||||
return i;
|
||||
i++;
|
||||
p = p->next;
|
||||
} while (p != h->first);
|
||||
fprintf (stderr, "Internal error: current not in dialog list\n\r");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int dlg_select_nth_widget (Dlg_head *h, int n)
|
||||
{
|
||||
Widget_Item *w;
|
||||
int i;
|
||||
|
||||
w = h->first;
|
||||
for (i = 0; i < n; i++)
|
||||
w = w->next;
|
||||
|
||||
return dlg_select_widget (h, w->widget);
|
||||
}
|
||||
|
||||
|
@ -199,8 +199,6 @@ int dlg_select_widget (Dlg_head *h, void *widget);
|
||||
void dlg_one_up (Dlg_head *h);
|
||||
void dlg_one_down (Dlg_head *h);
|
||||
int dlg_focus (Dlg_head *h);
|
||||
int dlg_select_nth_widget (Dlg_head *h, int n);
|
||||
int dlg_item_number (Dlg_head *h);
|
||||
Widget *find_widget_type (Dlg_head *h, void *callback);
|
||||
|
||||
/* Sets/clear the specified flag in the options field */
|
||||
|
@ -980,7 +980,7 @@ menu_last_selected_cmd (void)
|
||||
{
|
||||
the_menubar->active = 1;
|
||||
the_menubar->dropped = drop_menus;
|
||||
the_menubar->previous_selection = dlg_item_number (midnight_dlg);
|
||||
the_menubar->previous_widget = midnight_dlg->current->widget;
|
||||
dlg_select_widget (midnight_dlg, the_menubar);
|
||||
}
|
||||
|
||||
|
@ -206,14 +206,14 @@ static void menubar_right (WMenu *menu)
|
||||
menubar_draw (menu);
|
||||
}
|
||||
|
||||
static void menubar_finish (WMenu *menubar)
|
||||
static void
|
||||
menubar_finish (WMenu *menubar)
|
||||
{
|
||||
menubar->dropped = 0;
|
||||
menubar->active = 0;
|
||||
menubar->widget.lines = 1;
|
||||
widget_want_hotkey (menubar->widget, 0);
|
||||
dlg_select_nth_widget (menubar->widget.parent,
|
||||
menubar->previous_selection);
|
||||
dlg_select_widget (menubar->widget.parent, menubar->previous_widget);
|
||||
do_refresh ();
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ menubar_event (Gpm_Event *event, WMenu *menubar)
|
||||
return MOU_NORMAL;
|
||||
|
||||
if (!menubar->dropped){
|
||||
menubar->previous_selection = dlg_item_number(menubar->widget.parent);
|
||||
menubar->previous_widget = menubar->widget.parent->current->widget;
|
||||
menubar->active = 1;
|
||||
menubar->dropped = 1;
|
||||
was_active = 0;
|
||||
|
@ -37,7 +37,7 @@ typedef struct WMenu {
|
||||
int selected; /* Selected menu on the top bar */
|
||||
int subsel; /* Selected entry on the submenu */
|
||||
int max_entry_len; /* Cache value for the columns in a box */
|
||||
int previous_selection; /* Selected widget before activating menu */
|
||||
Widget *previous_widget; /* Selected widget before activating menu */
|
||||
} WMenu;
|
||||
|
||||
Menu *create_menu (char *name, menu_entry *entries, int count,
|
||||
|
Loading…
Reference in New Issue
Block a user