diff options
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-request-about.c | 19 | ||||
-rw-r--r-- | embed/ephy-web-app-utils.c | 44 | ||||
-rw-r--r-- | embed/ephy-web-app-utils.h | 2 |
3 files changed, 57 insertions, 8 deletions
diff --git a/embed/ephy-request-about.c b/embed/ephy-request-about.c index 1203d1a7e..e55bfec4c 100644 --- a/embed/ephy-request-about.c +++ b/embed/ephy-request-about.c @@ -166,12 +166,15 @@ ephy_request_about_send (SoupRequest *request, g_string_append_printf (data_str, "<head><title>%s</title>" \ "<style type=\"text/css\">%s</style></head>" \ - "<body>", - _("Web Applications"), - about->priv->css_style); + "<body class=\"applications-body\"><h1>%s</h1>" \ + "<p>%s</p>", + _("Applications"), + about->priv->css_style, + _("Applications"), + _("List of installed web applications")); + - g_string_append_printf (data_str, "<form><table><thead><tr><th>%s</th><th>%s</th><th>%s</th></tr></thead>", - _("Icon"), _("Name"), _("Delete?")); + g_string_append (data_str, "<form><table>"); applications = ephy_web_application_get_application_list (); for (p = applications; p; p = p->next) { @@ -181,9 +184,9 @@ ephy_request_about_send (SoupRequest *request, if (g_file_get_contents (app->icon_url, &img_data, &data_length, NULL)) img_data_base64 = g_base64_encode ((guchar*)img_data, data_length); - g_string_append_printf (data_str, "<tbody><tr><td><img width=64 height=64 src=\"data:image/png;base64,%s\">" \ - " </img></td><td>%s</td><td><input type=\"submit\" value=\"Delete\" id=\"%s\"></td></tr>", - img_data_base64, app->name, app->name); + g_string_append_printf (data_str, "<tbody><tr><td class=\"icon\"><img width=64 height=64 src=\"data:image/png;base64,%s\">" \ + " </img></td><td class=\"data\"><div class=\"appname\">%s</div><div class=\"appurl\">%s</div></td><td class=\"input\"><input type=\"submit\" value=\"Delete\" id=\"%s\"></td><td class=\"date\">%s <br /> %s</td></tr>", + img_data_base64, app->name, app->url, app->name, _("Installed on:"), app->install_date); g_free (img_data_base64); g_free (img_data); } 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); } diff --git a/embed/ephy-web-app-utils.h b/embed/ephy-web-app-utils.h index 06b3284ad..8326c4a10 100644 --- a/embed/ephy-web-app-utils.h +++ b/embed/ephy-web-app-utils.h @@ -34,6 +34,8 @@ G_BEGIN_DECLS typedef struct { char *name; char *icon_url; + char *url; + char install_date[128]; } EphyWebApplication; #define EPHY_WEB_APP_PREFIX "app-" |