summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2017-01-18 12:14:20 +0100
committerRichard Hughes <richard@hughsie.com>2017-01-18 12:42:24 +0000
commitd2c446bf250b07d8f444531ca527c3edcdec1f13 (patch)
tree8e571f58d045f4e1cf88218676de53deba1b17b5
parent31bc7ef5765f9d54c7d52b93c5f5a6d617eb7ee9 (diff)
downloadappstream-glib-d2c446bf250b07d8f444531ca527c3edcdec1f13.tar.gz
appstream-compose: Support appdata with no desktop files
For instance, this happens for the runtimes
-rw-r--r--client/as-compose.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/client/as-compose.c b/client/as-compose.c
index 979ff9c..4f45f39 100644
--- a/client/as-compose.c
+++ b/client/as-compose.c
@@ -187,20 +187,12 @@ load_desktop (const gchar *prefix,
const gchar *icons_dir,
guint min_icon_size,
const gchar *app_name,
- const gchar *appdata_id,
+ const gchar *desktop_path,
GError **error)
{
AsIcon *icon;
- g_autofree gchar *desktop_basename = NULL;
- g_autofree gchar *desktop_path = NULL;
g_autoptr(AsApp) app = NULL;
- if (appdata_id != NULL)
- desktop_basename = g_strdup (appdata_id);
- else
- desktop_basename = g_strconcat (app_name, ".desktop", NULL);
- desktop_path = g_build_filename (prefix, "share/applications", desktop_basename, NULL);
-
app = as_app_new ();
if (!as_app_parse_file (app, desktop_path,
AS_APP_PARSE_FLAG_USE_HEURISTICS |
@@ -414,6 +406,9 @@ main (int argc, char **argv)
g_auto(GStrv) intl_domains = NULL;
g_autoptr(AsApp) app_appdata = NULL;
g_autoptr(AsApp) app_desktop = NULL;
+ g_autofree gchar *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);
@@ -464,20 +459,29 @@ main (int argc, char **argv)
as_store_add_app (store, app_appdata);
- app_desktop = load_desktop (prefix,
- icons_dir,
- min_icon_size,
- app_name,
- as_app_get_id (app_appdata),
- &error);
- if (app_desktop == NULL) {
- /* TRANSLATORS: the .desktop file could not
- * be loaded */
- g_print ("%s: %s\n", _("Error loading desktop file"),
- error->message);
- return EXIT_FAILURE;
+ appdata_id = as_app_get_id (app_appdata);
+ if (appdata_id != NULL)
+ desktop_basename = g_strdup (appdata_id);
+ else
+ desktop_basename = g_strconcat (app_name, ".desktop", NULL);
+ desktop_path = g_build_filename (prefix, "share/applications", desktop_basename, NULL);
+
+ if (g_file_test (desktop_path, G_FILE_TEST_EXISTS)) {
+ app_desktop = load_desktop (prefix,
+ icons_dir,
+ min_icon_size,
+ app_name,
+ desktop_path,
+ &error);
+ if (app_desktop == NULL) {
+ /* TRANSLATORS: the .desktop file could not
+ * be loaded */
+ g_print ("%s: %s\n", _("Error loading desktop file"),
+ error->message);
+ return EXIT_FAILURE;
+ }
+ as_store_add_app (store, app_desktop);
}
- as_store_add_app (store, app_desktop);
}
/* create output directory */