[gnome-software/gnome-3-20] Allow popular and featured apps to match any prefix
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-20] Allow popular and featured apps to match any prefix
- Date: Thu, 14 Apr 2016 17:30:15 +0000 (UTC)
commit acbc105d5ca2f3ffe6534e9dc5555de582a55761
Author: Richard Hughes <richard hughsie com>
Date: Wed Mar 23 11:00:38 2016 +0000
Allow popular and featured apps to match any prefix
This allows us to specify the short-form 'foobar.desktop' which would be
matched against the system 'foobar.desktop' AND the prefixed version,
for instance 'xdg-app-user:foobar.desktop'.
src/gs-app.h | 4 ++++
src/plugins/gs-plugin-appstream.c | 8 ++++++++
src/plugins/gs-plugin-dummy.c | 1 +
src/plugins/gs-plugin-hardcoded-featured.c | 1 +
src/plugins/gs-plugin-moduleset.c | 2 ++
5 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.h b/src/gs-app.h
index 62ac991..03b64b4 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -73,6 +73,10 @@ typedef enum {
#define GS_APP_KUDOS_WEIGHT_TO_PERCENTAGE(w) (w * 20)
+#if !AS_CHECK_VERSION(0,5,12)
+#define AS_APP_QUIRK_MATCH_ANY_PREFIX (1 << 3)
+#endif
+
GQuark gs_app_error_quark (void);
GsApp *gs_app_new (const gchar *id);
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index a9bb7b1..4f1696e 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -251,6 +251,14 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
if (id == NULL)
return TRUE;
item = as_store_get_app_by_id (plugin->priv->store, id);
+#if AS_CHECK_VERSION(0,5,12)
+ if (item == NULL &&
+ gs_app_has_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX)) {
+ item = as_store_get_app_by_id_ignore_prefix (plugin->priv->store, id);
+ if (item != NULL)
+ g_debug ("found %s for wildcard %s", as_app_get_id (item), id);
+ }
+#endif
if (item == NULL)
return TRUE;
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index f5a92c1..d6897e9 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -129,6 +129,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
GError **error)
{
g_autoptr(GsApp) app = gs_app_new ("gnome-power-manager");
+ gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Power Manager");
gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "Power Management Program");
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
diff --git a/src/plugins/gs-plugin-hardcoded-featured.c b/src/plugins/gs-plugin-hardcoded-featured.c
index 1f36b54..eb10628 100644
--- a/src/plugins/gs-plugin-hardcoded-featured.c
+++ b/src/plugins/gs-plugin-hardcoded-featured.c
@@ -71,6 +71,7 @@ gs_plugin_add_featured_app (GList **list,
/* add app */
app = gs_app_new (id);
gs_app_add_kudo (app, GS_APP_KUDO_FEATURED_RECOMMENDED);
+ gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
gs_app_set_metadata (app, "Featured::background", background);
gs_app_set_metadata (app, "Featured::stroke-color", stroke_color);
gs_app_set_metadata (app, "Featured::text-color", text_color);
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index c1befe9..b8669e0 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -201,6 +201,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
for (i = 0; apps[i]; i++) {
g_autoptr(GsApp) app = NULL;
app = gs_app_new (apps[i]);
+ gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
gs_plugin_add_app (list, app);
}
}
@@ -263,6 +264,7 @@ gs_plugin_add_popular (GsPlugin *plugin,
for (i = 0; apps[i]; i++) {
g_autoptr(GsApp) app = NULL;
app = gs_app_new (apps[i]);
+ gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
gs_plugin_add_app (list, app);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]