summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Riemann <friemann@gnome.org>2014-03-14 21:24:34 +0100
committerFelix Riemann <friemann@gnome.org>2014-05-03 20:28:34 +0200
commit94004b468f57673365a069d0654919dd9f2974a7 (patch)
tree10fa2dfc459c3c0f59c75e26a1a20e3e25802340
parenta8343a6c56d8c0df225657f62e0011e694abae5f (diff)
downloadeog-94004b468f57673365a069d0654919dd9f2974a7.tar.gz
Initial GResource migration
Embedding UI data files as GResource makes several things easier. The compiled resources need to be linked directly with the binary as they won't be available if linked with the embedded libeog.
-rw-r--r--configure.ac1
-rw-r--r--data/Makefile.am16
-rw-r--r--src/Makefile.am8
-rw-r--r--src/eog-application.c10
-rw-r--r--src/eog-properties-dialog.c7
-rw-r--r--src/eog-window.c6
-rw-r--r--src/eog.gresource.xml11
7 files changed, 38 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index 35ea2932..2bfc29db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,7 @@ LT_INIT([disable-static])
AC_PROG_CC
AM_PROG_CC_C_O
+AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
diff --git a/data/Makefile.am b/data/Makefile.am
index 1191ae90..40997080 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -24,23 +24,21 @@ gsettingsconvertdir = $(datadir)/GConf/gsettings
gsettingsconvert_DATA = eog.convert
uidir = $(pkgdatadir)
-ui_DATA = eog-image-properties-dialog.ui \
+ui_DATA = \
eog-multiple-save-as-dialog.ui \
eog-preferences-dialog.ui \
- eog-app-menu.xml \
- eog-ui.xml \
eog-toolbar.xml
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = eog.pc
-styledir = $(pkgdatadir)
-style_DATA = eog.css
-
EXTRA_DIST = \
- $(style_DATA) \
- $(ui_DATA) \
- $(DESKTOP_IN_FILES) \
+ $(ui_DATA) \
+ eog.css \
+ eog-app-menu.xml \
+ eog-image-properties-dialog.ui \
+ eog-ui.xml \
+ $(DESKTOP_IN_FILES) \
$(appdata_in_files) \
eog.convert
diff --git a/src/Makefile.am b/src/Makefile.am
index f7798281..59b417d0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -162,7 +162,7 @@ endif
libeog_la_LDFLAGS = -export-dynamic -no-undefined
-eog_SOURCES = main.c
+eog_SOURCES = eog-resources.c main.c
eog_CFLAGS = \
-I$(top_srcdir)/cut-n-paste/toolbar-editor \
@@ -184,8 +184,13 @@ eog_LDFLAGS = -export-dynamic -no-undefined
BUILT_SOURCES = \
eog-enum-types.c \
eog-enum-types.h \
+ eog-resources.c \
$(MARSHAL_OUTPUT)
+eog-resources.c: eog.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies eog.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) "$<" --target=$@ \
+ --sourcedir=$(top_srcdir)/data --c-name _eog --generate-source
+
eog-enum-types.h: eog-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
$(AM_V_GEN)(cd $(srcdir) && $(GLIB_MKENUMS) --template eog-enum-types.h.template $(INST_H_FILES)) > $@
@@ -199,6 +204,7 @@ eog-marshal.c: eog-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --header --prefix=eog_marshal > $@
EXTRA_DIST = \
+ eog.gresource.xml \
eog-enum-types.h.template \
eog-enum-types.c.template \
eog-marshal.list
diff --git a/src/eog-application.c b/src/eog-application.c
index 916d97e7..2ae47082 100644
--- a/src/eog-application.c
+++ b/src/eog-application.c
@@ -180,7 +180,9 @@ eog_application_init_app_menu (EogApplication *application)
application);
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, EOG_DATA_DIR"/eog-app-menu.xml", &error);
+ gtk_builder_add_from_resource (builder,
+ "/org/gnome/eog/ui/eog-app-menu.xml",
+ &error);
if (error == NULL) {
gtk_application_set_app_menu (GTK_APPLICATION (application),
@@ -233,6 +235,7 @@ eog_application_startup (GApplication *application)
{
EogApplication *app = EOG_APPLICATION (application);
GError *error = NULL;
+ GFile *css_file;
GtkSettings *settings;
GtkCssProvider *provider;
@@ -246,9 +249,10 @@ eog_application_startup (GApplication *application)
eog_thumbnail_init ();
/* Load special style properties for EogThumbView's scrollbar */
+ css_file = g_file_new_for_uri ("resource:///org/gnome/eog/ui/eog.css");
provider = gtk_css_provider_new ();
- if (G_UNLIKELY (!gtk_css_provider_load_from_path(provider,
- EOG_CSS_FILE_PATH,
+ if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,
+ css_file,
&error)))
{
g_critical ("Could not load CSS data: %s", error->message);
diff --git a/src/eog-properties-dialog.c b/src/eog-properties-dialog.c
index face9fa8..5660eb48 100644
--- a/src/eog-properties-dialog.c
+++ b/src/eog-properties-dialog.c
@@ -557,11 +557,8 @@ eog_properties_dialog_class_init (EogPropertiesDialogClass *klass)
FALSE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- gchar* data;
- gsize data_size;
- g_file_get_contents(g_build_filename (EOG_DATA_DIR, "eog-image-properties-dialog.ui", NULL), &data, &data_size, NULL);
- GBytes *bytes = g_bytes_new_static(data, data_size);
- gtk_widget_class_set_template((GtkWidgetClass *) klass, bytes);
+
+ gtk_widget_class_set_template_from_resource ((GtkWidgetClass *) klass, "/org/gnome/eog/ui/eog-image-properties-dialog.ui");
GtkWidgetClass *wklass = (GtkWidgetClass*) klass;
gtk_widget_class_bind_template_child_private(wklass,
diff --git a/src/eog-window.c b/src/eog-window.c
index caa8e3d2..98c15390 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -4911,9 +4911,9 @@ eog_window_construct_ui (EogWindow *window)
gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_gallery, 0);
- if (!gtk_ui_manager_add_ui_from_file (priv->ui_mgr,
- EOG_DATA_DIR"/eog-ui.xml",
- &error)) {
+ if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
+ "/org/gnome/eog/ui/eog-ui.xml",
+ &error)) {
g_warning ("building menus failed: %s", error->message);
g_error_free (error);
}
diff --git a/src/eog.gresource.xml b/src/eog.gresource.xml
new file mode 100644
index 00000000..bf536949
--- /dev/null
+++ b/src/eog.gresource.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/eog/ui">
+ <file>eog.css</file>
+ <file compressed="true" preprocess="xml-stripblanks">eog-app-menu.xml</file>
+ <file compressed="true" preprocess="xml-stripblanks">eog-image-properties-dialog.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">eog-ui.xml</file>
+ </gresource>
+</gresources>
+
+