[gnome-software: 3/13] app-row: Add show-description property




commit 54afc29fafe0b78ff4ccde159b2cc6e198ea04e5
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jun 24 12:09:52 2021 +0200

    app-row: Add show-description property
    
    This allows hiding the row's app description.

 src/gs-app-row.c  | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gs-app-row.h  |  3 +++
 src/gs-app-row.ui |  1 +
 3 files changed, 72 insertions(+)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 57675dd6d..8de0dbcae 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -42,6 +42,7 @@ typedef struct
        gboolean         colorful;
        gboolean         show_buttons;
        gboolean         show_rating;
+       gboolean         show_description;
        gboolean         show_source;
        gboolean         show_update;
        gboolean         show_installed_size;
@@ -61,6 +62,7 @@ static guint signals [SIGNAL_LAST] = { 0 };
 
 typedef enum {
        PROP_APP = 1,
+       PROP_SHOW_DESCRIPTION,
        PROP_SHOW_SOURCE,
        PROP_SHOW_BUTTONS,
        PROP_SHOW_INSTALLED_SIZE,
@@ -612,6 +614,9 @@ gs_app_row_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
        case PROP_APP:
                g_value_set_object (value, priv->app);
                break;
+       case PROP_SHOW_DESCRIPTION:
+               g_value_set_boolean (value, gs_app_row_get_show_description (app_row));
+               break;
        case PROP_SHOW_SOURCE:
                g_value_set_boolean (value, priv->show_source);
                break;
@@ -639,6 +644,9 @@ gs_app_row_set_property (GObject *object, guint prop_id, const GValue *value, GP
        case PROP_APP:
                gs_app_row_set_app (app_row, g_value_get_object (value));
                break;
+       case PROP_SHOW_DESCRIPTION:
+               gs_app_row_set_show_description (app_row, g_value_get_boolean (value));
+               break;
        case PROP_SHOW_SOURCE:
                gs_app_row_set_show_source (app_row, g_value_get_boolean (value));
                break;
@@ -697,6 +705,18 @@ gs_app_row_class_init (GsAppRowClass *klass)
                                     GS_TYPE_APP,
                                     G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+       /**
+        * GsAppRow:show-description:
+        *
+        * Show the description of the app in the row.
+        *
+        * Since: 41
+        */
+       obj_props[PROP_SHOW_DESCRIPTION] =
+               g_param_spec_boolean ("show-description", NULL, NULL,
+                                     TRUE,
+                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
        /**
         * GsAppRow:show-source:
         *
@@ -798,6 +818,8 @@ gs_app_row_init (GsAppRow *app_row)
 {
        GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
 
+       priv->show_description = TRUE;
+
        gtk_widget_set_has_window (GTK_WIDGET (app_row), FALSE);
        gtk_widget_init_template (GTK_WIDGET (app_row));
 
@@ -848,6 +870,52 @@ gs_app_row_set_show_rating (GsAppRow *app_row, gboolean show_rating)
        gs_app_row_schedule_refresh (app_row);
 }
 
+/**
+ * gs_app_row_get_show_description:
+ * @app_row: a #GsAppRow
+ *
+ * Get the value of #GsAppRow:show-description.
+ *
+ * Returns: %TRUE if the description is shown, %FALSE otherwise
+ *
+ * Since: 41
+ */
+gboolean
+gs_app_row_get_show_description (GsAppRow *app_row)
+{
+       GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+
+       g_return_val_if_fail (GS_IS_APP_ROW (app_row), FALSE);
+
+       return priv->show_description;
+}
+
+/**
+ * gs_app_row_set_show_description:
+ * @app_row: a #GsAppRow
+ * @show_description: %TRUE to show the description, %FALSE otherwise
+ *
+ * Set the value of #GsAppRow:show-description.
+ *
+ * Since: 41
+ */
+void
+gs_app_row_set_show_description (GsAppRow *app_row, gboolean show_description)
+{
+       GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
+
+       g_return_if_fail (GS_IS_APP_ROW (app_row));
+
+       show_description = !!show_description;
+
+       if (priv->show_description == show_description)
+               return;
+
+       priv->show_description = show_description;
+       g_object_notify_by_pspec (G_OBJECT (app_row), obj_props[PROP_SHOW_DESCRIPTION]);
+       gs_app_row_schedule_refresh (app_row);
+}
+
 void
 gs_app_row_set_show_source (GsAppRow *app_row, gboolean show_source)
 {
diff --git a/src/gs-app-row.h b/src/gs-app-row.h
index 2d486a0c4..df92ebb96 100644
--- a/src/gs-app-row.h
+++ b/src/gs-app-row.h
@@ -34,6 +34,9 @@ void           gs_app_row_set_show_buttons            (GsAppRow       *app_row,
                                                         gboolean        show_buttons);
 void            gs_app_row_set_show_rating             (GsAppRow       *app_row,
                                                         gboolean        show_rating);
+gboolean        gs_app_row_get_show_description        (GsAppRow       *app_row);
+void            gs_app_row_set_show_description        (GsAppRow       *app_row,
+                                                        gboolean        show_description);
 void            gs_app_row_set_show_source             (GsAppRow       *app_row,
                                                         gboolean        show_source);
 void            gs_app_row_set_show_update             (GsAppRow       *app_row,
diff --git a/src/gs-app-row.ui b/src/gs-app-row.ui
index 6f46b22f7..5c2845fb3 100644
--- a/src/gs-app-row.ui
+++ b/src/gs-app-row.ui
@@ -96,6 +96,7 @@
             <property name="valign">center</property>
             <child>
               <object class="GtkLabel" id="description_label">
+                <property name="visible" bind-source="GsAppRow" bind-property="show-description" 
bind-flags="sync-create"/>
                 <property name="visible">True</property>
                 <property name="valign">start</property>
                 <property name="vexpand">True</property>


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