No support for image in GtkButton (Gtk 4)?

In migrating guide from Gtk 3 to Gtk 4 this was there :

Stop using GtkButton’s image-related API

The functions and properties related to automatically add a GtkImage to a GtkButton, and using a GtkSetting to control its visibility, are not supported in GTK 4. Instead, you can just pack a GtkImage inside a GtkButton, and control its visibility like you would for any other widget. If you only want to add a named icon to a GtkButton, you can use gtk_button_set_icon_name() .

I can’t understand this. Like how can you add image to a button? Is it the same as in Gtk 3 or not possible at all in 4?

One more: How to install Gtk 4 in Debian (without from source) ?

Hi! If you want an image and a label inside your button you should create a GtkBox, pack a GtkImage and a GtkLabel inside the box, and pack the box in the button.

If you want a button containing an icon from the icon theme (and no text) you can use gtk_button_set_icon_name.

2 Likes

6 posts were split to a new topic: Is GtkBox going to be deprecated?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.