[gnome-software] Only set the compulsory quirk for apps in the system AppStream store
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Only set the compulsory quirk for apps in the system AppStream store
- Date: Thu, 27 Sep 2018 15:46:14 +0000 (UTC)
commit 8344b74841ea3d18b0fb8d633c9c748914e60506
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 27 15:13:19 2018 +0100
Only set the compulsory quirk for apps in the system AppStream store
This also means we no longer have to remove the quirk in the flatpak plugin.
plugins/core/gs-appstream.c | 37 --------------------------------
plugins/core/gs-plugin-appstream.c | 43 ++++++++++++++++++++++++++++++++++++++
plugins/flatpak/gs-flatpak.c | 3 ---
3 files changed, 43 insertions(+), 40 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 5af9abad..feac9325 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -479,7 +479,6 @@ gs_appstream_refine_app (GsPlugin *plugin,
GPtrArray *array;
GPtrArray *pkgnames;
GPtrArray *kudos;
- const gchar *current_desktop;
const gchar *tmp;
/* set the kind to be more precise */
@@ -687,42 +686,6 @@ gs_appstream_refine_app (GsPlugin *plugin,
as_app_get_developer_name (item, NULL) != NULL)
gs_app_set_developer_name (app, as_app_get_developer_name (item, NULL));
- /*
- * Set the core applications for the current desktop that cannot be
- * removed.
- *
- * If XDG_CURRENT_DESKTOP contains ":", indicating that it is made up
- * of multiple components per the Desktop Entry Specification, an app
- * is compulsory if any of the components in XDG_CURRENT_DESKTOP match
- * any value in <compulsory_for_desktops />. In that way,
- * "GNOME-Classic:GNOME" shares compulsory apps with GNOME.
- *
- * As a special case, if the <compulsory_for_desktop /> value contains
- * a ":", we match the entire XDG_CURRENT_DESKTOP. This lets people set
- * compulsory apps for such compound desktops if they want.
- *
- */
- array = as_app_get_compulsory_for_desktops (item);
- current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
- if (current_desktop != NULL) {
- g_auto(GStrv) xdg_current_desktops = g_strsplit (current_desktop, ":", 0);
- for (guint i = 0; i < array->len; i++) {
- tmp = g_ptr_array_index (array, i);
- /* if the value has a :, check the whole string */
- if (g_strstr_len (tmp, -1, ":")) {
- if (g_strcmp0 (current_desktop, tmp) == 0) {
- gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
- break;
- }
- /* otherwise check if any element matches this one */
- } else if (g_strv_contains ((const gchar * const *) xdg_current_desktops,
- tmp)) {
- gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
- break;
- }
- }
- }
-
/* set id kind */
if (gs_app_get_kind (app) == AS_APP_KIND_UNKNOWN)
gs_app_set_kind (app, as_app_get_kind (item));
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 90c927f9..16e9b735 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -356,6 +356,48 @@ gs_plugin_url_to_app (GsPlugin *plugin,
return TRUE;
}
+static void
+gs_plugin_appstream_set_compulsory_quirk (GsApp *app, AsApp *item)
+{
+ GPtrArray *array;
+ const gchar *current_desktop;
+
+ /*
+ * Set the core applications for the current desktop that cannot be
+ * removed.
+ *
+ * If XDG_CURRENT_DESKTOP contains ":", indicating that it is made up
+ * of multiple components per the Desktop Entry Specification, an app
+ * is compulsory if any of the components in XDG_CURRENT_DESKTOP match
+ * any value in <compulsory_for_desktops />. In that way,
+ * "GNOME-Classic:GNOME" shares compulsory apps with GNOME.
+ *
+ * As a special case, if the <compulsory_for_desktop /> value contains
+ * a ":", we match the entire XDG_CURRENT_DESKTOP. This lets people set
+ * compulsory apps for such compound desktops if they want.
+ *
+ */
+ array = as_app_get_compulsory_for_desktops (item);
+ current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
+ if (current_desktop != NULL) {
+ g_auto(GStrv) xdg_current_desktops = g_strsplit (current_desktop, ":", 0);
+ for (guint i = 0; i < array->len; i++) {
+ const gchar *tmp = g_ptr_array_index (array, i);
+ /* if the value has a :, check the whole string */
+ if (g_strstr_len (tmp, -1, ":")) {
+ if (g_strcmp0 (current_desktop, tmp) == 0) {
+ gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
+ break;
+ }
+ /* otherwise check if any element matches this one */
+ } else if (g_strv_contains ((const gchar * const *) xdg_current_desktops, tmp)) {
+ gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
+ break;
+ }
+ }
+ }
+}
+
static gboolean
gs_plugin_refine_from_id (GsPlugin *plugin,
GsApp *app,
@@ -396,6 +438,7 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
item = g_ptr_array_index (apps, i);
if (!gs_appstream_refine_app (plugin, app, item, error))
return FALSE;
+ gs_plugin_appstream_set_compulsory_quirk (app, item);
}
}
return TRUE;
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 90526b22..5218e9b9 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1885,9 +1885,6 @@ gs_flatpak_refine_app (GsFlatpak *self,
if (!gs_flatpak_refine_appstream (self, app, error))
return FALSE;
- /* flatpak apps can always be removed */
- gs_app_remove_quirk (app, AS_APP_QUIRK_COMPULSORY);
-
/* AppStream sets the source to appname/arch/branch */
if (!gs_refine_item_metadata (self, app, cancellable, error)) {
g_prefix_error (error, "failed to get metadata: ");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]