Commit 0869cded authored by Philip Withnall's avatar Philip Withnall

Merge branch '1858-tutorial-deprecated-gobject-api' into 'master'

Fix handling of private object members in GObject property tutorial

Closes #1858

See merge request !1069
parents 150b9469 ca60cd33
Pipeline #122362 failed with stages
in 20 minutes and 20 seconds
......@@ -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)->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
viewer_file_class_init (ViewerFileClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = viewer_file_constructed;
object_class->finalize = viewer_file_finalize;
}
static void
......@@ -465,12 +480,12 @@ ViewerFile *file = g_object_new (VIEWER_TYPE_FILE, NULL);
/* Implementation */
/************************************************/
enum
typedef enum
{
PROP_FILENAME = 1,
PROP_ZOOM_LEVEL,
N_PROPERTIES
};
} ViewerFileProperty;
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
......@@ -482,7 +497,7 @@ viewer_file_set_property (GObject *object,
{
ViewerFile *self = VIEWER_FILE (object);
switch (property_id)
switch ((ViewerFileProperty) property_id)
{
case PROP_FILENAME:
g_free (self->filename);
......@@ -510,7 +525,7 @@ viewer_file_get_property (GObject *object,
{
ViewerFile *self = VIEWER_FILE (object);
switch (property_id)
switch ((ViewerFileProperty) property_id)
{
case PROP_FILENAME:
g_value_set_string (value, self->filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment