[gnome-software: 2/18] gs-app: Define a typedef for properties




commit bd382b53e0e3c4f484069544fc36fb5006df8e06
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu May 27 18:35:42 2021 +0100

    gs-app: Define a typedef for properties
    
    This allows for `-Wswitch-enum` to catch properties missing from the
    `switch` statements in `get_property()` and `set_property()`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-app.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index b8e14e575..25e4bdde5 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -132,7 +132,7 @@ typedef struct
        GPtrArray               *version_history; /* (element-type AsRelease) (nullable) (owned) */
 } GsAppPrivate;
 
-enum {
+typedef enum {
        PROP_ID = 1,
        PROP_NAME,
        PROP_VERSION,
@@ -152,7 +152,7 @@ enum {
        PROP_IS_UPDATE_DOWNLOADED,
        PROP_URL_MISSING,
        PROP_LAST
-};
+} GsAppProperty;
 
 static GParamSpec *obj_props[PROP_LAST] = { NULL, };
 
@@ -4656,7 +4656,7 @@ gs_app_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *
        GsApp *app = GS_APP (object);
        GsAppPrivate *priv = gs_app_get_instance_private (app);
 
-       switch (prop_id) {
+       switch ((GsAppProperty) prop_id) {
        case PROP_ID:
                g_value_set_string (value, priv->id);
                break;
@@ -4723,7 +4723,7 @@ gs_app_set_property (GObject *object, guint prop_id, const GValue *value, GParam
        GsApp *app = GS_APP (object);
        GsAppPrivate *priv = gs_app_get_instance_private (app);
 
-       switch (prop_id) {
+       switch ((GsAppProperty) prop_id) {
        case PROP_ID:
                gs_app_set_id (app, g_value_get_string (value));
                break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]