I’m pretty new to the whole GTK stack - so here’s a noob question.
I’m working on a new VPN plugin for NetworkManager. The whole NetworkManager stack and all the existing VPN plugins are written in C using GTK3/4.
I am starting to look into if I can write the plugin primarily using C++ with gtkmm. The VPN plugins passes some GObject objects back to the NetworkManager, which contains the UI widgets the user interacts with.
So what I’m wondering if it is possible at all to create the needed objects in C++ using gtkmm and pass these objects to the C APIs somehow. I know the C++ code will need to be wrapped and exposed through an «extern “C”» block for the functions NetworkManager expects to find in the plug-in.
Thanks in advance for any advises and knowledge sharing.
Yes, and it’s probably pretty easy to do. As long as you follow whatever API/ABI conventions NetworkManager expects, you should be fine. NetworkManager is surely expecting to work with C APIs, but it’s fine and normal for the implementation details to be handled in C++.
You can look at WebKitGTK for an example of implementing GObject C APIs using C++.
So I had a quick peek at the source code for WebKitGTK 2.48 … that doesn’t seem to use gtkmm at all, from what I can understand. Maybe I’ve overlooked something?
What I see WebKitGTK do is wrapping the GTK C APIs into C++ code, passing GObject objects as raw pointers, just like in C.