1

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?

peper0
  • 3,111
  • 23
  • 35
  • 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? – leftaroundabout May 23 '12 at 21:22
  • Because GTK+-style inheritance results in bloated code. Moreover I want to use C++ objects in newly defined class. – peper0 May 23 '12 at 21:48
  • 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). – peper0 May 23 '12 at 21:51
  • "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. – ptomato May 23 '12 at 23:24
  • Of course, but the code remains clearer. Overhead is not a problem in my case. – peper0 May 24 '12 at 10:14
  • An intermediate solution might be Vala instead of C++. You would get the best of both. – gpoo May 25 '12 at 06:07

1 Answers1

0

The followings are required to use gtkmm widget in GTK+:

  1. implement the desired custom widget in gtkmm
  2. create a library from the widget for Glade
  3. design the user interface containing the custom widget with Glade
  4. declare the C interface for the application written in GTK+
  5. build the user interface from XML with GtkBuilder

Details can be found in my blog post.

Szilárd Pfeiffer
  • 1,636
  • 1
  • 12
  • 6