C vs C++ for developing a Widget

A widget project for GTK4 is currently in development which I am contributing to called GTK Browser Widget. The aim is to provide a widget to allow embedding MSwebview2, Chromium and Webkit. The widget is made in C++ using GTKMM and language bindings will be written later for C, etc. A third-party involved has expressed concern about using C++ for this as he says the normal workflow is to write the widget in C and then do bindings for C++ and other languages. I would like to confirm that this workflow of using C++ and GTKMM and then writing bindings for C, Python, etc. is an acceptable workflow.

The API can be in C with the GObject library (that way there are automatically lots of bindings), and internally C++ is used. Like WebKitGTK.

1 Like

Have you noticed that the long-term maintenance of gtkmm is uncertain?
See Should I Move from GTK (C) to gtkmm (C++)? Future of gtkmm?.

If you intend to continue developing your widget when gtk5 is created, it might be
unwise to let all language bindings depend heavily on gtkmm.

Hi,

As alternative to gtkmm, there is some work in progress on a new C++ bindings framework, named peel, see Sergey Bugaev / peel · GitLab .
That may be worth to have a look.

About the GObject bindings, I don’t know the details, but there is also Vte (the terminal widget) which is implemented in C++, probably easier to analyze than WebKitGTK.

2 Likes

Can I anticipate that peel will be supported well into the future including with GTK5?

peel uses the gobject-introspection data to generate the bindings, so isn’t restricted to any specific Gtk version.

As for long-term support, better ping the authors directly to ask about their plans.

Is it a safe assumption that there will always be a supported C++ binding for GTK even if GTKMM or peel get orphaned?

C++ have fairly big community, so I guess so? And even if they will get orphaned, you can always step in. GTK ecosystem is run by volunteers

For a small hobby project this would mean to switch attention from the initial project to the development and maintenance of the C++ bindings system. (Not a bad idea per se, the developer just gets a bit side-tracked).

For a bigger and financially successful project, the story can be different.

If a company wants to build (or already has) a big project with C++ and GTK, it is also possible to provide funding. I think the GNOME Foundation now is more inclined to receive such funding and hire a contractor developer to work on a specific area (C++ bindings in this case). Or by contacting a consultancy company specialized in GNOME.

A company with a serious project should not dismiss our development platform just because some parts of it are not super well maintained, or lack some stuff, or would need further development to be fully functional. It’s fixable and actionable.

Maybe this needs more marketing to show that this is possible, to engage bigger stakeholders and companies.

If a company wants to build (or already has) a big project with C++ and GTK, it is also possible to provide funding. I think the GNOME Foundation now is more inclined to receive such funding and hire a contractor developer to work on a specific area (C++ bindings in this case). Or by contacting a consultancy company specialized in GNOME.

A company with a serious project should not dismiss our development platform just because some parts of it are not super well maintained, or lack some stuff, or would need further development to be fully functional. It’s fixable and actionable.

Maybe this needs more marketing to show that this is possible, to engage bigger stakeholders and companies.

I may be interested in looking into that. Do you know anyone I could contact about this? (Feel free to DM me too)

There is a list of companies contributing to GNOME, see

The list also includes companies developing products but not providing consultancy work.

For consultancy there is - in alphabetical order - Centricular (but more oriented for GStreamer and multimedia), Codethink, Collabora, Igalia, and maybe others now? And also the GNOME Foundation (for example Endless is currently funding some targeted work in GNOME through the GNOME Foundation).

For the intersection between C++ experts and GNOME development, look maybe at the companies contributing to WebKitGTK (especially Igalia I think).

You can contact also individual developers to offer them paid work :wink:

(Note that I’m not a C++ expert).

Is the list of maintainers on this site up-to-date: gtkmm Development - gtkmm - C++ Interfaces for GTK and GNOME? Only Kjell Ahlstedt seems to have pushed commits anytime in the past several years Commits · master · GNOME / gtkmm · GitLab

If you want “safe assumptions” you should start contributing to gtkmm. Otherwise, the licensing terms apply:

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Is the list of maintainers on this site up-to-date: gtkmm Development - gtkmm - C++ Interfaces for GTK and GNOME?

No, it’s not up-to-date.

If I want to avoid this issue is there a wrapper for another language (eg. Javascript) that is well-maintained and is not at the risk of abandonment that GTKMM is?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.