Hello,

I'm pretty new to gnome development and I have trouble understanding how to draw your own things. My eventual objective is to make a hearts game, but that's a long way off. At the moment I am having trouble to set a background in my UI, much like the green striped background in AisleRiot.

I am using libglade for my UI. The main window (where the cards are going to be) is a GtkDrawingArea called "table". I load up an image and try to fill the drawing area with it, but it doesn't show it. I've tried looking ar AilseRiot and see how they do it, but I can't figure it out. Here's my code, with comments as to what each step is supposed to do.

Any idea what I am doing wrong? Probably lots :-) Thanks in advance!

int main (int argc, char *argv[])
{
        GtkWidget *table_widget;
        GdkGC *table;

        /* Start up glade and show the UI */
        gnome_init (PACKAGE, VERSION, argc, argv);
        glade_gnome_init ();
        xml = glade_xml_new (PACKAGE_SOURCE_DIR"/hearts.glade", NULL, NULL);
        glade_xml_signal_autoconnect (xml);
        
/* Load the background pixmap. get_pixmap() uses gdk_pixbuf_new_from_file() to load the image and returns a GdkPixmap pointer. I got this from the AisleRiot code. background_pixmap is a global. It does return a valid image, not NULL. */
        background_pixmap = get_pixmap(PACKAGE_SOURCE_DIR"/pixmaps/baize.png");
        
/* From what I read, I need a GDK Graphics Context to draw in, so here I create one. I can verify that it does return a GdkGC, and not NULL */
        table_widget = glade_xml_get_widget (xml, "table");
        table = gdk_gc_new (table_widget->window);
        
        /* This should fill the GC with the background image, right? */
        gdk_gc_set_tile (table, background_pixmap);
        gdk_gc_set_fill (table, GDK_TILED);

        /* wait for events */
        gtk_main ();

        /* bye bye */
        return 0;
}

--
Sander Marechal
_______________________________________________
gnome-devel-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnome-devel-list

Reply via email to