diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2013-03-29 00:06:47 +0800 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2013-04-05 21:47:37 +0800 |
commit | a2181b928e5a0f6d27487859fe86a276c1eed25c (patch) | |
tree | 9a4915e37cb5f7f75ff686c8936bc34b47ea481c /embed | |
parent | efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6 (diff) | |
download | gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar.gz gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar.bz2 gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar.lz gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar.xz gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.tar.zst gsoc2013-epiphany-a2181b928e5a0f6d27487859fe86a276c1eed25c.zip |
Compile template pages as GResources
So that they are loaded from memory instead of disk every time they are
needed.
We also get rid of ephy_file searching for the files in the file system.
https://bugzilla.gnome.org/show_bug.cgi?id=696792
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-web-view.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index ce0312ad1..92cdb3896 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -63,6 +63,10 @@ #define MAX_TITLE_LENGTH 512 /* characters */ #define EMPTY_PAGE _("Blank page") /* Title for the empty page */ +#define EPHY_PAGE_TEMPLATE_ERROR "/org/gnome/epiphany/page-templates/error.html" +#define EPHY_PAGE_TEMPLATE_RECOVERY "/org/gnome/epiphany/page-templates/recovery.html" +#define EPHY_PAGE_TEMPLATE_PROCESS_CRASH "/org/gnome/epiphany/page-templates/process-crash.html" + struct _EphyWebViewPrivate { EphyWebViewSecurityLevel security_level; EphyWebViewDocumentType document_type; @@ -1699,22 +1703,17 @@ ephy_web_view_load_error_page (EphyWebView *view, { GString *html = g_string_new (""); const char *reason; - char *hostname; char *lang; - char *page_title; char *msg_title; char *msg; char *button_label; - const char *html_file; + GBytes *html_file; const char *stock_icon; - GtkIconInfo *icon_info; char *image_data; - char *template; - if (error) reason = error->message; else @@ -1741,7 +1740,7 @@ ephy_web_view_load_error_page (EphyWebView *view, button_label = g_strdup (_("Try again")); - html_file = ephy_file ("error.html"); + html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_ERROR, 0, NULL); stock_icon = "dialog-error"; break; case EPHY_WEB_VIEW_ERROR_PAGE_CRASH: @@ -1759,7 +1758,7 @@ ephy_web_view_load_error_page (EphyWebView *view, button_label = g_strdup (_("Load again anyway")); - html_file = ephy_file ("recovery.html"); + html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_RECOVERY, 0, NULL); stock_icon = "dialog-information"; break; case EPHY_WEB_VIEW_ERROR_PROCESS_CRASH: @@ -1768,7 +1767,7 @@ ephy_web_view_load_error_page (EphyWebView *view, msg = g_strdup (_("Something went wrong while displaying this page. Please reload or visit a different page to continue.")); button_label = NULL; - html_file = ephy_file ("process_crash.html"); + html_file = g_resources_lookup_data (EPHY_PAGE_TEMPLATE_PROCESS_CRASH, 0, NULL); stock_icon = "computer-fail-symbolic"; break; @@ -1785,13 +1784,12 @@ ephy_web_view_load_error_page (EphyWebView *view, 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); - ephy_web_view_set_title (view, page_title); _ephy_web_view_update_icon (view); - g_string_printf (html, template, + g_string_printf (html, + g_bytes_get_data (html_file, NULL), lang, lang, ((gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) ? "rtl" : "ltr"), page_title, @@ -1799,7 +1797,7 @@ ephy_web_view_load_error_page (EphyWebView *view, image_data ? image_data : "", msg_title, msg, button_label); - g_free (template); + g_bytes_unref (html_file); g_free (lang); g_free (page_title); g_free (msg_title); |