How can I find which GtkWidget to remove here in my code?
I want the new label in my button that i create with pango markup
language. The code compiles and runs but get errors:
(ColdStore:3173): Gtk-WARNING **: Attempting to add a widget with type GtkLabel to a GtkButton, but as a GtkBin subclass a GtkButton can only contain one widget at a time; it already contains a widget of type GtkLabel
hello
Here is my relevant snippet:
GtkWidget *text;
label = g_strdup (gtk_button_get_label (GTK_BUTTON (buttons[i])));
text = gtk_label_new(NULL);
gtk_label_set_markup (GTK_LABEL (text), "<span foreground=\"green\">1402</span>") ;
/* gtk_button_set_label (GTK_BUTTON (buttons[i]), text); */
gtk_container_add (GTK_CONTAINER(buttons[i]), text);
if ( i < 11 )
gtk_button_set_label (GTK_BUTTON (buttons[i+1]), old);
old = label ;
--i;
/* g_free() */
if (i < 0)
return FALSE;
return TRUE;
So i think before gtk_container_add I have to remove the GtkLabel from the container.
PS: How to move the post to Platform,newcomer,gtk not Core?
You’re trying to add the same label—old = label—to different widgets—gtk_button_set_label (buttons[i+1], old)—which is something you cannot do. A widget must have a single parent.
From the snippet you pasted I honestly don’t understand what you’re trying to achieve.