[epiphany] Make incognito image a resource



commit 2c5a06f84d64cb640645ed5208577787562753f2
Author: William Jon McCann <william jon mccann gmail com>
Date:   Thu Jan 2 14:39:47 2014 -0500

    Make incognito image a resource
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696078

 data/Makefile.am                      |    3 +--
 embed/ephy-about-handler.c            |   19 +++++++++++--------
 src/Makefile.am                       |    1 +
 src/epiphany.gresource.xml            |    1 +
 {data => src/resources}/incognito.png |  Bin 8445 -> 8445 bytes
 5 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 5a1b7d4..e406087 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -54,8 +54,7 @@ $(default_bookmarks_DATA): $(default_bookmarks_in_files) Makefile $(INTLTOOL_MER
 iconsdir = $(pkgdatadir)/icons
 dist_icons_DATA =         \
     missing-thumbnail.png \
-    thumbnail-frame.png   \
-    incognito.png
+    thumbnail-frame.png
 
 searchproviderdir = $(datadir)/gnome-shell/search-providers
 dist_searchprovider_DATA = epiphany-search-provider.ini
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index d3866b9..d04faac 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -419,18 +419,21 @@ static gboolean
 ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
                                      WebKitURISchemeRequest *request)
 {
-  const char *filename;
-  char *img_data = NULL, *img_data_base64 = NULL;
+  GBytes *img_data;
+  char *img_data_base64 = NULL;
   char *data;
-  gsize data_length;
+  GError *error;
 
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_INCOGNITO)
     return FALSE;
 
-  filename = ephy_file ("incognito.png");
-  if (filename) {
-    g_file_get_contents (filename, &img_data, &data_length, NULL);
-    img_data_base64 = g_base64_encode ((guchar*)img_data, data_length);
+  img_data = g_resources_lookup_data ("/org/gnome/epiphany/incognito.png", 0, &error);
+  if (img_data != NULL) {
+    img_data_base64 = g_base64_encode ((guchar*)g_bytes_get_data (img_data, NULL),
+                                       g_bytes_get_size (img_data));
+  } else {
+    g_debug ("%s", error->message);
+    g_error_free (error);
   }
 
   data = g_strdup_printf ("<html>\n"                                   \
@@ -457,7 +460,7 @@ ephy_about_handler_handle_incognito (EphyAboutHandler *handler,
                             "information will be cleared when you close the window."));
 
   g_free (img_data_base64);
-  g_free (img_data);
+  g_bytes_unref (img_data);
 
   ephy_about_handler_finish_request (request, data, -1);
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 579d8af..1cfed7e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -110,6 +110,7 @@ RESOURCE_FILES = \
        resources/cookies-dialog.ui               \
        resources/passwords-dialog.ui             \
        resources/epiphany.css                    \
+       resources/incognito.png                   \
        resources/error.html                      \
        resources/process-crash.html              \
        resources/recovery.html                   \
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
index ba2400b..fff66ff 100644
--- a/src/epiphany.gresource.xml
+++ b/src/epiphany.gresource.xml
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/epiphany">
+    <file>incognito.png</file>
     <file preprocess="xml-stripblanks" compressed="true">epiphany.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">prefs-dialog.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">prefs-lang-dialog.ui</file>


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