[gnome-software/1476-add-a-way-for-app-developers-to-test-their-metainfo-appdata-files] Apply 7 suggestion(s) to 4 file(s)



commit 024b1131c6e23088b8ec1a8f08826f075c164857
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Nov 29 09:55:31 2021 +0000

    Apply 7 suggestion(s) to 4 file(s)

 lib/gs-appstream.c    |  3 ++-
 src/gs-application.c  |  4 ++--
 src/gs-details-page.c | 18 ++++++++++++++++++
 src/gs-shell.c        | 16 ++++++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index a0272e77b..0b729e34f 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -28,7 +28,8 @@ gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GErr
                                      error))
                return NULL;
 
-       /* never add wildcard apps to the plugin cache */
+       /* never add wildcard apps to the plugin cache, and only add to
+        * the cache if it’s available */
        if (gs_app_has_quirk (app_new, GS_APP_QUIRK_IS_WILDCARD) || plugin == NULL)
                return g_steal_pointer (&app_new);
 
diff --git a/src/gs-application.c b/src/gs-application.c
index 0969428c8..a123e5db1 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -143,8 +143,8 @@ gs_application_init (GsApplication *application)
                { "interaction", '\0', 0, G_OPTION_ARG_STRING, NULL,
                  _("The kind of interaction expected for this action: either "
                    "‘none’, ‘notify’, or ‘full’"), NULL },
-               { "show-appdata", '\0', 0, G_OPTION_ARG_FILENAME, NULL,
-                 _("Show a local appdata file"), _("FILENAME") },
+               { "show-metainfo", '\0', 0, G_OPTION_ARG_FILENAME, NULL,
+                 _("Show a local metainfo or appdata file"), _("FILENAME") },
                { "verbose", '\0', 0, G_OPTION_ARG_NONE, NULL,
                  _("Show verbose debugging information"), NULL },
                { "autoupdate", 0, 0, G_OPTION_ARG_NONE, NULL,
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index ccbef2898..4b05beaa8 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -2579,11 +2579,29 @@ gs_details_page_appdata_thread (GTask *task,
        g_task_return_pointer (task, g_steal_pointer (&app), g_object_unref);
 }
 
+/**
+ * gs_details_page_set_appdata:
+ * @self: a #GsDetailsPage
+ * @file: path to ametainfo file to display
+ *
+ * Load and show the given metainfo @file on the details page.
+ *
+ * The file must be a single metainfo file, not an appstream file
+ * containing multiple components. It will be shown as if it came
+ * from a configured repository. This function is intended to be
+ * used by application developers wanting to test how their metainfo
+ * will appear to users.
+ *
+ * Since: 42
+ */
 void
 gs_details_page_set_appdata (GsDetailsPage *self,
                             GFile *file)
 {
        g_autoptr(GTask) task = NULL;
+
+       g_return_if_fail (GS_IS_DETAILS_PAGE (self));
+       g_return_if_fail (G_IS_FILE (self));
        gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
        g_clear_object (&self->app_local_file);
        g_clear_object (&self->app);
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 710c34bfe..903bae0e1 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -2362,10 +2362,26 @@ gs_shell_show_local_file (GsShell *shell, GFile *file)
        gs_shell_activate (shell);
 }
 
+/**
+ * gs_shell_show_appdata:
+ * @shell: a #GsShell
+ * @file: path to a metainfo file to display
+ *
+ * Open a metainfo file and display it on the details page as if it were
+ * published in a repository configured on the system.
+ *
+ * This is intended for app developers to be able to test their metainfo files
+ * locally.
+ *
+ * Since: 42
+ */
 void
 gs_shell_show_appdata (GsShell *shell, GFile *file)
 {
        g_autoptr(GsApp) app = gs_app_new (NULL);
+
+       g_return_if_fail (GS_IS_SHELL (shell));
+       g_return_if_fail (G_IS_FILE (file));
        save_back_entry (shell);
        gs_app_set_metadata (app, "GnomeSoftware::show-appdata", "1");
        gs_app_set_local_file (app, file);


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