mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 02:06:18 +01:00
Merge branch '1858-tutorial-deprecated-gobject-api' into 'master'
Fix handling of private object members in GObject property tutorial Closes #1858 See merge request GNOME/glib!1069
This commit is contained in:
commit
0869cdedcf
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user