mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 16:38:54 +02:00
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
This commit is contained in:
@@ -465,12 +465,12 @@ ViewerFile *file = g_object_new (VIEWER_TYPE_FILE, NULL);
|
|||||||
/* Implementation */
|
/* Implementation */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
enum
|
typedef enum
|
||||||
{
|
{
|
||||||
PROP_FILENAME = 1,
|
PROP_FILENAME = 1,
|
||||||
PROP_ZOOM_LEVEL,
|
PROP_ZOOM_LEVEL,
|
||||||
N_PROPERTIES
|
N_PROPERTIES
|
||||||
};
|
} ViewerFileProperty;
|
||||||
|
|
||||||
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
|
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ viewer_file_set_property (GObject *object,
|
|||||||
{
|
{
|
||||||
ViewerFile *self = VIEWER_FILE (object);
|
ViewerFile *self = VIEWER_FILE (object);
|
||||||
|
|
||||||
switch (property_id)
|
switch ((ViewerFileProperty) property_id)
|
||||||
{
|
{
|
||||||
case PROP_FILENAME:
|
case PROP_FILENAME:
|
||||||
g_free (self->priv->filename);
|
g_free (self->priv->filename);
|
||||||
@@ -510,7 +510,7 @@ viewer_file_get_property (GObject *object,
|
|||||||
{
|
{
|
||||||
ViewerFile *self = VIEWER_FILE (object);
|
ViewerFile *self = VIEWER_FILE (object);
|
||||||
|
|
||||||
switch (property_id)
|
switch ((ViewerFileProperty) property_id)
|
||||||
{
|
{
|
||||||
case PROP_FILENAME:
|
case PROP_FILENAME:
|
||||||
g_value_set_string (value, self->priv->filename);
|
g_value_set_string (value, self->priv->filename);
|
||||||
|
Reference in New Issue
Block a user