[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 15/331] Only show reviews widgets if a plugin supports it



commit 8165d9385d82f5da7896298b43283c0aacbb8e47
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Jan 15 13:42:59 2016 +1300

    Only show reviews widgets if a plugin supports it

 src/gs-plugin-loader.c |   10 +++++++++-
 src/gs-plugin.h        |    1 +
 src/gs-shell-details.c |    3 +++
 3 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 0ac74ff..b7cb318 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -51,6 +51,7 @@ typedef struct
        guint                    updates_changed_id;
        gboolean                 online; 
 
+       gboolean                 supports_reviews;
        gchar                   **review_auths;
 } GsPluginLoaderPrivate;
 
@@ -2948,7 +2949,14 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
                         "gs_plugin_get_conflicts",
                         (gpointer *) &plugin_conflicts);
 
-       /* Check if this module requires any authorization for reviews */
+       /* Check if this plugin can do reviews */
+       (void) g_module_symbol (module,
+                               "gs_plugin_get_supports_reviews",
+                               (gpointer *) &plugin_supports_reviews);
+       if (plugin_supports_reviews && plugin_supports_reviews (plugin))
+               priv->supports_reviews = TRUE;
+
+       /* Check if this plugin requires any authorization for reviews */
        (void) g_module_symbol (module,
                                "gs_plugin_get_review_auth",
                                (gpointer *) &plugin_review_auth);
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index e4cc0b8..5053189 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -148,6 +148,7 @@ typedef enum {
 
 typedef const gchar    *(*GsPluginGetNameFunc)         (void);
 typedef const gchar    **(*GsPluginGetDepsFunc)        (GsPlugin       *plugin);
+typedef gboolean       *(*GsPluginGetSupportsReviewsFunc)      (GsPlugin       *plugin);
 typedef const gchar    *(*GsPluginGetReviewAuthFunc)   (GsPlugin       *plugin);
 typedef void            (*GsPluginFunc)                (GsPlugin       *plugin);
 typedef gboolean        (*GsPluginSetupFunc)           (GsPlugin       *plugin,
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index e13d67a..5b3a783 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -963,6 +963,9 @@ gs_shell_details_refresh_reviews (GsShellDetails *self)
        GPtrArray *reviews;
        guint i;
 
+       if (!gs_plugin_loader_get_supports_reviews (self->plugin_loader))
+               return;
+
        gs_container_remove_all (GTK_CONTAINER (self->list_box_reviews));
 
        reviews = gs_app_get_reviews (self->app);


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