Changes in gtkmm 3

gtkmm-3.0 is a new version of the gtkmm API that installs in parallel with the older gtkmm-2.4 API. The last version of the gtkmm-2.4 API was gtkmm 2.24. gtkmm 3 has no major fundamental differences to gtkmm 2 but does make several small changes that were not possible while maintaining binary compatibility. If you never used the gtkmm-2.4 API then you can safely ignore this chapter.

gtkmm 3's library is called libgtkmm-3.0 rather than libgtkmm-2.4 and installs its headers in a similarly-versioned directory, so your pkg-config check should ask for gtkmm-3.0 rather than gtkmm-2.4.

gtkmm 3 added some new classes:

  1. Gtk::AppChooser, Gtk::AppChooserButton, Gtk::AppChooserDialog allow the user to select an installed application to open a particular type of content.

  2. Gtk::Grid is a new container widget that will eventually replace Gtk::Box and Gtk::Table. It arranges its children according to properties of those children rather than its own layout details.

  3. Gtk::Switch displays On/Off states more explictly than Gtk::CheckBox. It may be useful, for instance, when allowing users to activate hardware.

gtkmm 3 also made several small changes to the API, which you will probably encounter when porting code that used gtkmm-2.4. Here is a short list:

  1. Gtk::CellLayout, used by Gtk::IconView, Gtk::TreeView::Column and Gtk::ComboBox, now has a Gtk::CellArea which can be used to specify more details of how the CellRenderers are arranged and aligned.

  2. Gtk::ComboBox now derives from CellLayout, allowing easier layout and alignment of its Gtk::CellRenderers.

  3. Gtk::Adjustment and IconSet and Gdk::Cursor are now used via Glib::RefPtr.

  4. Gtk::Box, Gtk::ButtonBox, Gtk::IconView, Gtk::Paned, Gtk::ProgressBar, Gtk::ScaleButton, Gtk::Scrollbar and Gtk::Separator now derive from Gtk::Orientable, allowing their orientation (vertical or horizontal) to be specified without requiring the use of a derived class such as Gtk::HBox.

  5. Gtk::IconView, Gtk::TextView, Gtk::TreeView and other widgets derive from Scrollable instead of having their own methods such as get_vadjustment() and instead of having their own set_scroll_adjustments signal.

  6. Gtk::Style and Gtk::Rc were removed, replaced by Gtk::StyleContext, and Gtk::StyleProviders, such as Gtk::CssProvider.

  7. Widget::on_expose_event() was replaced by Widget::on_draw(), which assumes that cairomm is used for drawing, via the provided Cairo::Context and does not require you to call Cairo::Context::clip().

  8. Gdk::RGBA replaces Color, adding an alpha component for opacity. Colormap was removed, along with its awkward use to allocate colors.

  9. Gdk::Pixmap and Gdk::Bitmap were removed in favour of Gdk::Pixbuf.

  10. Gdk::Drawable was removed, with its methods moving into Gdk::Window.

  11. We now use std::vector in several methods instead of the intermediate *Handle types to make the API clearer.

All deprecated API was removed in gtkmm 3.0, though there will be new deprecations in future versions.

As a first step to porting your source code to gtkmm-3.0 you should probably ensure that your application builds with the deprecated gtkmm-2.4 API disabled, by defining macro such as GTKMM_DISABLE_DEPRECATED. There are some autotools macros that can help with this by defining them optionally at build time. See the gtkmm 3 porting wiki page for more details.