[gnome-software/mwleeds/hardcoded-pwa-list: 4/10] Treat a download size of 1 as a special value
- From: Phaedrus Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/mwleeds/hardcoded-pwa-list: 4/10] Treat a download size of 1 as a special value
- Date: Mon, 28 Mar 2022 18:28:43 +0000 (UTC)
commit 9c950006a1a73489796ac0a4576f5155fa02f2c0
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 6a30d0aef..0ee272231 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -3526,7 +3526,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
**/
@@ -3548,6 +3549,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]