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:
Philip Withnall 2019-08-29 09:20:01 +01:00
parent 22b59c91ad
commit ca60cd3314

View File

@ -65,6 +65,8 @@ struct _ViewerFile
GObject parent_instance;
/* instance members */
gchar *filename;
guint zoom_level;
};
/* 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)-&gt;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)-&gt;finalize (obj);
}
static void
viewer_file_class_init (ViewerFileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class-&gt;constructed = viewer_file_constructed;
object_class-&gt;finalize = viewer_file_finalize;
}
static void