Commit 634ebb59 authored by Bastien Nocera's avatar Bastien Nocera

tests: Add accelerator example to testmenubutton

https://bugzilla.gnome.org/show_bug.cgi?id=680962
parent 97912acb
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment