[epiphany] Make about:applications prettier



commit 4bd5ca329c07b8e8b3a2736c77dd862175cdf37b
Author: Xan Lopez <xlopez igalia com>
Date:   Tue Sep 6 19:10:05 2011 +0200

    Make about:applications prettier
    
    Thanks to Lapo Calamandrei for the CSS.

 data/pages/about.css       |   40 ++++++++++++++++++++++++++++++++++++++++
 embed/ephy-request-about.c |   19 +++++++++++--------
 embed/ephy-web-app-utils.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 embed/ephy-web-app-utils.h |    2 ++
 4 files changed, 97 insertions(+), 8 deletions(-)
---
diff --git a/data/pages/about.css b/data/pages/about.css
index af49828..2cb4c58 100644
--- a/data/pages/about.css
+++ b/data/pages/about.css
@@ -78,3 +78,43 @@
     border-top: 1px solidtransparent;
 }
 
+/* about:applications */
+
+.applications-body { 
+	font: 11pt cantarell;
+	color: #2e3436;
+	padding: 20px 20px 0 20px;
+	background-color: #f6f6f4;
+	background-image: -webkit-gradient(
+		linear,
+		left top,
+		left bottom,
+		color-stop(0, #eeeeec),
+		color-stop(1, #f6f6f4)
+	);
+	background-size: 100% 5em;
+	background-repeat: no-repeat;
+}
+
+.applications-body table { width: 100%; border-collapse: collapse; }
+
+.applications-body table, td { 
+	border: 1px solid #d3d7cf;
+	border-left: none; border-right: none;
+}
+
+.applications-body h1 { 
+	color: #babdb6;
+	text-shadow: 0 1px 0 white;
+	margin-bottom: 0;
+}
+
+.applications-body p { margin-bottom: 30px; }
+.applications-body td { padding: 15px 15px;}
+.applications-body td.icon { width: 64px; }
+.applications-body td.datas { width: 200px; }
+.applications-body td.input { width: 64px; }
+.applications-body td.date { width: auto; text-align: right; font-style: italic; font-size: small; }
+.applications-body .appname { font-weight: bold; }
+.applications-body .appurl, td.date { color: #babdb6; }
+.applications-body input { width: 100%; padding: 8px; }
diff --git a/embed/ephy-request-about.c b/embed/ephy-request-about.c
index 1203d1a..e55bfec 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 293ec63..272ca8e 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 06b3284..8326c4a 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-"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]