[gtk+/gtk-3-16] Added an additional explanation and code snippet for GtkImageMenuItem.c
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-16] Added an additional explanation and code snippet for GtkImageMenuItem.c
- Date: Tue, 21 Jul 2015 14:20:18 +0000 (UTC)
commit b9e0a54a420375a8132487db1a6ce320ff67c8de
Author: Eric Williams <ericwill redhat com>
Date: Tue Jul 7 14:54:32 2015 -0400
Added an additional explanation and code snippet for GtkImageMenuItem.c
https://bugzilla.gnome.org/show_bug.cgi?id=752093
gtk/deprecated/gtkimagemenuitem.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gtk/deprecated/gtkimagemenuitem.c b/gtk/deprecated/gtkimagemenuitem.c
index f52eb3c..fe40516 100644
--- a/gtk/deprecated/gtkimagemenuitem.c
+++ b/gtk/deprecated/gtkimagemenuitem.c
@@ -79,6 +79,35 @@
* consider using icons in menu items only sparingly, and for "objects" (or
* "nouns") elements only, like bookmarks, files, and links; "actions" (or
* "verbs") should not have icons.
+ *
+ * Furthermore, if you would like to display keyboard accelerator, you must
+ * pack the accel label into the box using gtk_box_pack_end() and align the
+ * label, otherwise the accelerator will not display correctly. The following
+ * code snippet adds a keyboard accelerator to the menu item, with a key
+ * binding of Ctrl+M:
+ *
+ * |[<!-- language="C" -->
+ * GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ * GtkWidget *icon = gtk_image_new_from_icon_name ("folder-music-symbolic", GTK_ICON_SIZE_MENU);
+ * GtkWidget *label = gtk_accel_label_new ("Music");
+ * GtkWidget *menu_item = gtk_menu_item_new ();
+ * GtkAccelGroup *accel_group = gtk_accel_group_new ();
+ *
+ * gtk_container_add (GTK_CONTAINER (box), icon);
+ *
+ * gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+ * gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+ *
+ * gtk_widget_add_accelerator (menu_item, "activate", accel_group,
+ * GDK_KEY_m, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ * gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menu_item);
+ *
+ * gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
+ *
+ * gtk_container_add (GTK_CONTAINER (menu_item), box);
+ *
+ * gtk_widget_show_all (menu_item);
+ * ]|
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]