[gnome-software/wip/mcrha/show-metainfo-enh: 6/7] show-metainfo: Allow defining also path for the icon to be used
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/show-metainfo-enh: 6/7] show-metainfo: Allow defining also path for the icon to be used
- Date: Wed, 26 Jan 2022 10:14:12 +0000 (UTC)
commit 0805d9dcb90e676d84e1cbf7f1014925c84197c1
Author: Milan Crha <mcrha redhat com>
Date: Fri Jan 21 12:59:57 2022 +0100
show-metainfo: Allow defining also path for the icon to be used
The passed-in metainfo is shown in the Details page, but without an icon.
By passing in the icon it can be seen more accurately what the app
will look like in the Software.
To specify the icon append a comma-separated argument "icon=" to
the path. An example:
gnome-software --show-metainfo=/path/to/app.metainfo.xml,icon=/path/to/icon.png
src/gs-details-page.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 54bbb2052..fffb8d2c4 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -2450,15 +2450,32 @@ gs_details_page_metainfo_thread (GTask *task,
const gchar *const *locales;
g_autofree gchar *xml = NULL;
g_autofree gchar *path = NULL;
+ g_autofree gchar *icon_path = NULL;
g_autoptr(XbBuilder) builder = NULL;
g_autoptr(XbBuilderSource) builder_source = NULL;
g_autoptr(XbSilo) silo = NULL;
g_autoptr(GPtrArray) nodes = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GsApp) app = NULL;
+ g_autoptr(GFile) tmp_file = NULL;
GFile *file = task_data;
XbNode *component;
+ path = g_file_get_path (file);
+ if (path && strstr (path, ",icon=")) {
+ gchar *pos = strstr (path, ",icon=");
+
+ *pos = '\0';
+
+ tmp_file = g_file_new_for_path (path);
+ file = tmp_file;
+
+ pos += 6;
+ if (*pos)
+ icon_path = g_strdup (pos);
+ }
+ g_clear_pointer (&path, g_free);
+
builder_source = xb_builder_source_new ();
if (!xb_builder_source_load_file (builder_source, file, XB_BUILDER_SOURCE_FLAG_NONE, cancellable,
&error)) {
g_task_return_error (task, g_steal_pointer (&error));
@@ -2512,6 +2529,13 @@ gs_details_page_metainfo_thread (GTask *task,
path = g_file_get_path (file);
gs_app_set_origin (app, path);
+ if (icon_path) {
+ g_autoptr(GFile) icon_file = g_file_new_for_path (icon_path);
+ g_autoptr(GIcon) icon = g_file_icon_new (icon_file);
+ gs_icon_set_width (icon, (guint) -1);
+ gs_app_add_icon (app, G_ICON (icon));
+ }
+
gs_app_set_state (app, GS_APP_STATE_UNKNOWN);
g_task_return_pointer (task, g_steal_pointer (&app), g_object_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]