[gnome-software] Only return valid results from url_to_app()



commit e6dcb5310533a43852c8f6805a37bf8c5c9a12f1
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 4 10:54:22 2017 +0100

    Only return valid results from url_to_app()
    
    The auto-adding icon code was erroneously copied and pasted from the
    file_to_app() function (where we do need the icon auto-add code, and the
    relaxation of validity) and it was causing blank 'apps' to show up for
    requests like apt://powertop.

 lib/gs-plugin-loader.c          |   24 +-----------------------
 plugins/dummy/gs-plugin-dummy.c |    3 +++
 2 files changed, 4 insertions(+), 23 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 319fbe6..ee222fe 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -4525,32 +4525,10 @@ gs_plugin_loader_url_to_app_thread_cb (GTask *task,
        }
 
        /* filter package list */
+       gs_app_list_filter (job->list, gs_plugin_loader_app_is_valid, job);
        gs_app_list_filter (job->list, gs_plugin_loader_app_set_prio, plugin_loader);
        gs_app_list_filter_duplicates (job->list, GS_APP_LIST_FILTER_FLAG_PRIORITY);
 
-       /* check the apps have an icon set */
-       for (guint j = 0; j < gs_app_list_length (job->list); j++) {
-               GsApp *app = gs_app_list_index (job->list, j);
-               if (_gs_app_get_icon_by_kind (app, AS_ICON_KIND_STOCK) == NULL &&
-                   _gs_app_get_icon_by_kind (app, AS_ICON_KIND_LOCAL) == NULL &&
-                   _gs_app_get_icon_by_kind (app, AS_ICON_KIND_CACHED) == NULL) {
-                       g_autoptr(AsIcon) ic = as_icon_new ();
-                       as_icon_set_kind (ic, AS_ICON_KIND_STOCK);
-                       if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE)
-                               as_icon_set_name (ic, "x-package-repository");
-                       else
-                               as_icon_set_name (ic, "application-x-executable");
-                       gs_app_add_icon (app, ic);
-               }
-       }
-
-       /* run refine() on each one again to pick up any icons */
-       job->refine_flags = GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON;
-       if (!gs_plugin_loader_run_refine (job, job->list, cancellable, &error)) {
-               g_task_return_error (task, error);
-               return;
-       }
-
        /* success */
        if (gs_app_list_length (job->list) != 1) {
                g_task_return_new_error (task,
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index 73f5929..e26dd0b 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -92,6 +92,9 @@ gs_plugin_initialize (GsPlugin *plugin)
        priv->installed_apps = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
        priv->available_apps = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
        g_hash_table_insert (priv->available_apps,
+                            g_strdup ("chiron.desktop"),
+                            GUINT_TO_POINTER (1));
+       g_hash_table_insert (priv->available_apps,
                             g_strdup ("zeus.desktop"),
                             GUINT_TO_POINTER (1));
        g_hash_table_insert (priv->available_apps,


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