[gnome-software] Do not show applications that have an unset name
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Do not show applications that have an unset name
- Date: Thu, 7 Mar 2013 18:02:04 +0000 (UTC)
commit d3c03a9e06bc7f17d671408efd806094dad935d9
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 7 17:58:19 2013 +0000
Do not show applications that have an unset name
This is probably where we have no data, for instance returning a set of popular
applications that we might not have installed.
src/gs-plugin-loader.c | 29 ++++++++++++++++++++++-------
src/gs-self-test.c | 2 +-
2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 4bf9a49..ddcad05 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -135,17 +135,32 @@ out:
}
/**
- * gs_plugin_loader_remove_packages:
+ * gs_plugin_loader_app_is_valid:
+ **/
+static gboolean
+gs_plugin_loader_app_is_valid (GsApp *app)
+{
+ /* don't show unconverted packages in the application view */
+ if (gs_app_get_kind (app) == GS_APP_KIND_PACKAGE)
+ return FALSE;
+ /* don't show apps that do not have a name */
+ if (gs_app_get_name (app) == NULL)
+ return FALSE;
+ return TRUE;
+}
+
+/**
+ * gs_plugin_loader_remove_invalid:
**/
static GList *
-gs_plugin_loader_remove_packages (GList *list)
+gs_plugin_loader_remove_invalid (GList *list)
{
GList *l;
GsApp *app;
for (l = list; l != NULL;) {
app = GS_APP (l->data);
- if (gs_app_get_kind (app) != GS_APP_KIND_PACKAGE) {
+ if (gs_plugin_loader_app_is_valid (app)) {
l = l->next;
continue;
}
@@ -215,7 +230,7 @@ gs_plugin_loader_get_updates (GsPluginLoader *plugin_loader, GError **error)
/* remove any packages that are not proper applications or
* OS updates */
- list = gs_plugin_loader_remove_packages (list);
+ list = gs_plugin_loader_remove_invalid (list);
}
out:
@@ -236,7 +251,7 @@ gs_plugin_loader_get_installed (GsPluginLoader *plugin_loader, GError **error)
list = gs_plugin_loader_run_results (plugin_loader,
"gs_plugin_add_installed",
error);
- list = gs_plugin_loader_remove_packages (list);
+ list = gs_plugin_loader_remove_invalid (list);
if (list == NULL) {
g_set_error (error,
GS_PLUGIN_LOADER_ERROR,
@@ -258,7 +273,7 @@ gs_plugin_loader_get_popular (GsPluginLoader *plugin_loader, GError **error)
list = gs_plugin_loader_run_results (plugin_loader,
"gs_plugin_add_popular",
error);
- list = gs_plugin_loader_remove_packages (list);
+ list = gs_plugin_loader_remove_invalid (list);
if (list == NULL) {
g_set_error (error,
GS_PLUGIN_LOADER_ERROR,
@@ -311,7 +326,7 @@ gs_plugin_loader_search (GsPluginLoader *plugin_loader, const gchar *value, GErr
goto out;
/* success */
- list = gs_plugin_loader_remove_packages (list);
+ list = gs_plugin_loader_remove_invalid (list);
if (list == NULL) {
g_set_error (error,
GS_PLUGIN_LOADER_ERROR,
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 62ab096..5c68215 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -79,7 +79,7 @@ gs_plugin_loader_func (void)
list = gs_plugin_loader_get_popular (loader, &error);
g_assert_no_error (error);
g_assert (list != NULL);
- g_assert_cmpint (g_list_length (list), ==, 7);
+ g_assert_cmpint (g_list_length (list), ==, 6);
app = g_list_nth_data (list, 0);
g_assert_cmpstr (gs_app_get_id (app), ==, "gnome-boxes");
g_assert_cmpstr (gs_app_get_name (app), ==, "Boxes");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]