I can use
gtk_button_set_icon_name, to set a button’s icon from default icons. What if I have and icon as gresource. How can I set the icon? It seems in gtk4 I cant use GtkImage on a button.
I can use
You can use
GtkWidget *image = gtk_image_new_from_resource ("/com/example/resource.png"); GtkWidget *button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_show (image);
GtkButton is a container, so you can pack widgets into it—which is what the
GtkButton API in GTK3 does.
This should also answer you question about GTK4: you can still use images with
GtkButton by packing them into your button.
Or add your icons to the usual icon theme using https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-add-resource-path, then you can refer to them by icon name.
Though this will popup another question of adding a path that is in resource. If it’s in the file system cool but if it in compiled resources how would I reference that
Like this: https://wiki.gnome.org/HowDoI/ThemedIcons
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.