[gnome-software] Show the application size in the details page



commit 13e99d322f5ea1495be6f18f078cfc9d45f8b5cf
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 9 16:20:07 2013 +0100

    Show the application size in the details page
    
    This isn't using a test-depsolve but gets us someway there.

 src/gs-app.c                              |   21 +++++++++++++++++++++
 src/gs-app.h                              |    3 +++
 src/gs-plugin.h                           |    1 +
 src/gs-shell-details.c                    |   13 +++++++++++++
 src/plugins/gs-plugin-packagekit-refine.c |   11 ++++++++++-
 5 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 181f4f2..5713f65 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -69,6 +69,7 @@ struct GsAppPrivate
        gchar                   *update_details;
        gchar                   *management_plugin;
        gint                     rating;
+       guint64                  size;
        GsAppKind                kind;
        GsAppState               state;
        GHashTable              *metadata;
@@ -897,6 +898,26 @@ gs_app_set_rating (GsApp *app, gint rating)
 }
 
 /**
+ * gs_app_get_size:
+ */
+guint64
+gs_app_get_size (GsApp *app)
+{
+       g_return_val_if_fail (GS_IS_APP (app), G_MAXUINT64);
+       return app->priv->size;
+}
+
+/**
+ * gs_app_set_size:
+ */
+void
+gs_app_set_size (GsApp *app, guint64 size)
+{
+       g_return_if_fail (GS_IS_APP (app));
+       app->priv->size = size;
+}
+
+/**
  * gs_app_get_metadata_item:
  */
 const gchar *
diff --git a/src/gs-app.h b/src/gs-app.h
index 2f49e48..e28c67a 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -146,6 +146,9 @@ void                 gs_app_set_metadata            (GsApp          *app,
 gint            gs_app_get_rating              (GsApp          *app);
 void            gs_app_set_rating              (GsApp          *app,
                                                 gint            rating);
+guint64                 gs_app_get_size                (GsApp          *app);
+void            gs_app_set_size                (GsApp          *app,
+                                                guint64         size);
 GPtrArray      *gs_app_get_related             (GsApp          *app);
 void            gs_app_add_related             (GsApp          *app,
                                                 GsApp          *app2);
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 48c3e3d..9e302d1 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -78,6 +78,7 @@ typedef enum {
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE          = 1 << 1,
        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_LAST
 } GsPluginRefineFlags;
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index ce5cf4a..c645891 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -225,6 +225,7 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
        GtkWidget *widget2;
        GtkWidget *widget;
        const gchar *tmp;
+       gchar *size;
        guint i;
 
        /* change widgets */
@@ -349,6 +350,17 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_details_version_value"));
        gtk_label_set_label (GTK_LABEL (widget), gs_app_get_version (priv->app));
 
+       /* set the size */
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "label_details_size_value"));
+       if (gs_app_get_size (priv->app) == 0) {
+               /* TRANSLATORS: this is where the licence is not known */
+               gtk_label_set_label (GTK_LABEL (widget), _("Calculating…"));
+       } else {
+               size = g_format_size (gs_app_get_size (priv->app));
+               gtk_label_set_label (GTK_LABEL (widget), size);
+               g_free (size);
+       }
+
        /* FIXME: This isn't ready yet */
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_details_title"));
        gtk_widget_set_visible (widget, FALSE);
@@ -405,6 +417,7 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
        /* get extra details about the 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_URL,
                                           priv->cancellable,
                                           gs_shell_details_app_refine_cb,
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 8aec3bc..cf430e3 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -381,8 +381,9 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
        guint i = 0;
        guint size;
 #if !PK_CHECK_VERSION(0,8,12)
-       gboolean matches;
        gchar *tmp;
+       guint64 size_tmp;
+       gboolean matches;
 #endif
 
        size = g_list_length (list);
@@ -419,6 +420,8 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
                                gs_app_set_licence (app, pk_details_get_license (details));
                        if (gs_app_get_url (app) == NULL)
                                gs_app_set_url (app, pk_details_get_url (details));
+                       if (gs_app_get_size (app) == 0)
+                               gs_app_set_size (app, pk_details_get_size (details));
                        if (gs_app_get_description (app) == NULL &&
                            g_getenv ("GNOME_SOFTWARE_USE_PKG_DESCRIPTIONS") != NULL) {
                                desc = gs_pk_format_desc (pk_details_get_description (details));
@@ -441,6 +444,10 @@ gs_plugin_packagekit_refine_details (GsPlugin *plugin,
                                gs_app_set_licence (app, tmp);
                                g_free (tmp);
                        }
+                       if (gs_app_get_size (app) == 0) {
+                               g_object_get (details, "size", &size_tmp, NULL);
+                               gs_app_set_size (app, size_tmp);
+                       }
                        if (gs_app_get_description (app) == NULL &&
                            g_getenv ("GNOME_SOFTWARE_USE_PKG_DESCRIPTIONS") != NULL) {
                                g_object_get (details, "description", &tmp, NULL);
@@ -481,6 +488,7 @@ gs_plugin_refine_require_details (GsPlugin *plugin,
                app = GS_APP (l->data);
                if (gs_app_get_licence (app) != NULL &&
                    gs_app_get_url (app) != NULL &&
+                   gs_app_get_size (app) != 0 &&
                    (gs_app_get_description (app) != NULL ||
                     g_getenv ("GNOME_SOFTWARE_USE_PKG_DESCRIPTIONS") == NULL))
                        continue;
@@ -579,6 +587,7 @@ gs_plugin_refine (GsPlugin *plugin,
        /* any important details missing? */
        if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE) > 0 ||
            (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL) > 0 ||
+           (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE) > 0 ||
            (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION) > 0) {
                ret = gs_plugin_refine_require_details (plugin,
                                                        list,


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