G'Day !
I am trying to create toolbars using pixmaps loaded from files. If I do it
using XPM definitions in header files, it works. However I can't get it to
work when I switch to files. I keep getting the following errors.
Gtk-CRITICAL **: file gtkpixmap.c: line 97 (gtk_pixmap_new): assertion `val
!= NULL' failed.
Gtk-CRITICAL **: file gtkwidget.c: line 1427 (gtk_widget_show): assertion
`widget != NULL' failed.
I use the folowing function to load the pixmap. (attached is a xpm
datafile).
/*
* --- Create Widget from XPM file
*/
GtkWidget *CreateWidgetFromXpmFile (GtkWidget *window, gchar *xpm_datafile)
{
GdkBitmap *mask;
GdkPixmap *pixmap;
GtkWidget *pixmapwid;
gchar buffer[50];
sprintf (buffer, "%s", xpm_datafile);
style = gtk_widget_get_style (window);
/* load a pixmap from a file */
pixmap = gdk_pixmap_create_from_xpm ( win_main->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
buffer );
pixmapwid = gtk_pixmap_new( pixmap, mask );
gtk_widget_show( pixmapwid );
return (pixmapwid);
}
Finally this is my call to the xpm function:
/* --- Create "open" button --- */
gtk_toolbar_append_item (GTK_TOOLBAR (toolbar),
"Open Dialog", "Open dialog", "",
CreateWidgetFromXpmFile (vbox_main,"./open.xpm"),
(GtkSignalFunc) ButtonClicked,
NULL);
Any ideas what I'm doing wrong ?
TIA
cheers,
Jim Parker
Attachment:
new.xpm
Description: Binary data