[gnome-software] Only get the rating data when required



commit aa04c38c866258d644845320d0ab9c94971ad1f2
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 11 18:00:21 2013 +0100

    Only get the rating data when required
    
    This speeds up startup by about 25ms as we only need the ratings data for the
    details page and for sorting the search results.

 src/gs-plugin.h                       |    1 +
 src/gs-shell-details.c                |    1 +
 src/gs-shell-search.c                 |    3 ++-
 src/gs-star-widget.c                  |    6 ------
 src/plugins/gs-plugin-fedora-tagger.c |    4 ++++
 src/plugins/gs-plugin-local-ratings.c |    4 ++++
 6 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 95449b6..3720faf 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -79,6 +79,7 @@ typedef enum {
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL              = 1 << 2,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION      = 1 << 3,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE             = 1 << 4,
+       GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING           = 1 << 5,
        GS_PLUGIN_REFINE_FLAGS_LAST
 } GsPluginRefineFlags;
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index e26b68e..733ccc6 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -530,6 +530,7 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
        gs_plugin_loader_app_refine_async (priv->plugin_loader, app,
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE |
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE |
+                                          GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
                                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL,
                                           priv->cancellable,
                                           gs_shell_details_app_refine_cb,
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 50c10f7..e6d1155 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -285,7 +285,8 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboole
        /* search for apps */
        gs_plugin_loader_search_async (priv->plugin_loader,
                                       value,
-                                      GS_PLUGIN_REFINE_FLAGS_DEFAULT,
+                                      GS_PLUGIN_REFINE_FLAGS_DEFAULT |
+                                      GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING,
                                       priv->cancellable,
                                       gs_shell_search_get_search_cb,
                                       shell_search);
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index 4dbe271..6f99a55 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -74,12 +74,6 @@ gs_star_widget_refresh (GsStarWidget *star)
 
        priv = gs_star_widget_get_instance_private (star);
 
-       /* not set yet */
-       gtk_widget_set_sensitive (priv->button1, priv->rating != -1);
-       gtk_widget_set_sensitive (priv->button2, priv->rating != -1);
-       gtk_widget_set_sensitive (priv->button3, priv->rating != -1);
-       gtk_widget_set_sensitive (priv->button4, priv->rating != -1);
-
        /* set the dim states correctly */
        gtk_image_set_from_file (GTK_IMAGE (priv->image1),
                                 priv->rating >= rate_to_star[0] ? img : img_dim);
diff --git a/src/plugins/gs-plugin-fedora-tagger.c b/src/plugins/gs-plugin-fedora-tagger.c
index ce09684..5567b12 100644
--- a/src/plugins/gs-plugin-fedora-tagger.c
+++ b/src/plugins/gs-plugin-fedora-tagger.c
@@ -495,6 +495,10 @@ gs_plugin_refine (GsPlugin *plugin,
        gboolean ret = TRUE;
        gint rating;
 
+       /* nothing to do here */
+       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING) == 0)
+               goto out;
+
        /* already loaded */
        if (g_once_init_enter (&plugin->priv->loaded)) {
                ret = gs_plugin_fedora_tagger_load_db (plugin, error);
diff --git a/src/plugins/gs-plugin-local-ratings.c b/src/plugins/gs-plugin-local-ratings.c
index 162c139..be398fb 100644
--- a/src/plugins/gs-plugin-local-ratings.c
+++ b/src/plugins/gs-plugin-local-ratings.c
@@ -212,6 +212,10 @@ gs_plugin_refine (GsPlugin *plugin,
        GList *l;
        GsApp *app;
 
+       /* nothing to do here */
+       if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING) == 0)
+               goto out;
+
        /* already loaded */
        if (g_once_init_enter (&plugin->priv->loaded)) {
                ret = gs_plugin_local_ratings_load_db (plugin, error);


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