Index: gtk/gtkitemfactory.c =================================================================== diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- gtk/gtkitemfactory.c 2001/07/03 20:18:42 1.1.1.1 +++ gtk/gtkitemfactory.c 2001/07/04 08:01:13 1.1.1.1.2.1 @@ -28,7 +28,9 @@ */ #include "gtkitemfactory.h" +#include "gtk/gtkwindow.h" #include "gtk/gtksignal.h" +#include "gtk/gtkpixmap.h" #include "gtk/gtkoptionmenu.h" #include "gtk/gtkmenubar.h" #include "gtk/gtkmenu.h" @@ -37,6 +39,7 @@ #include "gtk/gtkcheckmenuitem.h" #include "gtk/gtktearoffmenuitem.h" #include "gtk/gtkaccellabel.h" +#include "gdk/gdkx.h" #include "gdk/gdkkeysyms.h" #include #include @@ -978,6 +981,34 @@ return TRUE; } +static GdkPixmap *icon_pixmap=NULL; +static GdkBitmap *icon_mask=NULL; + +void +gtk_item_factory_create_item_with_icon (GtkItemFactory *ifactory, + GtkItemFactoryEntry *entry, + gchar **icon_data, + gpointer callback_data, + guint callback_type) +{ + GtkStyle *style; + +#if 0 +printf("itemfactory: pixmap creating...: %s\n", entry->path); +printf("%p\n", icon_data); +#endif + if (icon_data!=NULL) { + style=gtk_widget_get_style(ifactory->widget); + icon_pixmap=gdk_pixmap_create_from_xpm_d(GDK_ROOT_PARENT(), &icon_mask, + &style->bg[GTK_STATE_NORMAL], + icon_data); + } +#if 0 +puts("itemfactory: pixmap created"); +#endif + gtk_item_factory_create_item (ifactory, entry, callback_data, callback_type); +} + void gtk_item_factory_create_item (GtkItemFactory *ifactory, GtkItemFactoryEntry *entry, @@ -1057,6 +1088,7 @@ &path, &parent_path, &name)) return; + parent = gtk_item_factory_get_widget (ifactory, parent_path); if (!parent) { @@ -1112,13 +1144,40 @@ *name) { GtkWidget *label; - - label = gtk_widget_new (GTK_TYPE_ACCEL_LABEL, - "GtkWidget::visible", TRUE, - "GtkWidget::parent", widget, - "GtkAccelLabel::accel_widget", widget, - "GtkMisc::xalign", 0.0, - NULL); + + if (icon_pixmap!=NULL) { + GtkWidget *align; + GtkWidget *hbox; + GtkWidget *icon; + +#if 0 +printf("icon_pixmap: %p %s\n", icon_pixmap, path); +#endif + align = gtk_alignment_new(1,0,0,0); + hbox = gtk_hbox_new(FALSE, 0); + + icon=gtk_pixmap_new(icon_pixmap, icon_mask); + gtk_container_add (GTK_CONTAINER (hbox), icon); + label = gtk_widget_new (GTK_TYPE_ACCEL_LABEL, + "GtkWidget::visible", TRUE, + "GtkWidget::parent", hbox, + "GtkAccelLabel::accel_widget", hbox, + "GtkMisc::xalign", 0.0, + NULL); + gtk_container_add (GTK_CONTAINER (align), hbox); + gtk_container_add (GTK_CONTAINER (widget), align); + gtk_widget_show_all (align); + gdk_pixmap_unref(icon_pixmap); + icon_pixmap=NULL; + icon_mask=NULL; + } else { + label = gtk_widget_new (GTK_TYPE_ACCEL_LABEL, + "GtkWidget::visible", TRUE, + "GtkWidget::parent", widget, + "GtkAccelLabel::accel_widget", widget, + "GtkMisc::xalign", 0.0, + NULL); + } accel_key = gtk_label_parse_uline (GTK_LABEL (label), name); Index: gtk/gtkitemfactory.h =================================================================== RCS file: /home/grp1/oshiro/work/repository/gtk+-1.2.10/gtk/gtkitemfactory.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- gtk/gtkitemfactory.h 2001/07/03 20:18:46 1.1.1.1 +++ gtk/gtkitemfactory.h 2001/07/04 08:01:14 1.1.1.1.2.1 @@ -173,6 +173,11 @@ gboolean modified_only); void gtk_item_factory_print_func (gpointer FILE_pointer, gchar *string); +void gtk_item_factory_create_item_with_icon (GtkItemFactory *ifactory, + GtkItemFactoryEntry *entry, + gchar **icon_data, + gpointer callback_data, + guint callback_type); void gtk_item_factory_create_item (GtkItemFactory *ifactory, GtkItemFactoryEntry *entry, gpointer callback_data,