[gnome-software/1927-web-apps-can-t-be-opened-via-show-details-in-the-app-grid: 19/19] webapps: Search for apps by app id




commit 9b2af883522284efe4bffe4ca05d1cadb95f11f9
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 27 16:56:58 2022 +0200

    webapps: Search for apps by app id
    
    The `keywords` list is used to search for an (installed) app, to show
    its details, like from the Activities and the app context menu in the Shell.
    No other plugin knows about installed web apps, thus search for them by
    the app id.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1927

 plugins/epiphany/gs-plugin-epiphany.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 40f465a33..537ed400c 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -784,17 +784,20 @@ list_apps_thread_cb (GTask        *task,
        g_autoptr(GsAppList) list = gs_app_list_new ();
        GsPluginListAppsData *data = task_data;
        GsAppQueryTristate is_installed = GS_APP_QUERY_TRISTATE_UNSET;
+       const gchar * const *keywords = NULL;
        g_autoptr(GError) local_error = NULL;
 
        assert_in_worker (self);
 
        if (data->query != NULL) {
                is_installed = gs_app_query_get_is_installed (data->query);
+               keywords = gs_app_query_get_keywords (data->query);
        }
 
        /* Currently only support a subset of query properties, and only one set at once.
         * Also don’t currently support GS_APP_QUERY_TRISTATE_FALSE. */
-       if (is_installed == GS_APP_QUERY_TRISTATE_UNSET ||
+       if ((is_installed == GS_APP_QUERY_TRISTATE_UNSET &&
+            keywords == NULL) ||
            is_installed == GS_APP_QUERY_TRISTATE_FALSE ||
            gs_app_query_get_n_properties_set (data->query) != 1) {
                g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
@@ -810,6 +813,26 @@ list_apps_thread_cb (GTask        *task,
 
        if (is_installed == GS_APP_QUERY_TRISTATE_TRUE)
                gs_plugin_cache_lookup_by_state (GS_PLUGIN (self), list, GS_APP_STATE_INSTALLED);
+       else if (keywords != NULL) {
+               for (gsize i = 0; keywords[i]; i++) {
+                       GHashTableIter iter;
+                       gpointer key, value;
+                       g_hash_table_iter_init (&iter, self->url_id_map);
+                       while (g_hash_table_iter_next (&iter, &key, &value)) {
+                               const gchar *url = key;
+                               const gchar *app_id = value;
+                               if (g_strcmp0 (app_id, keywords[i]) == 0) {
+                                       g_autoptr(GsApp) app = NULL;
+                                       g_autofree gchar *metainfo_app_id = NULL;
+                                       metainfo_app_id = generate_app_id_for_url (url);
+                                       app = gs_plugin_cache_lookup (GS_PLUGIN (self), metainfo_app_id);
+                                       if (app != NULL)
+                                               gs_app_list_add (list, app);
+                                       break;
+                               }
+                       }
+               }
+       }
 
        g_task_return_pointer (task, g_steal_pointer (&list), g_object_unref);
 }


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