Search code examples
cimageubuntugtkgdk

How would one go about opening an image not as widget in C/GTK?


What I am trying to do is open several images in C, then create a table comprised of GtkImages who's actual images can be set or reset to one of the initial images(I'm trying to create a chess board). I tried doing this with GTK but I can't use an image more than once because it is a widget. I tried using GDK, but according to the documentation all (image related) GDK functions are deprecated.

The widets should look like this:

window <- table <- a1 a2 a3 ... a8                a1 - h8 are GtkImages.
                   b1 b2 b3 ... b8
                   c1 c2 c3 ... c8
                    ...
                   h1 h2 h3 ... h8

Does anyone have any ideas? I'm getting really confused about opening/using images/pixmaps in GTK. Also I am using Ubuntu. All answers are greatly appreciated.


Solution

  • Store the images as GdkPixbufs. It's not deprecated. Swap them into the GtkImage widgets using gtk_image_set_from_pixbuf().