| Top |
| void | gum_disposable_set_auto_dispose () |
| gboolean | gum_disposable_get_auto_dispose () |
| void | gum_disposable_set_timeout () |
| void | gum_disposable_delete_later () |
GumDisposable is used to dispose the object when the timer expires with the specified timeout value provided auto-dispose is enabled. A GObject which needs to be auto-disposable should derive itself from GumDisposable and can set the timeout value (at the time of object construction e.g.). One such example, which can make use of GumDisposable, is a DBus object as it may be required to destory after some period of inactivity.
Following code snippet demonstrates how to derive and use GumDisposable:
//gum-test-object.h
struct _GumTestObject
{
GumDisposable parent;
};
struct _GumTestObjectClass
{
GumDisposableClass parent_class;
};
//gum-test-object.c
GumTestObject *
gum_test_object_new ()
{
GumTestObject *obj = g_object_new (GUM_TYPE_TEST_OBJECT, NULL);
// ... other code
// GumTestobject will be disposed after 5 seconds unless auto-dispose
// is disabled by calling gum_disposable_set_auto_dispose (obj, FALSE)
gint timeout = 5;
gum_disposable_set_timeout (GUM_DISPOSABLE (obj), timeout);
// ... other code
}
void gum_disposable_set_auto_dispose (GumDisposable *self,gboolean dispose);
Sets the auto-dispose flag, and sets up the timer if needed.
gboolean
gum_disposable_get_auto_dispose (GumDisposable *self);
Gets the auto-dispose value.
void gum_disposable_set_timeout (GumDisposable *self,guint timeout);
Sets the timeout value and sets up the timer if needed. If timeout value is set to 0, the object is never disposed.
void
gum_disposable_delete_later (GumDisposable *self);
Sets the object to be deleted later. Once delete later is requested, the object should not be used.
“auto-dispose” property“auto-dispose” gboolean
This property holds the value of auto-dispose to be TRUE or FALSE. Default value is FALSE. If auto-dispose is TRUE, then object is auto-disposed otherwise not.
Flags: Read / Write
Default value: TRUE
“delete-later” property“delete-later” gboolean
This property is used when the object is asked to be deleted later. The object should not be used once gum_disposable_delete_later is requested for the object.
Flags: Read
Default value: FALSE
“timeout” property“timeout” guint
This property holds the value of timeout in seconds. Default value is 0. If timeout value is 0, the object never auto-dispose.
Flags: Read / Write
Default value: 0
“disposing” signalvoid user_function (GumDisposable *object, gpointer user_data)
This signal is emitted when the object is about to be disposed.
object |
the object which emits the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action