[gnome-software/1723-installed-updates-papercuts: 1/9] gs-app-row: Make show-rating a GObject property




commit 9996f349304ee906c700f708e4a0b88a37fdfeea
Author: Milan Crha <mcrha redhat com>
Date:   Tue Apr 26 10:24:40 2022 +0200

    gs-app-row: Make show-rating a GObject property
    
    Can be better used with GObject bindings, if needed.

 src/gs-app-row.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 4efd5660a..976acc05f 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -66,6 +66,7 @@ typedef enum {
        PROP_SHOW_DESCRIPTION,
        PROP_SHOW_SOURCE,
        PROP_SHOW_BUTTONS,
+       PROP_SHOW_RATING,
        PROP_SHOW_INSTALLED_SIZE,
        PROP_IS_NARROW,
 } GsAppRowProperty;
@@ -644,6 +645,9 @@ gs_app_row_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
        case PROP_SHOW_BUTTONS:
                g_value_set_boolean (value, priv->show_buttons);
                break;
+       case PROP_SHOW_RATING:
+               g_value_set_boolean (value, priv->show_rating);
+               break;
        case PROP_SHOW_INSTALLED_SIZE:
                g_value_set_boolean (value, priv->show_installed_size);
                break;
@@ -674,6 +678,9 @@ gs_app_row_set_property (GObject *object, guint prop_id, const GValue *value, GP
        case PROP_SHOW_BUTTONS:
                gs_app_row_set_show_buttons (app_row, g_value_get_boolean (value));
                break;
+       case PROP_SHOW_RATING:
+               gs_app_row_set_show_rating (app_row, g_value_get_boolean (value));
+               break;
        case PROP_SHOW_INSTALLED_SIZE:
                gs_app_row_set_show_installed_size (app_row, g_value_get_boolean (value));
                break;
@@ -762,6 +769,18 @@ gs_app_row_class_init (GsAppRowClass *klass)
                                      FALSE,
                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+       /**
+        * GsAppRow:show-rating:
+        *
+        * Show app rating in the app row.
+        *
+        * Since: 42.1
+        */
+       obj_props[PROP_SHOW_RATING] =
+               g_param_spec_boolean ("show-rating", NULL, NULL,
+                                     FALSE,
+                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
        /**
         * GsAppRow:show-installed-size:
         *
@@ -887,6 +906,7 @@ gs_app_row_set_show_rating (GsAppRow *app_row, gboolean show_rating)
        GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
 
        priv->show_rating = show_rating;
+       g_object_notify (G_OBJECT (app_row), "show-rating");
        gs_app_row_schedule_refresh (app_row);
 }
 


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