[gnome-software] trivial: Update the feature tile widget if the app name or summary changes



commit 8d9abb62ce6c8b1ca8b802f1756ee62723f5875d
Author: Richard Hughes <richard hughsie com>
Date:   Thu May 4 16:04:05 2017 +0100

    trivial: Update the feature tile widget if the app name or summary changes

 lib/gs-app.c          |    6 ++++--
 src/gs-feature-tile.c |   23 ++++++++++++++---------
 2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 206827b..e4b938a 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -1138,7 +1138,8 @@ gs_app_set_name (GsApp *app, GsAppQuality quality, const gchar *name)
        if (quality <= app->name_quality)
                return;
        app->name_quality = quality;
-       _g_set_str (&app->name, name);
+       if (_g_set_str (&app->name, name))
+               g_object_notify (G_OBJECT (app), "name");
 }
 
 /**
@@ -1844,7 +1845,8 @@ gs_app_set_summary (GsApp *app, GsAppQuality quality, const gchar *summary)
        if (quality <= app->summary_quality)
                return;
        app->summary_quality = quality;
-       _g_set_str (&app->summary, summary);
+       if (_g_set_str (&app->summary, summary))
+               g_object_notify (G_OBJECT (app), "summary");
 }
 
 /**
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index f5fcadd..2818228 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -52,6 +52,14 @@ app_state_changed_idle (gpointer user_data)
        AtkObject *accessible;
        g_autofree gchar *name = NULL;
 
+       /* update text */
+       gtk_label_set_label (GTK_LABEL (tile->title), gs_app_get_name (tile->app));
+       gtk_label_set_label (GTK_LABEL (tile->subtitle), gs_app_get_summary (tile->app));
+
+       /* perhaps set custom css */
+       gs_utils_widget_set_css_app (tile->app, GTK_WIDGET (tile),
+                                    "GnomeSoftware::FeatureTile-css");
+
        accessible = gtk_widget_get_accessible (GTK_WIDGET (tile));
 
        switch (gs_app_get_state (tile->app)) {
@@ -93,25 +101,22 @@ gs_feature_tile_set_app (GsAppTile *app_tile, GsApp *app)
 
        g_return_if_fail (GS_IS_APP (app) || app == NULL);
 
-       if (tile->app)
+       if (tile->app != NULL)
                g_signal_handlers_disconnect_by_func (tile->app, app_state_changed, tile);
 
        g_set_object (&tile->app, app);
-       if (!app)
+       if (app == NULL)
                return;
 
        gtk_stack_set_visible_child_name (GTK_STACK (tile->stack), "content");
 
        g_signal_connect (tile->app, "notify::state",
                          G_CALLBACK (app_state_changed), tile);
+       g_signal_connect (tile->app, "notify::name",
+                         G_CALLBACK (app_state_changed), tile);
+       g_signal_connect (tile->app, "notify::summary",
+                         G_CALLBACK (app_state_changed), tile);
        app_state_changed (tile->app, NULL, tile);
-
-       gtk_label_set_label (GTK_LABEL (tile->title), gs_app_get_name (app));
-       gtk_label_set_label (GTK_LABEL (tile->subtitle), gs_app_get_summary (app));
-
-       /* perhaps set custom css */
-       gs_utils_widget_set_css_app (app, GTK_WIDGET (tile),
-                                    "GnomeSoftware::FeatureTile-css");
 }
 
 static void


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