| gumd API Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Properties | Signals | ||||
#include <gum/common/gum-disposable.h> struct GumDisposable; struct GumDisposableClass; void gum_disposable_delete_later (GumDisposable *self); gboolean gum_disposable_get_auto_dispose (GumDisposable *self); void gum_disposable_set_auto_dispose (GumDisposable *self,gboolean dispose); void gum_disposable_set_timeout (GumDisposable *self,guint timeout);
"auto-dispose" gboolean : Read / Write "delete-later" gboolean : Read "timeout" guint : Read / Write
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
}
struct GumDisposableClass {
GObjectClass parent_class;
};
Opaque structure for the class.
GObjectClass |
parent class object |
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.
|
an instance of GumDisposable. [transfer none] |
gboolean gum_disposable_get_auto_dispose (GumDisposable *self);
Gets the auto-dispose value.
|
an instance of GumDisposable. [transfer none] |
Returns : |
the auto-dispose value of the object. |
void gum_disposable_set_auto_dispose (GumDisposable *self,gboolean dispose);
Sets the auto-dispose flag, and sets up the timer if needed.
|
an instance of GumDisposable. [transfer none] |
|
dispose flag |
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.
|
an instance of GumDisposable. [transfer none] |
|
timeout value in seconds |
"auto-dispose" property"auto-dispose" gboolean : Read / Write
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.
Default value: TRUE
"delete-later" property"delete-later" gboolean : Read
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.
Default value: FALSE
"timeout" property"timeout" guint : Read / Write
This property holds the value of timeout in seconds. Default value is 0. If timeout value is 0, the object never auto-dispose.
Default value: 0
"disposing" signalvoid user_function (GumDisposable *object,
gpointer user_data) : Action
This signal is emitted when the object is about to be disposed.
|
the object which emits the signal |
|
user data set when the signal handler was connected. |