mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
tutorial: Add private members to example code in tutorial
Add the private members referred to in the property setting/getting example, and a finalize function for them, to make the tutorial code more self-contained. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1858
This commit is contained in:
parent
22b59c91ad
commit
ca60cd3314
@ -65,6 +65,8 @@ struct _ViewerFile
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
/* instance members */
|
/* instance members */
|
||||||
|
gchar *filename;
|
||||||
|
guint zoom_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* will create viewer_file_get_type and set viewer_file_parent_class */
|
/* will create viewer_file_get_type and set viewer_file_parent_class */
|
||||||
@ -80,12 +82,25 @@ viewer_file_constructed (GObject *obj)
|
|||||||
G_OBJECT_CLASS (viewer_file_parent_class)->constructed (obj);
|
G_OBJECT_CLASS (viewer_file_parent_class)->constructed (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
viewer_file_finalize (GObject *obj)
|
||||||
|
{
|
||||||
|
ViewerFile *self = VIEWER_FILE (obj);
|
||||||
|
|
||||||
|
g_free (self->filename);
|
||||||
|
|
||||||
|
/* Always chain up to the parent finalize function to complete object
|
||||||
|
* destruction. */
|
||||||
|
G_OBJECT_CLASS (viewer_file_parent_class)->finalize (obj);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
viewer_file_class_init (ViewerFileClass *klass)
|
viewer_file_class_init (ViewerFileClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->constructed = viewer_file_constructed;
|
object_class->constructed = viewer_file_constructed;
|
||||||
|
object_class->finalize = viewer_file_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user