Gtk::Button with standard Icons

余生长醉 提交于 2021-02-10 07:28:12

问题


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 the always-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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!