[gnome-software/wip/hughsie/flatpak-to-desktop-or-not: 2/2] Use the recently-added X-Flatpak desktop key to avoid using a heuristic



commit af112d5cc4f04f44970e16859d1b798a6fb30cfe
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 15 12:28:06 2018 +0100

    Use the recently-added X-Flatpak desktop key to avoid using a heuristic

 .gitlab-ci.yml                                        |  1 +
 meson.build                                           |  2 +-
 plugins/flatpak/gs-flatpak.c                          | 19 ++-----------------
 .../files/share/applications/org.test.Chiron.desktop  |  1 +
 4 files changed, 5 insertions(+), 18 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4376c5bc..b1bdc853 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,7 @@ stages:
 before_script:
   # Update and use base build deps
   - dnf update -y && dnf -y install dnf-plugins-core @buildsys-build
+  - dnf install -y 
https://people.freedesktop.org/~hughsient/temp/libappstream-glib-0.7.14-0.641.20181015git.fc29.x86_64.rpm 
https://people.freedesktop.org/~hughsient/temp/libappstream-glib-devel-0.7.14-0.641.20181015git.fc29.x86_64.rpm
   - dnf --enablerepo updates-testing -y builddep gnome-software
   # Some deps may not be sync'd
   - dnf -y install rpm-ostree-devel
diff --git a/meson.build b/meson.build
index dbb7ca63..0a397d64 100644
--- a/meson.build
+++ b/meson.build
@@ -96,7 +96,7 @@ add_project_arguments('-D_GNU_SOURCE', language : 'c')
 
 conf.set('HAVE_LINUX_UNISTD_H', cc.has_header('linux/unistd.h'))
 
-appstream_glib = dependency('appstream-glib', version : '>= 0.7.11')
+appstream_glib = dependency('appstream-glib', version : '>= 0.7.14')
 gdk_pixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.32.0')
 gio_unix = dependency('gio-unix-2.0')
 gmodule = dependency('gmodule-2.0')
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 12595bc6..3e476981 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -348,19 +348,6 @@ 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,
@@ -388,7 +375,6 @@ gs_flatpak_rescan_installed (GsFlatpak *self,
                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)
@@ -423,14 +409,13 @@ gs_flatpak_rescan_installed (GsFlatpak *self,
                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,
+                                                                         as_app_get_id (app),
                                                                          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);
+                                  "file %s: %s", as_app_get_id (app), fn_desktop, error_local->message);
                        continue;
                }
 
diff --git 
a/plugins/flatpak/tests/app-with-runtime/org.test.Chiron/files/share/applications/org.test.Chiron.desktop 
b/plugins/flatpak/tests/app-with-runtime/org.test.Chiron/files/share/applications/org.test.Chiron.desktop
index 2fbdf959..b744766e 100644
--- a/plugins/flatpak/tests/app-with-runtime/org.test.Chiron/files/share/applications/org.test.Chiron.desktop
+++ b/plugins/flatpak/tests/app-with-runtime/org.test.Chiron/files/share/applications/org.test.Chiron.desktop
@@ -4,3 +4,4 @@ Name=Chiron
 Exec=chiron.sh
 Icon=org.test.Chiron
 Keywords=Bingo;
+X-Flatpak=org.test.Chiron


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]