2
votes

I know this question exists How to add an image to a button with GTK but gtk_button_set_image is deprecated in gtk4.

2
just create a GtkImage and add() it to the Button. The point I think is that specialised code to create child widgets by the Button itself is not needed when users can just set up the child they want and add it in.underscore_d
Ok, I get it . I just needed to set it like this : gtk_button_set_child (GTK_BUTTON (button), image); where button is GtkButton and image is a GtkImage. Thanks . That was fast .Placeholder
Better to gtk_container_add (GTK_CONTAINER (button), image) imo, just looks more right.underscore_d
gtk_container_add() it's deprecated too in gtk4Placeholder
ok, so then use gtk_button_set_child()underscore_d

2 Answers

1
votes

gtk_button_set_child (GTK_BUTTON (button), image); where button and image are GtkButton and GtkImage , respectivly .

0
votes
Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5);
box.prepend(new Image.from_icon_name("media-playback-start"));
box.append(new Gtk.Label("Play"));
button.child = box;