4

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! :-(

Klaus
  • 24,205
  • 7
  • 58
  • 113

2 Answers2

4

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.

user96649
  • 471
  • 1
  • 5
  • 22
2

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
andlabs
  • 11,290
  • 1
  • 31
  • 52
  • 2
    Can you give a short example of how to use the "other" way to implement a button? I can't find any example code for that. Simply: How can I make my "Delete" button in the new fashion? – Klaus Sep 26 '14 at 07:42