[gtk+/composite-templates] tests: Add accelerator example to testmenubutton
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/composite-templates] tests: Add accelerator example to testmenubutton
- Date: Fri, 14 Sep 2012 21:30:31 +0000 (UTC)
commit 4947217bba5f18e1519c451c6d441e7ace2f0ac3
Author: Bastien Nocera <hadess hadess net>
Date: Wed Sep 12 18:12:41 2012 +0100
tests: Add accelerator example to testmenubutton
https://bugzilla.gnome.org/show_bug.cgi?id=680962
tests/testmenubutton.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/tests/testmenubutton.c b/tests/testmenubutton.c
index e4775ba..08ce2c9 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]