Window with background Image



I've been working on this problem for 6 hours now so any help would be
appreciated.  I've created a simple test app to try to figure out what
I'm doing wrong.  I've read everything in the archives even remotely
related to this issue.

I'm needing a background image on a window to indicate that the window
is in edit mode, similar to the way glade paints the cross hatch
pattern.  I'm not getting any errors with the code below, but I'm also
not seeing my image and I don't know what else to try.  Here is the
simple testing app I have right now:

#include <gtk/gtk.h>

int main( int   argc, char *argv[] ){
    GtkWidget *window;
    GdkPixbuf *pixbuf_image = NULL;
    GdkPixmap *pixmap;
    GdkScreen *screen = NULL;
    gint depth, width, height;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    gtk_widget_realize(window);

    pixbuf_image = gdk_pixbuf_new_from_file("test.png",NULL);
    width = gdk_pixbuf_get_width(pixbuf_image);
    height = gdk_pixbuf_get_height(pixbuf_image);
    screen = gdk_screen_get_default();
    depth = (gdk_screen_get_system_visual(screen))->depth;
    pixmap = gdk_pixmap_new(NULL, width, height, depth);
    gdk_drawable_set_colormap(pixmap, gdk_colormap_get_system ());
    gdk_pixbuf_render_pixmap_and_mask(pixbuf_image, &pixmap, NULL,0);
    gdk_window_set_back_pixmap(gtk_widget_get_root_window(window),
pixmap, FALSE);

    gtk_widget_show (window);

    gtk_main ();

    return 0;
}







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