From f4bd5f611645eb394ac0419d848aba7fda91ccee Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 16 Apr 2018 16:11:21 +0100 Subject: If the launchable is specified don't guess it when composing This allows us to have an appdata file with org.gnome.Gimp without being forced to rename the gimp.desktop file. --- client/as-compose.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client/as-compose.c b/client/as-compose.c index fecc752..512a7f1 100644 --- a/client/as-compose.c +++ b/client/as-compose.c @@ -400,13 +400,13 @@ main (int argc, char **argv) /* load each application specified */ for (i = 1; i < (guint) argc; i++) { + AsLaunchable *launchable; const gchar *app_name = argv[i]; g_auto(GStrv) intl_domains = NULL; g_autoptr(AsApp) app_appdata = NULL; g_autoptr(AsApp) app_desktop = NULL; g_autoptr(GString) desktop_basename = NULL; g_autofree gchar *desktop_path = NULL; - const gchar *appdata_id; /* TRANSLATORS: we're generating the AppStream data */ g_print ("%s %s\n", _("Processing application"), app_name); @@ -458,12 +458,19 @@ main (int argc, char **argv) as_store_add_app (store, app_appdata); /* use the ID from the AppData file if it was found */ - appdata_id = as_app_get_id (app_appdata); - desktop_basename = g_string_new (appdata_id != NULL ? appdata_id : app_name); + launchable = as_app_get_launchable_by_kind (app_appdata, + AS_LAUNCHABLE_KIND_DESKTOP_ID); + if (launchable != NULL) { + desktop_basename = g_string_new (as_launchable_get_value (launchable)); + } else { + const gchar *appdata_id = as_app_get_id (app_appdata); + + /* append the .desktop suffix if using a new-style name */ + desktop_basename = g_string_new (appdata_id != NULL ? appdata_id : app_name); + if (!g_str_has_suffix (desktop_basename->str, ".desktop")) + g_string_append (desktop_basename, ".desktop"); + } - /* append the .desktop suffix if using a new-style name */ - if (!g_str_has_suffix (desktop_basename->str, ".desktop")) - g_string_append (desktop_basename, ".desktop"); desktop_path = g_build_filename (prefix, "share", "applications", desktop_basename->str, NULL); g_debug ("looking for %s", desktop_path); -- cgit v1.2.1