[gnome-software/1005-add-option-for-packaging-format-preference] gs-app: Introduce gs_app_get_packaging_format_raw()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1005-add-option-for-packaging-format-preference] gs-app: Introduce gs_app_get_packaging_format_raw()
- Date: Tue, 27 Jul 2021 10:35:34 +0000 (UTC)
commit 0095aa37ea78ab9e6c416a21826e2f91a3c5eacd
Author: Milan Crha <mcrha redhat com>
Date: Tue Jul 27 12:32:01 2021 +0200
gs-app: Introduce gs_app_get_packaging_format_raw()
It returns a raw value, suitable for machine processing, in contract
to the gs_app_get_packaging_format(), which returns a value suitable
for the UI.
lib/gs-app.c | 25 +++++++++++++++++++++++++
lib/gs-app.h | 1 +
2 files changed, 26 insertions(+)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index ce334de38..22b9cb98d 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -5441,6 +5441,31 @@ gs_app_get_packaging_format (GsApp *app)
return g_strdup (bundle_kind_ui);
}
+/**
+ * gs_app_get_packaging_format_raw:
+ * @app: a #GsApp
+ *
+ * Similar to gs_app_get_packaging_format(), but it does not return a newly
+ * allocated string and the value is not suitable for the UI.
+ *
+ * Returns: The raw value of the packaging format
+ *
+ * Since: 41
+ **/
+const gchar *
+gs_app_get_packaging_format_raw (GsApp *app)
+{
+ const gchar *packaging_format;
+
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+
+ packaging_format = gs_app_get_metadata_item (app, "GnomeSoftware::PackagingFormat");
+ if (packaging_format != NULL)
+ return packaging_format;
+
+ return as_bundle_kind_to_string (gs_app_get_bundle_kind (app));
+}
+
/**
* gs_app_subsume_metadata:
* @app: a #GsApp
diff --git a/lib/gs-app.h b/lib/gs-app.h
index 935344ea2..87c07df98 100644
--- a/lib/gs-app.h
+++ b/lib/gs-app.h
@@ -467,6 +467,7 @@ gchar *gs_app_get_origin_ui (GsApp *app);
void gs_app_set_origin_ui (GsApp *app,
const gchar *origin_ui);
gchar *gs_app_get_packaging_format (GsApp *app);
+const gchar *gs_app_get_packaging_format_raw(GsApp *app);
void gs_app_subsume_metadata (GsApp *app,
GsApp *donor);
GsAppPermissions gs_app_get_permissions (GsApp *app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]