diff options
Diffstat (limited to 'embed/ephy-web-app-utils.c')
-rw-r--r-- | embed/ephy-web-app-utils.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/embed/ephy-web-app-utils.c b/embed/ephy-web-app-utils.c index 293ec6318..272ca8e6f 100644 --- a/embed/ephy-web-app-utils.c +++ b/embed/ephy-web-app-utils.c @@ -301,14 +301,57 @@ ephy_web_application_get_application_list () name = g_file_info_get_name (info); if (g_str_has_prefix (name, EPHY_WEB_APP_PREFIX)) { char *profile_dir; + guint64 created; + GDate *date; + char *desktop_file, *desktop_file_path; + char *contents; + GFile *file; + GFileInfo *desktop_info; app = g_slice_new0 (EphyWebApplication); app->name = g_strdup (name + prefix_length); profile_dir = ephy_web_application_get_profile_directory (app->name); app->icon_url = g_build_filename (profile_dir, "app-icon.png", NULL); + + desktop_file = g_strconcat (app->name, ".desktop", NULL); + desktop_file_path = g_build_filename (profile_dir, desktop_file, NULL); + if (g_file_get_contents (desktop_file_path, &contents, NULL, NULL)) { + char *exec; + char **strings; + GKeyFile *key; + int i; + + key = g_key_file_new (); + g_key_file_load_from_data (key, contents, -1, 0, NULL); + exec = g_key_file_get_string (key, "Desktop Entry", "Exec", NULL); + strings = g_strsplit (exec, " ", -1); + + for (i = 0; strings[i]; i++); + app->url = g_strdup (strings[i - 1]); + + g_strfreev (strings); + g_free (exec); + g_key_file_free (key); + } + + g_free (contents); + g_free (desktop_file); g_free (profile_dir); + file = g_file_new_for_path (desktop_file_path); + g_free (desktop_file_path); + + /* FIXME: this should use TIME_CREATED but it does not seem to be working. */ + desktop_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL); + created = g_file_info_get_attribute_uint64 (desktop_info, G_FILE_ATTRIBUTE_TIME_MODIFIED); + date = g_date_new (); + g_date_set_time_t (date, (time_t)created); + g_date_strftime (app->install_date, 127, "%x", date); + g_date_free (date); + g_object_unref (file); + g_object_unref (desktop_info); + applications = g_list_append (applications, app); } @@ -328,6 +371,7 @@ ephy_web_application_free (EphyWebApplication *app) { g_free (app->name); g_free (app->icon_url); + g_free (app->url); g_slice_free (EphyWebApplication, app); } |