Re: Creating custom GTK+ widget using C++ -- Ctor/Dtor not called

I'm sorry I was not very clear in my original message.

I have implemented a custom GTK+ widget which relies on a C++ object internally. i.e. the widget structure contains an instance of a C++ class. My concern was that the constructor and destructor of the contained object were not being called. I had assumed that merely compiling as C++ would make it work... but now I realize it need not be so when allocated via g_object_new.

c++-gtk-utils looks like just what I need. Thank you.

-- Agnel

On Sat, Feb 11, 2012 at 1:51 AM, Chris Vine <chris cvine freeserve co uk> wrote:
On Fri, 10 Feb 2012 02:58:53 +0530
Agnel Kurian <agnel kurian gmail com> wrote:
> I am trying to create a custom GTK+ widget using GTK+ 2.4.8 called
> from C++. I find that the constructor and destructor of my widget is
> never called. So...
> 1. Is this expected behaviour?
> 2. What is the usual solution to such a problem (apart from using
> gtkmm)? 3. Any other issues I need to watch out for when using C++
> with GTK+?

If you just want to manage the lifetime of a GtkWidget object using C++
constructors and destructors by containing the Gtk+ object within a C++
object, and add your own interface or specialisations to the GTK+
object, there are some very thin wrapper classes here which will do
this:  See in
particular the WinBase class.

gtkmm automatically wraps all the C object's methods into C++ methods,
whereas WinBase assumes you don't want to do this or that you will do
it yourself.  It depends entirely on what you want from it, how UI
intensive your application is, and how rigorously "C++-ized" you want
GTK+ to become.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]