summaryrefslogtreecommitdiff
path: root/gtk/gtkmenuitem.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkmenuitem.c')
-rw-r--r--gtk/gtkmenuitem.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 4c68939ecf..0501a8bd64 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -229,6 +229,35 @@ gtk_menu_item_new_with_label (const gchar *label)
return menu_item;
}
+
+/**
+ * gtk_menu_item_new_with_mnemonic:
+ * @label: The text of the button, with an underscore in front of the
+ * mnemonic character
+ * @returns: a new #GtkMenuItem
+ *
+ * Creates a new #GtkMenuItem containing a label. The label
+ * will be created using gtk_label_new_with_mnemonic(), so underscores
+ * in @label indicate the mnemonic for the menu item.
+ **/
+GtkWidget*
+gtk_menu_item_new_with_mnemonic (const gchar *label)
+{
+ GtkWidget *menu_item;
+ GtkWidget *accel_label;
+
+ menu_item = gtk_menu_item_new ();
+ accel_label = gtk_type_new (GTK_TYPE_ACCEL_LABEL);
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (accel_label), label);
+ gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
+
+ gtk_container_add (GTK_CONTAINER (menu_item), accel_label);
+ gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menu_item);
+ gtk_widget_show (accel_label);
+
+ return menu_item;
+}
+
static void
gtk_menu_item_destroy (GtkObject *object)
{