aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-03-27 19:31:56 +0800
committerXan Lopez <xan@igalia.com>2012-03-28 03:42:41 +0800
commit98e31b7886bad0eae162ec7c6513a1d20f306727 (patch)
tree714c4d1d1341f9947ce9d12168a55f6609ce1a42 /src
parentd892edb5d13028c4d150acba9edf3792eb000194 (diff)
downloadgsoc2013-epiphany-98e31b7886bad0eae162ec7c6513a1d20f306727.tar.gz
gsoc2013-epiphany-98e31b7886bad0eae162ec7c6513a1d20f306727.tar.zst
gsoc2013-epiphany-98e31b7886bad0eae162ec7c6513a1d20f306727.zip
Use glib resources to bundle our UI files
https://bugzilla.gnome.org/show_bug.cgi?id=672907
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am25
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c6
-rw-r--r--src/ephy-encoding-dialog.c2
-rw-r--r--src/ephy-history-window.c6
-rw-r--r--src/ephy-shell.c6
-rw-r--r--src/ephy-window.c43
-rw-r--r--src/epiphany.gresource.xml12
-rw-r--r--src/pdm-dialog.c4
-rw-r--r--src/prefs-dialog.c4
9 files changed, 80 insertions, 28 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0d75a298c..d9cb01db3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,9 @@ noinst_LTLIBRARIES = libephymain.la
bin_PROGRAMS = epiphany
-EXTRA_DIST =
+EXTRA_DIST = \
+ epiphany.gresource.xml \
+ $(NULL)
headerdir = $(prefix)/include/epiphany/$(EPIPHANY_MAJOR)/epiphany
header_DATA = \
@@ -106,8 +108,21 @@ libephymain_la_CFLAGS = \
$(WEBKIT_CFLAGS) \
$(AM_CFLAGS)
-BUILT_SOURCES = \
- $(TYPES_SOURCE)
+epiphany-resources.c: epiphany.gresource.xml
+ glib-compile-resources --target=$@ --sourcedir=$(top_srcdir)/data/ui --generate-source --c-name epiphany $(srcdir)/epiphany.gresource.xml
+
+epiphany-resources.h: epiphany.gresource.xml
+ glib-compile-resources --target=$@ --sourcedir=$(top_srcdir)/data/ui --generate-header --c-name epiphany $(srcdir)/epiphany.gresource.xml
+
+EPIPHANY_RESOURCES = \
+ epiphany-resources.c \
+ epiphany-resources.h \
+ $(NULL)
+
+BUILT_SOURCES = \
+ $(EPIPHANY_RESOURCES) \
+ $(TYPES_SOURCE) \
+ $(NULL)
if ENABLE_SEED
NOINST_H_FILES += \
@@ -123,7 +138,9 @@ libephymain_la_SOURCES += \
libephymain_la_CFLAGS += $(SEED_CFLAGS)
endif # ENABLE_SEED
-epiphany_SOURCES = ephy-main.c
+epiphany_SOURCES = ephy-main.c \
+ $(EPIPHANY_RESOURCES) \
+ $(NULL)
epiphany_CPPFLAGS = \
-I$(top_builddir)/lib \
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index b30b542b6..f0f46929c 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -1553,9 +1553,9 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_ui_manager_insert_action_group (ui_merge,
action_group, 0);
- gtk_ui_manager_add_ui_from_file (ui_merge,
- ephy_file ("epiphany-bookmark-editor-ui.xml"),
- NULL);
+ gtk_ui_manager_add_ui_from_resource (ui_merge,
+ "/org/gnome/epiphany/epiphany-bookmark-editor-ui.xml",
+ NULL);
gtk_window_add_accel_group (GTK_WINDOW (editor),
gtk_ui_manager_get_accel_group (ui_merge));
gtk_ui_manager_ensure_update (ui_merge);
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index d3756df77..824ae5d0f 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -285,7 +285,7 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog)
(EPHY_EMBED_SHELL (ephy_shell)));
ephy_dialog_construct (EPHY_DIALOG (dialog),
- ephy_file ("epiphany.ui"),
+ "/org/gnome/epiphany/epiphany.ui",
"encoding_dialog",
NULL);
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 88dd18d59..7581f3d2f 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -1145,9 +1145,9 @@ ephy_history_window_constructed (GObject *object)
gtk_ui_manager_insert_action_group (ui_merge,
action_group, 0);
- gtk_ui_manager_add_ui_from_file (ui_merge,
- ephy_file ("epiphany-history-window-ui.xml"),
- NULL);
+ gtk_ui_manager_add_ui_from_resource (ui_merge,
+ "/org/gnome/epiphany/epiphany-history-window-ui.xml",
+ NULL);
gtk_ui_manager_ensure_update (ui_merge);
editor->priv->ui_merge = ui_merge;
editor->priv->action_group = action_group;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 510017a7f..3e8450c9a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -297,9 +297,9 @@ ephy_shell_startup (GApplication* application)
application);
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder,
- ephy_file ("epiphany-application-menu.ui"),
- NULL);
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/epiphany/epiphany-application-menu.ui",
+ NULL);
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
g_object_unref (builder);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0636d5504..ee1c0c293 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3183,6 +3183,30 @@ static const char* disabled_actions_for_app_mode[] = { "FileOpen",
"ViewEncoding",
"FileBookmarkPage" };
+static gboolean
+_gtk_css_provider_load_from_resource (GtkCssProvider* provider,
+ const char *resource_path,
+ GError **error)
+{
+ GBytes *data;
+ gboolean res;
+
+ g_return_val_if_fail (GTK_IS_CSS_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (resource_path != NULL, FALSE);
+
+ data = g_resources_lookup_data (resource_path, 0, error);
+ if (data == NULL)
+ return FALSE;
+
+ res = gtk_css_provider_load_from_data (provider,
+ g_bytes_get_data (data, NULL),
+ g_bytes_get_size (data),
+ error);
+ g_bytes_unref (data);
+
+ return res;
+}
+
static GObject *
ephy_window_constructor (GType type,
guint n_construct_properties,
@@ -3199,7 +3223,6 @@ ephy_window_constructor (GType type,
GError *error = NULL;
guint settings_connection;
GtkCssProvider *css_provider;
- GFile *css_file;
int i;
EphyEmbedShellMode mode;
@@ -3275,21 +3298,22 @@ ephy_window_constructor (GType type,
priv->downloads_box, "visible",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- /* now load the UI definition */
- gtk_ui_manager_add_ui_from_file
- (priv->manager, ephy_file ("epiphany-ui.xml"), &error);
+ /* Now load the UI definition. */
+ gtk_ui_manager_add_ui_from_resource (priv->manager,
+ "/org/gnome/epiphany/epiphany-ui.xml",
+ &error);
if (error != NULL)
{
g_warning ("Could not merge epiphany-ui.xml: %s", error->message);
g_error_free (error);
+ error = NULL;
}
- /* Attach the CSS provider to the window */
- css_file = g_file_new_for_path (ephy_file ("epiphany.css"));
+ /* Attach the CSS provider to the window. */
css_provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_file (css_provider,
- css_file,
- &error);
+ _gtk_css_provider_load_from_resource (css_provider,
+ "/org/gnome/epiphany/epiphany.css",
+ &error);
if (error == NULL)
{
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)),
@@ -3303,7 +3327,6 @@ ephy_window_constructor (GType type,
}
g_object_unref (css_provider);
- g_object_unref (css_file);
/* Initialize the menus */
priv->enc_menu = ephy_encoding_menu_new (window);
diff --git a/src/epiphany.gresource.xml b/src/epiphany.gresource.xml
new file mode 100644
index 000000000..1b881c0df
--- /dev/null
+++ b/src/epiphany.gresource.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/epiphany">
+ <file compressed="true">epiphany.ui</file>
+ <file compressed="true">prefs-dialog.ui</file>
+ <file>epiphany-application-menu.ui</file>
+ <file>epiphany-ui.xml</file>
+ <file>epiphany-bookmark-editor-ui.xml</file>
+ <file>epiphany-history-window-ui.xml</file>
+ <file>epiphany.css</file>
+ </gresource>
+</gresources>
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index 24d075869..b8cb4802a 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -625,7 +625,7 @@ show_cookies_properties (PdmDialog *dialog,
cookie_dialog = ephy_dialog_new_with_parent (parent);
ephy_dialog_construct (cookie_dialog,
- ephy_file ("epiphany.ui"),
+ "/org/gnome/epiphany/epiphany.ui",
"cookie_properties_dialog",
NULL);
@@ -1466,7 +1466,7 @@ pdm_dialog_init (PdmDialog *dialog)
priv = dialog->priv = EPHY_PDM_DIALOG_GET_PRIVATE (dialog);
ephy_dialog_construct (EPHY_DIALOG (dialog),
- ephy_file ("epiphany.ui"),
+ "/org/gnome/epiphany/epiphany.ui",
"pdm_dialog",
NULL);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index d3c0c09ac..3ee1f617f 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -538,7 +538,7 @@ setup_add_language_dialog (PrefsDialog *pd)
NULL));
ephy_dialog_construct (dialog,
- ephy_file ("prefs-dialog.ui"),
+ "/org/gnome/epiphany/prefs-dialog.ui",
"add_language_dialog",
NULL);
@@ -1031,7 +1031,7 @@ prefs_dialog_init (PrefsDialog *pd)
pd->priv = EPHY_PREFS_DIALOG_GET_PRIVATE (pd);
ephy_dialog_construct (dialog,
- ephy_file ("prefs-dialog.ui"),
+ "/org/gnome/epiphany/prefs-dialog.ui",
"prefs_dialog",
NULL);