summaryrefslogtreecommitdiff
path: root/gtk/gtkmenubar.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-03-17 10:43:09 +0100
committerTimm Bäder <mail@baedert.org>2018-03-17 12:09:30 +0100
commit1a8e7d97ae94c5700c6c2551632a2e09f6f9d506 (patch)
treee1110326a201696a4601d1c2c062e15ccdd755b2 /gtk/gtkmenubar.c
parent1eb22e79272e923f8fd5ac983ea6645344d56f13 (diff)
downloadgtk+-1a8e7d97ae94c5700c6c2551632a2e09f6f9d506.tar.gz
menubar: Use GtkWidget focusing facilities
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r--gtk/gtkmenubar.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 6caf04d9ad..170c2722dc 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -570,26 +570,30 @@ _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
if (gtk_widget_is_toplevel (toplevel))
{
GList *tmp_menubars = _gtk_menu_bar_get_viewable_menu_bars (GTK_WINDOW (toplevel));
- GList *menubars;
- GList *current;
+ GList *l;
+ GPtrArray *menubars;
+ gboolean found;
+ guint index;
- menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
- dir, GTK_WIDGET (menubar));
- g_list_free (tmp_menubars);
+ menubars = g_ptr_array_sized_new (g_list_length (tmp_menubars));
- if (menubars)
- {
- current = g_list_find (menubars, menubar);
+ for (l = tmp_menubars; l; l = l->next)
+ g_ptr_array_add (menubars, l->data);
- if (current && current->next)
- {
- GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
- if (new_menushell->priv->children)
- to_activate = new_menushell->priv->children->data;
- }
- }
-
- g_list_free (menubars);
+ gtk_widget_focus_sort (toplevel, dir, menubars);
+
+ found = g_ptr_array_find (menubars, menubar, &index);
+
+ if (found && index < menubars->len)
+ {
+ GtkWidget *next = g_ptr_array_index (menubars, index + 1);
+ GtkMenuShell *new_menushell = GTK_MENU_SHELL (next);
+
+ if (new_menushell->priv->children)
+ to_activate = new_menushell->priv->children->data;
+ }
+
+ g_ptr_array_free (menubars, TRUE);
}
gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));