问题
if I use:
Gtk::Button* button = Gtk::manage( new Gtk::Button(Gtk::Stock::DELETE));
it works perfect, but the documentation and the header says: Deprecated, use label _Delete
But if I simply write
Gtk::Button* button = Gtk::manage( new Gtk::Button("_Delete"));
the button shows simply the text _Delete
.
How can I create a standard button in the "new" fashion?
Update: There is simply no plan to make anything automated anymore in gtk. There was a long discussion on the developers mailing list. They decided that there will no replacement for the stock items anymore. This simply means: Do all the things yourself! :-(
回答1:
The idea is that GTK+ in general has deprecated icons in buttons, possibly as an overarching decision by the GNOME design team.
Even without this decision, stock items in general are deprecated in favor of using freedesktop.org named icons.
That being said, you can either:
- continue to use the stock name
- use the icon named
edit-delete
and set thealways-show-image
property of the button to true
回答2:
What works for me is to have a button and do this :
Button* button = new Button("Button");
button->set_icon_name(MY_ICON_NAME);
Where MY_ICON_NAME is any icon in the icon naming specification, available here : https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
A lot of icons are available, and AFAIK should be available by default.
来源:https://stackoverflow.com/questions/26037055/gtkbutton-with-standard-icons