Stock menu items (bug 50489)
- From: Alexander Larsson <alla lysator liu se>
- To: gtk-devel-list gnome org
- Subject: Stock menu items (bug 50489)
- Date: Fri, 23 Feb 2001 14:54:35 +0100 (CET)
This implements stock GtkImageMenuItems.
It could possibly be placed in gtkmenuitem.h and called
gtk_menu_item_new_stock() instead, to hide the fact that it's actually
implemented using a GtkImageMenuItem.
Comments?
Index: gtk/gtkimagemenuitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimagemenuitem.c,v
retrieving revision 1.2
diff -u -p -r1.2 gtkimagemenuitem.c
--- gtk/gtkimagemenuitem.c 2001/02/15 03:40:48 1.2
+++ gtk/gtkimagemenuitem.c 2001/02/23 13:37:32
@@ -28,6 +28,9 @@
#include "gtkaccellabel.h"
#include "gtksignal.h"
#include "gtkintl.h"
+#include "gtkstock.h"
+#include "gtkiconfactory.h"
+#include "gtkimage.h"
static void gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass);
static void gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item);
@@ -389,6 +392,35 @@ gtk_image_menu_item_new (GtkWidget *wi
gtk_image_menu_item_add_image (image_menu_item, widget);
return GTK_WIDGET(image_menu_item);
+}
+
+GtkWidget*
+gtk_image_menu_item_new_stock (const gchar *stock_id,
+ GtkAccelGroup *accel_group)
+{
+ GtkWidget *image;
+ GtkStockItem stock_item;
+ GtkWidget *item;
+
+ image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+
+ if (gtk_stock_lookup (stock_id, &stock_item))
+ {
+ item = gtk_image_menu_item_new (image, stock_item.label);
+
+ if (stock_item.keyval && accel_group)
+ gtk_widget_add_accelerator (item,
+ "activate",
+ accel_group,
+ stock_item.keyval,
+ stock_item.modifier,
+ GTK_ACCEL_VISIBLE);
+ }
+ else
+ item = gtk_image_menu_item_new (image, stock_id);
+
+ gtk_widget_show (image);
+ return item;
}
void
Index: gtk/gtkimagemenuitem.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimagemenuitem.h,v
retrieving revision 1.1
diff -u -p -r1.1 gtkimagemenuitem.h
--- gtk/gtkimagemenuitem.h 2001/02/13 05:44:47 1.1
+++ gtk/gtkimagemenuitem.h 2001/02/23 13:37:32
@@ -64,9 +64,11 @@ struct _GtkImageMenuItemClass
GtkType gtk_image_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_image_menu_item_new (GtkWidget *widget,
- const gchar *label);
+ const gchar *label);
+GtkWidget* gtk_image_menu_item_new_stock (const gchar *stock_id,
+ GtkAccelGroup *accel_group);
void gtk_image_menu_item_add_image (GtkImageMenuItem *image_menu_item,
- GtkWidget *child);
+ GtkWidget *child);
GtkWidget* gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
#ifdef __cplusplus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]