I would like to define a new subclass of some gtkmm type, implementing interface of underlying GTK+ object. Then, i want to compile it into some kind of dll and use in pure C code (GTK+, no gtkmm) through this interface. Is it possible?
Is it possible to define GTK+ type using gtkmm?
The result will necessarily be a C++ class. There's no way to use a C++ class from C, but you can of course write a C wrapper around it. Would be a bit roundabout though, wouldn't it? If you want to use it in C, why not just write it in C? –
Builder
Because GTK+-style inheritance results in bloated code. Moreover I want to use C++ objects in newly defined class. –
Ferrell
Technically it could be possible without writting any additional wrapper - we'd just need to tell to the GTK+ magic layer how big the object is and tell somewhat how to call the constructor. The question is - how to do it in non-hacky way (if such exists). –
Ferrell
"Because GTK+-style inheritance results in bloated code." Inheritance is inherently complicated. All that 'bloat' is going on in C++ too, only under the hood. –
Earlie
Of course, but the code remains clearer. Overhead is not a problem in my case. –
Ferrell
An intermediate solution might be Vala instead of C++. You would get the best of both. –
Iliac
The followings are required to use gtkmm widget in GTK+:
- implement the desired custom widget in gtkmm
- create a library from the widget for Glade
- design the user interface containing the custom widget with Glade
- declare the C interface for the application written in GTK+
- build the user interface from XML with
GtkBuilder
Details can be found in my blog post.
© 2022 - 2024 — McMap. All rights reserved.