[gnome-shell/eos3.8: 124/255] shell-app-system: obey X-Flatpak-RenamedFrom
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/eos3.8: 124/255] shell-app-system: obey X-Flatpak-RenamedFrom
- Date: Wed, 10 Jun 2020 19:08:24 +0000 (UTC)
commit c75eff99297bf0da4cb251edbcd33340eef9253f
Author: Will Thompson <wjt endlessm com>
Date: Thu Sep 20 15:46:05 2018 +0100
shell-app-system: obey X-Flatpak-RenamedFrom
To get X-Flatpak-RenamedFrom from the .desktop file, we would like to
call g_key_file_get_string_list(), but GDesktopAppInfo does not expose
its internal GKeyFile, nor provides a get_string_list() wrapper.
GKeyFile does not expose its string-list parser, so we open-code our
own.
An interesting quirk of the GKeyFile format is that lists are (supposed
to be) ;-terminated, not just ;-delimited. This is so you can express an
empty trailing element: "a;;" represents the list ["a", ""].
g_strsplit("a;", ";", -1) returns ["a", ""], so we take care to skip any
empty elements in the returned list.
It is possible to escape a semicolon in a list: "a\;b;" represents ["a;",
"b"]. We cannot support this here, because g_key_file_get_string(), used
internally by g_desktop_app_info_get_string(), rejects the "\;" sequence
and returns NULL.
In practice, .desktop filenames do not contain semicolons (or indeed any
characters more exotic than ASCII alphanumerics, hyphens, underscores
and dots) so this code will be fine. (The alternative would be to
re-parse every .desktop file using GKeyFile directly, fish this field
out, and throw it away again.)
https://phabricator.endlessm.com/T22596
src/shell-app-system.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index d8738dc141..760a13574b 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -33,12 +33,27 @@
*/
#define SHELL_APP_IS_OPEN_EVENT "b5e11a3d-13f8-4219-84fd-c9ba0bf3d1f0"
-/* Additional key used to map a renamed desktop file to its previous name;
- * for instance, org.gnome.Totem.desktop would use this key to point to
- * 'totem.desktop'
+/* Additional key used to map a renamed desktop file to its previous name.
+ * For instance, org.gnome.Totem.desktop contains:
+ *
+ * X-Endless-Alias=totem
+ *
+ * (without the .desktop suffix).
*/
#define X_ENDLESS_ALIAS_KEY "X-Endless-Alias"
+/* Additional key listing 0 or more previous names for an application. This is
+ * added by flatpak-builder when the manifest contains a rename-desktop-file
+ * key, and by Endless-specific tools to migrate from an app in our eos-apps
+ * repository to the same app with a different ID on Flathub. For example,
+ * org.inkscape.Inkscape.desktop contains:
+ *
+ * X-Flatpak-RenamedFrom=inkscape.desktop;
+ *
+ * (with the .desktop suffix).
+ */
+#define X_FLATPAK_RENAMED_FROM_KEY "X-Flatpak-RenamedFrom"
+
/* Vendor prefixes are something that can be preprended to a .desktop
* file name. Undo this.
*/
@@ -126,6 +141,8 @@ add_aliases (ShellAppSystem *self,
ShellAppSystemPrivate *priv = self->priv;
const char *id = g_app_info_get_id (G_APP_INFO (info));
const char *alias;
+ g_autofree char **renamed_from_list = NULL;
+ size_t i;
alias = g_desktop_app_info_get_string (info, X_ENDLESS_ALIAS_KEY);
if (alias != NULL)
@@ -133,6 +150,14 @@ add_aliases (ShellAppSystem *self,
char *desktop_alias = g_strconcat (alias, ".desktop", NULL);
g_hash_table_insert (priv->alias_to_id, desktop_alias, g_strdup (id));
}
+
+ renamed_from_list = g_desktop_app_info_get_string_list (info, X_FLATPAK_RENAMED_FROM_KEY, NULL);
+ for (i = 0; renamed_from_list != NULL && renamed_from_list[i] != NULL; i++)
+ {
+ g_hash_table_insert (priv->alias_to_id,
+ g_steal_pointer (&renamed_from_list[i]),
+ g_strdup (id));
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]