[gnome-software/gnome-3-26] Assign the branch to Flatpak apps coming from installed desktop files
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-26] Assign the branch to Flatpak apps coming from installed desktop files
- Date: Thu, 9 Nov 2017 14:35:37 +0000 (UTC)
commit e880b5808c01e4ad19a04797c6452914ac9cf5e7
Author: Joaquim Rocha <jrocha endlessm com>
Date: Tue May 16 14:39:09 2017 +0200
Assign the branch to Flatpak apps coming from installed desktop files
When an app's non-default branch is installed and the default one isn't,
then the latter will show up as installed because the apps are getting
mixed up.
This is due to merging apps that are created by parsing the installed
desktop files without setting their branch.
These changes set the branch for the mentioned apps which not only fixes
the state for the default branch app in the example mentioned above, but
also show the non-default branch app (as it should be because it is
installed).
plugins/flatpak/gs-flatpak.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 02e2705..4d4ddd0 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -342,6 +342,19 @@ gs_flatpak_add_apps_from_xremote (GsFlatpak *self,
return TRUE;
}
+static gchar *
+gs_flatpak_discard_desktop_suffix (const gchar *app_id)
+{
+ const gchar *desktop_suffix = ".desktop";
+ guint app_prefix_len;
+
+ if (!g_str_has_suffix (app_id, desktop_suffix))
+ return g_strdup (app_id);
+
+ app_prefix_len = strlen (app_id) - strlen (desktop_suffix);
+ return g_strndup (app_id, app_prefix_len);
+}
+
static void
gs_flatpak_rescan_installed (GsFlatpak *self,
GCancellable *cancellable,
@@ -376,6 +389,8 @@ gs_flatpak_rescan_installed (GsFlatpak *self,
g_autoptr(GError) error_local = NULL;
g_autoptr(AsApp) app = NULL;
g_autoptr(AsFormat) format = as_format_new ();
+ g_autoptr(FlatpakInstalledRef) app_ref = NULL;
+ g_autofree gchar *app_id = NULL;
/* ignore */
if (g_strcmp0 (fn, "mimeinfo.cache") == 0)
@@ -409,6 +424,19 @@ gs_flatpak_rescan_installed (GsFlatpak *self,
as_format_set_kind (format, AS_FORMAT_KIND_DESKTOP);
as_format_set_filename (format, fn_desktop);
as_app_add_format (app, format);
+
+ app_id = gs_flatpak_discard_desktop_suffix (fn);
+ app_ref = flatpak_installation_get_current_installed_app (self->installation,
+ app_id,
+ cancellable,
+ &error_local);
+ if (app_ref == NULL) {
+ g_warning ("Could not get app (from ID '%s') for installed desktop "
+ "file %s: %s", app_id, fn_desktop, error_local->message);
+ continue;
+ }
+
+ as_app_set_branch (app, flatpak_ref_get_branch (FLATPAK_REF (app_ref)));
as_app_set_icon_path (app, path_exports);
as_app_add_keyword (app, NULL, "flatpak");
as_store_add_app (self->store, app);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]