summaryrefslogtreecommitdiff
path: root/tests/testmenubutton.c
diff options
context:
space:
mode:
authorDaniel Boles <dboles@src.gnome.org>2017-10-08 13:15:33 +0100
committerDaniel Boles <dboles.src@gmail.com>2017-10-08 13:17:04 +0100
commit6cafb62e9b76d0c7c6ff9e0acf03a5f7bc39fac0 (patch)
tree97203746bb1df2568a612ed6e0a1db9566a46d6c /tests/testmenubutton.c
parent007e4639a8404fba6e71b3e7120de7a34253c2ae (diff)
downloadgtk+-6cafb62e9b76d0c7c6ff9e0acf03a5f7bc39fac0.tar.gz
testmenubutton: Fix inverted keynav in the GtkMenu
GtkMenu’s own keynav code, which actually bothers to account for the layout of items, only happens if columns > 1. So, adding items to 1 column using a reverse loop meant they were placed in the Menu’s list of children in that order, and because we only have 1 column, Menu passes keynav up to MenuShell, which doesn’t adjust for the items’ positions. ‘Fix’ that here by adding items in the same order they’ll have when laid out in the Menu, so keynav does what you’d expect, not the opposite. For that, it’s simpler just to use gtk_container_add(). Let’s presume users are using add(), attach() with a non-inverted loop, or attach() with arguments that create 2+ columns and so GtkMenu keynav.
Diffstat (limited to 'tests/testmenubutton.c')
-rw-r--r--tests/testmenubutton.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c
index 8de76a4702..62b9ea2226 100644
--- a/tests/testmenubutton.c
+++ b/tests/testmenubutton.c
@@ -104,23 +104,21 @@ int main (int argc, char **argv)
/* Button with GtkMenu */
menu_widget = gtk_menu_new ();
- for (i = 5; i > 0; i--) {
+ for (i = 0; i < 5; ++i) {
GtkWidget *item;
- if (i == 3) {
+ if (i == 2) {
item = gtk_menu_item_new_with_mnemonic ("_Copy");
} else {
char *label;
- label = g_strdup_printf ("Item _%d", i);
+ label = g_strdup_printf ("Item _%d", i + 1);
item = gtk_menu_item_new_with_mnemonic (label);
g_free (label);
}
+
gtk_menu_item_set_use_underline (GTK_MENU_ITEM (item), TRUE);
- gtk_menu_attach (GTK_MENU (menu_widget),
- item,
- 0, 1,
- i - 1, i);
+ gtk_container_add (GTK_CONTAINER (menu_widget), item);
}
gtk_widget_show (menu_widget);