Carmine
Carmine

Reputation: 13

GtkAlignment can only contain one widget at a time

I made a GUI in Glade. I have this kind of structure:

_ A GtkWindow named winTimer
__ A GtkVBox
___ A GtkHBox
____ A GtkAlignment called alignTimer with absolutely nothing inside.

My structure (gif)

I do:

controlli->alignTimer=GTK_WIDGET(gtk_builder_get_object(builder,"alignTimer"));
controlli->pbTimerComposito = gdk_pixbuf_new(GDK_COLORSPACE_RGB,0,8,320,200);
controlli->imgTimer = GTK_WIDGET(gtk_image_new_from_pixbuf(controlli->pbTimerComposito));
gtk_container_add(GTK_CONTAINER(controlli->alignTimer),controlli->imgTimer); /* warning */
gtk_widget_show(controlli->imgTimer);

Where controlli is a pointer to a struct that has, among other things:

GtkWidget *alignTimer;
GdkPixbuf *pbTimerComposito;
GtkWidget *imgTimer;

I get this at runtime:
Gtk-WARNING **: Attempting to add a widget with type GtkImage to a GtkAlignment, but as a GtkBin subclass a GtkAlignment can only contain one widget at a time; it already contains a widget of type GtkImage

But that is not true! It's the first and only widget that I'm adding! What's happening? I had done the exact same thing in another part of my app and it's been working perfectly for years.

My environment:
- Windows XP SP3
- MinGW
- GCC 4.8.1
- GTK 2.24.10

PS I know I'm using an old version of GTK, deprecated widgets and an ancient OS, but I code just for fun so I'm OK with that. Any help will be very appreciated.

Upvotes: 0

Views: 485

Answers (1)

Carmine
Carmine

Reputation: 13

Problem solved (or, rather, there was no problem).
The function that contained the code I posted above was called twice. Facepalm for myself.

Upvotes: 1

Related Questions