From 2f2e2ee3d39955bc26fac9781f491d4f426ede18 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 2 May 2018 12:24:18 +0100 Subject: Use the launchable to find the desktop filename when using appstream-builder --- libappstream-builder/plugins/asb-plugin-desktop.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libappstream-builder') diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c index 0249966..a4662e9 100644 --- a/libappstream-builder/plugins/asb-plugin-desktop.c +++ b/libappstream-builder/plugins/asb-plugin-desktop.c @@ -246,19 +246,31 @@ asb_plugin_process_app (AsbPlugin *plugin, const gchar *tmpdir, GError **error) { + AsLaunchable *launchable; gboolean found = FALSE; guint i; + g_autoptr(GString) desktop_basename = NULL; const gchar *app_dirs[] = { "/usr/share/applications", "/usr/share/applications/kde4", NULL }; + /* get the (optional) launchable to get the name of the desktop file */ + launchable = as_app_get_launchable_by_kind (AS_APP (app), AS_LAUNCHABLE_KIND_DESKTOP_ID); + if (launchable != NULL) { + desktop_basename = g_string_new (as_launchable_get_value (launchable)); + } else { + desktop_basename = g_string_new (as_app_get_id (AS_APP (app))); + if (!g_str_has_suffix (desktop_basename->str, ".desktop")) + g_string_append (desktop_basename, ".desktop"); + } + /* use the .desktop file to refine the application */ for (i = 0; app_dirs[i] != NULL; i++) { g_autofree gchar *fn = NULL; fn = g_build_filename (tmpdir, app_dirs[i], - as_app_get_id (AS_APP (app)), + desktop_basename->str, NULL); if (g_file_test (fn, G_FILE_TEST_EXISTS)) { if (!asb_plugin_desktop_refine (plugin, pkg, fn, -- cgit v1.2.1