c++linuxgnomegobjectgobject-introspection

Using C++ bindings with GObject Introspection


I decided I want to use the Goffice library in my project. But I write it in C++, so I prefer to have a C++ class interface, just like I use gtkmm and not GTK+ directly.

The documentation (see link above) says I can use GObject Introspection. So I started reading anout it. I read and read and read, and I just couldn't understand how to use any binding of GOffice. I looked for a goffice gi-repository/typelib file on my system, and in the list of files installed by PackageKit. Found nothing. I checked in PackageKit if goffice or goffice-devel packages depend on the gobject introspection package. Maybe they depend indirectly, but they don't depend on it directly (otherwise I'd see it on the list).

I tried and tried, but I couldn't find a resource which could simply explain how to take a library written in GObject, such as GOffice, and use it on another language, e.g. Python, or in my case C++. Of course, I can use the C functions directly, but the point is that I want to have an interface similar to gtkmm.

(I use GNU/Linux, writing a desktop application with gtkmm and GNU build system, goffice version 0.10)


Solution

  • There is currently no GObject Introspection tool for C++. You can see a list of users at https://live.gnome.org/GObjectIntrospection/Users.

    Based on one of GOffice's automake files, the GIR name GOffice is GOffice-0.10, so you should expect $(pkg-config --variable=girdir gobject-introspection-1.0)/GOffice-0.10.gir and $(pkg-config --variable=typelibdir gobject-introspection-1.0)/GOffice-0.10.typelib, but it's possible your distribution's packages don't include those files, in which case you might want to consider filing a bug.

    As for documentation on how to use GObject Introspection for Python, you should check out the PyGObject site. They link to the The Python GTK+ 3 Tutorial, which should help you get a feel for how to use PyGObject. As for other languages, the documentation will vary depending on the language and implementation.