[epiphany] Move mime-types-permissions to gresource
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Move mime-types-permissions to gresource
- Date: Mon, 17 Oct 2016 19:55:07 +0000 (UTC)
commit e4dba3b223fb1b52fd27539b2223b151e4402c20
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Oct 17 14:53:18 2016 -0500
Move mime-types-permissions to gresource
And get rid of ephy_file()
data/Makefile.am | 3 -
lib/ephy-file-helpers.c | 62 +++-----------------
lib/ephy-file-helpers.h | 1 -
src/Makefile.am | 1 +
src/resources/epiphany.gresource.xml | 1 +
{data => src/resources}/mime-types-permissions.xml | 0
6 files changed, 10 insertions(+), 58 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 0396bb6..61cfc4b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -20,9 +20,6 @@ appstream_XML = $(appstream_in_files:.xml.in=.xml)
$(appstream_XML): $(appstream_in_files)
$(AM_V_GEN) $(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
-mimepermissiondir = $(pkgdatadir)
-dist_mimepermission_DATA = mime-types-permissions.xml
-
# Dbus service file
servicedir = $(datadir)/dbus-1/services
service_in_files = org.gnome.Epiphany.service.in
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index ebb053a..2761f23 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -55,6 +55,8 @@
#define DELAY_MAX_TICKS 64
#define INITIAL_TICKS 2
+#define EPHY_MIME_TYPE_PERMISSIONS_URI "/org/gnome/epiphany/mime-types-permissions.xml"
+
static GHashTable *files = NULL;
static GHashTable *mime_table = NULL;
@@ -205,52 +207,6 @@ ephy_file_tmp_filename (const char *base,
}
/**
- * ephy_file:
- * @filename: the name of the Epiphany file requested
- *
- * Looks for @filename in Epiphany's directories and relevant paths.
- *
- * Returns: the full path to the requested file
- **/
-const char *
-ephy_file (const char *filename)
-{
- char *ret;
- guint i;
-
- static const char * const paths[] =
- {
-#ifndef NDEBUG
- TOP_SRC_DATADIR "/",
- TOP_SRC_DATADIR "/icons/",
- TOP_SRC_DATADIR "/pages/",
-#endif
- PKGDATADIR "/",
- PKGDATADIR "/icons/",
- PKGDATADIR "/pages/"
- };
-
- g_assert (files != NULL);
-
- ret = g_hash_table_lookup (files, filename);
- if (ret != NULL)
- return ret;
-
- for (i = 0; i < G_N_ELEMENTS (paths); i++) {
- ret = g_strconcat (paths[i], filename, NULL);
- if (g_file_test (ret, G_FILE_TEST_EXISTS) == TRUE) {
- g_hash_table_insert (files, g_strdup (filename), ret);
- return (const char *)ret;
- }
- g_free (ret);
- }
-
- g_warning ("Failed to find %s\n", filename);
-
- return NULL;
-}
-
-/**
* ephy_dot_dir:
*
* Gets Epiphany's configuration directory, usually .config/epiphany
@@ -551,8 +507,9 @@ static void
load_mime_from_xml (void)
{
xmlTextReaderPtr reader;
- const char *xml_file;
+ const xmlChar *xml_file;
int ret;
+ GBytes *bytes;
EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN;
g_return_if_fail (mime_table == NULL);
@@ -560,13 +517,9 @@ load_mime_from_xml (void)
mime_table = g_hash_table_new_full (g_str_hash, g_str_equal,
xmlFree, NULL);
- xml_file = ephy_file ("mime-types-permissions.xml");
- if (xml_file == NULL) {
- g_warning ("MIME types permissions file not found!\n");
- return;
- }
-
- reader = xmlNewTextReaderFilename (xml_file);
+ bytes = g_resources_lookup_data (EPHY_MIME_TYPE_PERMISSIONS_URI, 0, NULL);
+ xml_file = (xmlChar *)g_bytes_get_data (bytes, NULL);
+ reader = xmlReaderForDoc (xml_file, EPHY_MIME_TYPE_PERMISSIONS_URI, NULL, 0);
if (reader == NULL) {
g_warning ("Could not load MIME types permissions file!\n");
return;
@@ -596,6 +549,7 @@ load_mime_from_xml (void)
}
xmlFreeTextReader (reader);
+ g_object_unref (bytes);
}
/**
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index 4c572b1..11b8fe1 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -50,7 +50,6 @@ typedef enum
gboolean ephy_file_helpers_init (const char *profile_dir,
EphyFileHelpersFlags flags,
GError **error);
-const char * ephy_file (const char *filename);
const char * ephy_dot_dir (void);
gboolean ephy_dot_dir_is_default (void);
char * ephy_default_dot_dir (void);
diff --git a/src/Makefile.am b/src/Makefile.am
index 00e6692..a32b946 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -145,6 +145,7 @@ RESOURCE_FILES = \
resources/gtk/page-menu-popover.ui \
resources/history-dialog.ui \
resources/incognito.png \
+ resources/mime-types-permissions.xml \
resources/missing-thumbnail.png \
resources/passwords-dialog.ui \
resources/prefs-dialog.ui \
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 37f2029..8edcf2b 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -13,6 +13,7 @@
<file alias="page-templates/about.css" compressed="true">about.css</file>
<file alias="page-templates/error.css" compressed="true">error.css</file>
<file alias="page-templates/error.html" compressed="true">error.html</file>
+ <file preprocess="xml-stripblanks" compressed="true">mime-types-permissions.xml</file>
<file preprocess="xml-stripblanks" compressed="true">clear-data-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">cookies-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">encoding-dialog.ui</file>
diff --git a/data/mime-types-permissions.xml b/src/resources/mime-types-permissions.xml
similarity index 100%
rename from data/mime-types-permissions.xml
rename to src/resources/mime-types-permissions.xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]