1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include "default.xpm"
/* example-start buttons buttons.c */
#include <gtk/gtk.h>
GtkWidget *xpm_widget( GtkWidget *parent,
gchar *xpm_filename)
{
GtkWidget *image;
GdkPixbuf *pixbuf;
GError *error = NULL;
/* Load the pixbuf from file */
pixbuf = gdk_pixbuf_new_from_file(xpm_filename, &error);
if (!pixbuf) {
g_warning("Failed to load image %s: %s", xpm_filename, error->message);
g_error_free(error);
return NULL;
}
/* Create image widget from pixbuf */
image = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
return(image);
}
/* example-start pixmap pixmap.c */
GtkWidget *xpm_widget_default( GtkWidget *parent)
{
/* GtkWidget is the storage type for widgets */
GtkWidget *image;
GdkPixbuf *pixbuf;
/* Create pixbuf from xpm data */
pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)default_xpm);
/* a image widget to contain the pixbuf */
image = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref(pixbuf);
return(image);
}
|