[gnome-software/wip/kalev/gnome-3-22: 9/96] trivial: Ensure flatpak apps have the same quirks applied as system apps
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/kalev/gnome-3-22: 9/96] trivial: Ensure flatpak apps have the same quirks applied as system apps
- Date: Tue, 7 Mar 2017 16:24:35 +0000 (UTC)
commit 7c2732f42ff70d85ed5873751bec2a3e1628893b
Author: Richard Hughes <richard hughsie com>
Date: Wed Nov 2 09:45:20 2016 +0000
trivial: Ensure flatpak apps have the same quirks applied as system apps
src/plugins/gs-appstream.c | 42 ++++++++++++++++++++++++
src/plugins/gs-appstream.h | 2 +
src/plugins/gs-flatpak.c | 9 +++++
src/plugins/gs-plugin-appstream.c | 65 ++++++++----------------------------
4 files changed, 68 insertions(+), 50 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 5377f3b..cbd2d5d 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -1017,3 +1017,45 @@ gs_appstream_add_featured (GsPlugin *plugin,
}
return TRUE;
}
+
+void
+gs_appstream_add_extra_info (GsPlugin *plugin, AsApp *app)
+{
+ const gchar *tmp;
+
+ /* add more search terms */
+ switch (as_app_get_kind (app)) {
+ case AS_APP_KIND_WEB_APP:
+ case AS_APP_KIND_INPUT_METHOD:
+ tmp = as_app_kind_to_string (as_app_get_kind (app));
+ g_debug ("adding keyword '%s' to %s",
+ tmp, as_app_get_unique_id (app));
+ as_app_add_keyword (app, NULL, tmp);
+ break;
+ default:
+ break;
+ }
+
+ /* fix up these */
+ if (as_app_get_kind (app) == AS_APP_KIND_LOCALIZATION &&
+ g_str_has_prefix (as_app_get_id (app),
+ "org.fedoraproject.LangPack-")) {
+ g_autoptr(AsIcon) icon = NULL;
+
+ /* add icon */
+ icon = as_icon_new ();
+ as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+ as_icon_set_name (icon, "accessories-dictionary-symbolic");
+ as_app_add_icon (app, icon);
+
+ /* add categories */
+ as_app_add_category (app, "Addons");
+ as_app_add_category (app, "Localization");
+ }
+
+ /* fix up drivers with our nonstandard groups */
+ if (as_app_get_kind (app) == AS_APP_KIND_DRIVER) {
+ as_app_add_category (app, "Addons");
+ as_app_add_category (app, "Drivers");
+ }
+}
diff --git a/src/plugins/gs-appstream.h b/src/plugins/gs-appstream.h
index d8651bd..c4c6d98 100644
--- a/src/plugins/gs-appstream.h
+++ b/src/plugins/gs-appstream.h
@@ -63,6 +63,8 @@ gboolean gs_appstream_add_featured (GsPlugin *plugin,
GsAppList *list,
GCancellable *cancellable,
GError **error);
+void gs_appstream_add_extra_info (GsPlugin *plugin,
+ AsApp *app);
G_END_DECLS
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index 9a01081..5a0cf3c 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -2637,6 +2637,12 @@ gs_flatpak_add_featured (GsFlatpak *self,
}
static void
+gs_flatpak_store_app_added_cb (AsStore *store, AsApp *app, GsFlatpak *self)
+{
+ gs_appstream_add_extra_info (self->plugin, app);
+}
+
+static void
gs_flatpak_store_app_removed_cb (AsStore *store, AsApp *app, GsFlatpak *self)
{
g_debug ("AppStream app was removed, doing delete from global cache");
@@ -2670,6 +2676,9 @@ gs_flatpak_init (GsFlatpak *self)
self->broken_remotes = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
self->store = as_store_new ();
+ g_signal_connect (self->store, "app-added",
+ G_CALLBACK (gs_flatpak_store_app_added_cb),
+ self);
g_signal_connect (self->store, "app-removed",
G_CALLBACK (gs_flatpak_store_app_removed_cb),
self);
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 031b222..343ae45 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -133,6 +133,14 @@ gs_plugin_appstream_store_changed_cb (AsStore *store, GsPlugin *plugin)
}
static void
+gs_plugin_appstream_store_app_added_cb (AsStore *store,
+ AsApp *app,
+ GsPlugin *plugin)
+{
+ gs_appstream_add_extra_info (plugin, app);
+}
+
+static void
gs_plugin_appstream_store_app_removed_cb (AsStore *store,
AsApp *app,
GsPlugin *plugin)
@@ -146,6 +154,12 @@ gs_plugin_initialize (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
priv->store = as_store_new ();
+ g_signal_connect (priv->store, "app-added",
+ G_CALLBACK (gs_plugin_appstream_store_app_added_cb),
+ plugin);
+ g_signal_connect (priv->store, "app-removed",
+ G_CALLBACK (gs_plugin_appstream_store_app_removed_cb),
+ plugin);
as_store_set_add_flags (priv->store,
AS_STORE_ADD_FLAG_USE_UNIQUE_ID |
AS_STORE_ADD_FLAG_ONLY_NATIVE_LANGS |
@@ -227,7 +241,6 @@ gboolean
gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
- AsApp *app;
GPtrArray *items;
gboolean ret;
const gchar *tmp;
@@ -282,9 +295,6 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
g_signal_connect (priv->store, "changed",
G_CALLBACK (gs_plugin_appstream_store_changed_cb),
plugin);
- g_signal_connect (priv->store, "app-removed",
- G_CALLBACK (gs_plugin_appstream_store_app_removed_cb),
- plugin);
/* ensure the token cache */
as_store_load_search_cache (priv->store);
@@ -292,7 +302,7 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
/* add search terms for apps not in the main source */
origins = gs_plugin_appstream_get_origins_hash (items);
for (i = 0; i < items->len; i++) {
- app = g_ptr_array_index (items, i);
+ AsApp *app = g_ptr_array_index (items, i);
tmp = as_app_get_origin (app);
if (tmp == NULL || tmp[0] == '\0')
continue;
@@ -304,51 +314,6 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
}
}
- /* add more search terms */
- for (i = 0; i < items->len; i++) {
- app = g_ptr_array_index (items, i);
- switch (as_app_get_kind (app)) {
- case AS_APP_KIND_WEB_APP:
- case AS_APP_KIND_INPUT_METHOD:
- tmp = as_app_kind_to_string (as_app_get_kind (app));
- g_debug ("adding keyword '%s' to %s",
- tmp, as_app_get_unique_id (app));
- as_app_add_keyword (app, NULL, tmp);
- break;
- default:
- break;
- }
- }
-
- /* fix up these */
- for (i = 0; i < items->len; i++) {
- app = g_ptr_array_index (items, i);
- if (as_app_get_kind (app) == AS_APP_KIND_LOCALIZATION &&
- g_str_has_prefix (as_app_get_id (app),
- "org.fedoraproject.LangPack-")) {
- g_autoptr(AsIcon) icon = NULL;
-
- /* add icon */
- icon = as_icon_new ();
- as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
- as_icon_set_name (icon, "accessories-dictionary-symbolic");
- as_app_add_icon (app, icon);
-
- /* add categories */
- as_app_add_category (app, "Addons");
- as_app_add_category (app, "Localization");
- }
- }
-
- /* fix up drivers with our nonstandard groups */
- for (i = 0; i < items->len; i++) {
- app = g_ptr_array_index (items, i);
- if (as_app_get_kind (app) == AS_APP_KIND_DRIVER) {
- as_app_add_category (app, "Addons");
- as_app_add_category (app, "Drivers");
- }
- }
-
/* rely on the store keeping itself updated */
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]