summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-08-29 09:12:18 +0100
committerPhilip Withnall <withnall@endlessm.com>2019-08-29 09:12:18 +0100
commit61912bffb59140416e1a55461230db847d448740 (patch)
tree2bd303648676a6c40e3354c38c9cc208a067249f
parentfea016399c9c1177c6e7cd25c8605ff9b5ec32c2 (diff)
downloadglib-61912bffb59140416e1a55461230db847d448740.tar.gz
tutorial: Improve type safety of property usage in GObject tutorial
This means that if you compile with `-Wswitch-enum`, the compiler will warn you about properties which you’ve forgotten to handle in `set_property()` or `get_property()`. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1858
-rw-r--r--docs/reference/gobject/tut_gobject.xml8
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/reference/gobject/tut_gobject.xml b/docs/reference/gobject/tut_gobject.xml
index 161150ebf..e6d7923f5 100644
--- a/docs/reference/gobject/tut_gobject.xml
+++ b/docs/reference/gobject/tut_gobject.xml
@@ -465,12 +465,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 +482,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-&gt;priv-&gt;filename);
@@ -510,7 +510,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-&gt;priv-&gt;filename);