[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

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@xxxxxxxxxxxxxxxxxxxxx> wrote:
On Fri, 10 Feb 2012 02:58:53 +0530
Agnel Kurian <agnel.kurian@xxxxxxxxx> 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: http://cxx-gtk-utils.sourceforge.net/2.0/index.html.  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.

Chris

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[GIMP Users]     [Yosemite News]    [Yosemite Photos]    [Gimp's Home]     [Steve's Art]

Add to Google Powered by Linux