gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
507 stars 90 forks source link

[HELP] Using GTK_STOCK_REMOVE #811

Closed twiclo closed 1 year ago

twiclo commented 1 year ago

I've found that with regular C GTK you can pass something like "_Remove" when creating a label and that will replace it with a built in remove icon. How can that be achieved with the Rust library? I found this in the docs: https://gtk-rs.org/gtk3-rs/stable/latest/docs/gtk_sys/constant.GTK_STOCK_REMOVE.html But I'm not sure how I would actually create a button with it

twiclo commented 1 year ago

I was able to get something going using Button::from_icon_name. My problem now is these icons have transparent backgrounds where a regular label created a background for the text when it was being used in an overlay. Is there a way to set the icon and have a background on the button exist?

let remove_btn = gtk::Button::from_icon_name(Some("process-stop"), IconSize::Menu);
remove_btn.set_property("halign", Align::End);
remove_btn.set_property("valign", Align::Start);
remove_btn.set_property("margin_end", 1);
bilelmoussaoui commented 1 year ago

The APIs in question were deprecated and are part of a no longer supported version in the bindings. Using from_icon_name is the way to go.