This is a class to manage the lifetime of widgets which are not top-level widgets (ie which are not derived from GtkWindow). More...
|GtkWidget *||get_main_widget () const|
|MainWidgetBase (GtkWidget *widget)|
This is a class to manage the lifetime of widgets which are not top-level widgets (ie which are not derived from GtkWindow).
Normally you will not need this class, because the GObject reference counting system coupled with the WinBase class will provide for lifetime management and exception safety, provided that widgets are placed in their containers on a "top-down" basis and the top-level window is managed by a WinBase object.
However, sometimes it is convenient for a class to encapsulate only part of the implementation of a top level window, and for there to be automatic lifetime management of a widget before it is placed in a GTK+ container.
The MainWidgetBase class is intended to achieve this, by managing references with g_object_ref_sink() such that the widget managed by the class and its children are correctly destroyed when the MainWidgetBase class goes out of scope or is deleted even if they are not subsequently placed in another GTK+ container object which calls g_object_ref_sink() on the widget.
This class therefore represents a safety feature which can be used simply by inheriting from it. It also enables a widget to be placed in and removed from a GTK+ container without it being destroyed by the removal, since it is owned by the MainWidgetBase class object.
See Writing multi-threaded programs using c++-gtk-utils for particulars about GTK+ thread safety (and so MainWidgetBase thread safety).
This class is not compiled into the library if the library is built with the --without-gtk configuration option.
The constructor will not throw. It calls g_object_ref_sink() to take ownership of the object to be managed.
|widget||The GtkWidget object to be managed by this class.|
The destructor will not throw. It calls g_object_unref() to relinquish ownership of the managed object.
Returns the GtkWidget object managed by this class. This method will not throw.