[maemo-developers] GtkImage with inverted colors: why?

From: Floriano Scioscia floriano.scioscia at libero.it
Date: Sat Nov 7 21:22:29 EET 2009

I would like some help to solve a GTK+ problem, since I am working with this
GUI library for the first time.

I want to create some clickable boxes with a background image. I am using a
GtkEventBox with a GtkImage inside, as I read on the API. This is my
function for setting the background image:

static void set_box_image(struct game_data *d, gint box_index, gint
img_index) {
    gchar file[40];
    sprintf(file, "/usr/share/pixmaps/100boxes/%d.png", img_index);
    GtkWidget *img = gtk_image_new_from_file(file);
    GtkWidget *old = gtk_bin_get_child(GTK_BIN(d->base[box_index]));
    if (old != NULL) {
    gtk_container_add(GTK_CONTAINER(d->base[box_index]), GTK_WIDGET(img));

where d->base is an array of GtkEventBox items.

The problem is that sometimes the images appear with inverted colors (i.e.
in negative). It happens in an inconsistent manner, I have not been able to
spot the cause so far.
I suspect it has to do with GtkWidget states, so I tried to set the state
programmatically (both for the GtkEventBox and the GtkImage), but that did
not solve the problem.

Thanks for your attention.
Best wishes

Floriano Scioscia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20091107/99a6b885/attachment.htm 
More information about the maemo-developers mailing list