Search code examples
c++gtkgtkmm

Gtk::ScaleButton: Icons in the constructor


I am trying to use a Gtk::ScaleButton in Gtkmm 3. My problem is the constructor. It needs as last parameter (see here: https://developer.gnome.org/gtkmm/stable/classGtk_1_1ScaleButton.html#a96753b6cb6b8adb0ed3727ba3eb8cfb7 ) a vector of ustrings. I guess (i can't find it in the docs what it means exactly) i have to give it the path to the +/- Images. I want to use the Gtk Stock items for +/-. How can i achieve this?

Currently i give it an empty vector, which results in a glibmm warning:

    std::vector<Glib::ustring> icons;
    Gtk::ScaleButton * scale = Gtk::manage(new Gtk::ScaleButton(Gtk::ICON_SIZE_SMALL_TOOLBAR, 0.0, 10.0, 1.0, icons));

Warning:

 glibmm-WARNING **: Glib::ConstructParams::ConstructParams(): object class "gtkmm__GtkScaleButton" has no property named "min"

How can i avoid the warning and give it stock icons?


Solution

  • You must be one of the first people to ever try using this Gtk::ScaleButton constructor from gtkmm. It seems to have been broken for several years.

    I've fixed it in gtkmm: https://git.gnome.org/browse/gtkmm/commit/?id=26f94d231da9481d74acdd94e56168ed6b38609a

    But it will be some time until that is widely available via Linux distro packages. In the meantime you can try using

    Gtk::ScaleButton* button = Glib::wrap(gtk_scale_button_new(whatever));
    

    See https://developer.gnome.org/gtkmm-tutorial/stable/sec-basics-gobj-and-wrap.html.en

    However, I don't know how it's actually meant to behave, so you might encounter other bugs. You might actually want to use the derived Gtk::VolumeButton instead.

    andlabs is correct that the GTK+ documentation describes the icons better: https://developer.gnome.org/gtk3/stable/GtkScaleButton.html#GtkScaleButton--icons and those should indeed probably be the standard icon names: http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html