aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-05-29 20:30:49 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-14 19:41:42 +0800
commit2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc (patch)
tree774eb65bf0e127118de737852843967d5e3d01f7 /embed
parent8e096384a3e15ba1b68235045c6148a8af29cedb (diff)
downloadgsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar.gz
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar.bz2
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar.lz
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar.xz
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.tar.zst
gsoc2013-epiphany-2b5cfe828cef29dd20225540fdd2bf5fcbf6b8fc.zip
e-file-helpers: Add ephy_file_create_data_uri_for_filename()
It creates a data URI for the given filename. Use the new function when building error and applications pages. https://bugzilla.gnome.org/show_bug.cgi?id=677025
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-request-about.c16
-rw-r--r--embed/ephy-web-view.c33
2 files changed, 8 insertions, 41 deletions
diff --git a/embed/ephy-request-about.c b/embed/ephy-request-about.c
index e239c1123..bfff22f95 100644
--- a/embed/ephy-request-about.c
+++ b/embed/ephy-request-about.c
@@ -182,19 +182,17 @@ ephy_request_about_send (SoupRequest *request,
applications = ephy_web_application_get_application_list ();
for (p = applications; p; p = p->next) {
- char *img_data = NULL, *img_data_base64 = NULL;
- gsize data_length;
+ char *icon_uri;
EphyWebApplication *app = (EphyWebApplication*)p->data;
-
- 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 class=\"icon\"><img width=64 height=64 src=\"data:image/png;base64,%s\">" \
+
+ icon_uri = ephy_file_create_data_uri_for_filename (app->icon_url, "image/png");
+ g_string_append_printf (data_str, "<tbody><tr><td class=\"icon\"><img width=64 height=64 src=\"%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,
+ icon_uri ? icon_uri : "",
+ app->name, app->url, app->name,
/* Note for translators: this refers to the installation date. */
_("Installed on:"), app->install_date);
- g_free (img_data_base64);
- g_free (img_data);
+ g_free (icon_uri);
}
g_string_append (data_str, "</form></table></body>");
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index f0b3d8f94..e4ae30f09 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2052,37 +2052,6 @@ load_status_cb (WebKitWebView *web_view,
g_object_thaw_notify (object);
}
-static char *
-get_file_content_as_base64 (const char *path)
-{
- GFile *file;
- GFileInfo *file_info;
- const char *image_type;
- char *image_raw;
- gsize len;
- char *image_data;
- char *image64;
-
- file = g_file_new_for_path (path);
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- NULL, NULL);
- image_type = g_file_info_get_content_type (file_info);
-
- g_file_get_contents (path, &image_raw, &len, NULL);
- image_data = g_base64_encode ((guchar *) image_raw, len);
- image64 = g_strdup_printf ("data:%s;base64,%s", image_type, image_data);
-
- g_free (image_raw);
- g_free (image_data);
-
- g_object_unref (file);
- g_object_unref (file_info);
-
- return image64;
-}
-
/**
* ephy_web_view_load_error_page:
* @view: an #EphyWebView
@@ -2175,7 +2144,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
48,
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- image_data = icon_info ? get_file_content_as_base64 (gtk_icon_info_get_filename (icon_info)) : NULL;
+ image_data = icon_info ? ephy_file_create_data_uri_for_filename (gtk_icon_info_get_filename (icon_info), NULL) : NULL;
g_file_get_contents (html_file, &template, NULL, NULL);