[gnome-software/mwleeds/hardcoded-pwa-list: 2/7] Treat a download size of 1 as a special value




commit a73527a4ceb612179ae6b3f41d6c7eed54fcde11
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Thu Mar 10 12:37:04 2022 -0800

    Treat a download size of 1 as a special value
    
    Web apps don't require you to download anything (the icon is already
    downloaded by the time you're looking at the app's details page).
    However we can't just do "gs_app_set_size_download (app, 0)" because 0
    is treated as meaning "size unknown" which shows up in the UI as a
    question mark. So allow plugins to set the download size to 1 byte as a
    way of saying no download is required.

 lib/gs-app.c             | 5 ++++-
 src/gs-app-context-bar.c | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 3e605a209..042c00f89 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -3523,7 +3523,8 @@ gs_app_add_provided_item (GsApp *app, AsProvidedKind kind, const gchar *item)
  *
  * Get the value of #GsApp:size-download.
  *
- * Returns: number of bytes, `0` for unknown, or %GS_APP_SIZE_UNKNOWABLE for invalid
+ * Returns: number of bytes, `0` for unknown, `1` for no download required, or
+ *   %GS_APP_SIZE_UNKNOWABLE for invalid
  *
  * Since: 3.22
  **/
@@ -3545,6 +3546,8 @@ gs_app_get_size_download (GsApp *app)
  * Sets the download size of the application, not including any
  * required runtime.
  *
+ * If @size_download is 1, this is considered to mean no download is required.
+ *
  * Since: 3.22
  **/
 void
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index ea1e8938f..cf2f235e2 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -199,7 +199,8 @@ update_storage_tile (GsAppContextBar *self)
                 * This is displayed in a context tile, so the string should be short. */
                description = g_strdup (_("Size is unknown"));
        } else {
-               lozenge_text = g_format_size (size_bytes);
+               /* Treat 1 byte as meaning "no download needed" */
+               lozenge_text = g_format_size (size_bytes == 1 ? 0 : size_bytes);
        }
 
        gtk_label_set_text (GTK_LABEL (self->tiles[STORAGE_TILE].lozenge_content), lozenge_text);


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