Mixing C and C++ APIs

You can use C APIs which do not yet have convenient C++ interfaces. It is generally not a problem to use C APIs from C++, and gtkmm helps by providing access to the underlying C object, and providing an easy way to create a C++ wrapper object from a C object, provided that the C API is also based on the GObject system.

To use a gtkmm instance with a C function that requires a C GObject instance, use the gobj() function to obtain a pointer to the underlying GObject instance. For instance

Gtk::Button* button = new Gtk::Button("example");

To obtain a gtkmm instance from a C GObject instance, use the Glib::wrap() function. For instance

GtkButton* cbutton = get_a_button();
Gtk::Button* button = Glib::wrap(cbutton);