From 634ebb593c1a61638d2ad4187ce82dd6c746a57a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 12 Sep 2012 18:12:41 +0100 Subject: [PATCH] tests: Add accelerator example to testmenubutton https://bugzilla.gnome.org/show_bug.cgi?id=680962 --- tests/testmenubutton.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c index e4775ba580..08ce2c9276 100644 --- a/tests/testmenubutton.c +++ b/tests/testmenubutton.c @@ -8,6 +8,7 @@ int main (int argc, char **argv) GtkWidget *grid; GtkWidget *entry; GtkWidget *menu_widget; + GtkAccelGroup *accel_group; guint i; GMenu *menu; @@ -19,6 +20,9 @@ int main (int argc, char **argv) grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), grid); + accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); + /* Button next to entry */ entry = gtk_entry_new (); gtk_grid_attach (GTK_GRID (grid), @@ -35,11 +39,17 @@ int main (int argc, char **argv) menu_widget = gtk_menu_new (); for (i = 5; i > 0; i--) { GtkWidget *item; - char *label; - label = g_strdup_printf ("Item _%d", i); - item = gtk_menu_item_new_with_mnemonic (label); - g_free (label); + if (i == 3) { + item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, accel_group); + } else { + char *label; + + label = g_strdup_printf ("Item _%d", i); + 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,