Re: GTK+ & images



On Tue, 4 Jan 2005, Hubert Sokolowski wrote:

I have not been able to find a way to add an image to the background of a
window
created with glade.
I would like to have the base window to have a background image and each
button
on that window to also have an image as background. I have seen this done
on VB
& want the same functionality in GTK+.
Can this be done?
yes,
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Windows.html#gdk-window-set-back-pixmap

I have tried that as follows:-

int main(int argc, char **argv)
{
   GtkWindow *window;
   GtkButton *button;
   GtkImage  *image;
   GdkPixbuf *orig_pixbuf;

   /* Initialize GTK+ */
   gtk_init(&argc, &argv);

   /* create window, set default height and width to 200 pixels */
   window = g_object_new(GTK_TYPE_WINDOW,
                         "default-height", 640,
                         "default-width", 480,
                         "border-width", 12,
                         "title", "Kiosk",
                         NULL);

   image = g_object_new(GTK_TYPE_IMAGE, "file", "Background.jpg", NULL);
   g_object_get(image, "pixbuf", &orig_pixbuf, NULL);
   g_object_set_data(G_OBJECT(image),"orig_pixbuf",(gpointer)orig_pixbuf);
   gdk_window_set_back_pixmap((GdkWindow *)window, (GdkPixmap *)image, FALSE);

but when I run the program I get:-
(Kiosk:2175): Gdk-CRITICAL **: file gdkwindow-x11.c: line 2508 (gdk_window_set_back_pixmap): assertion `GDK_IS_WINDOW (window)' failed

---

Regards,
Alf Stockton    www.stockton.co.za

Real programmers don't write in BASIC.  Actually, no programmers write
in BASIC after reaching puberty.
NOTE: Dear Outlook users: Please remove me from your address books.
       Read this article and you know why:
       http://newsforge.com/article.pl?sid=03/08/21/143258




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]