Commit 94004b46 authored by Felix Riemann's avatar Felix Riemann
Browse files

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.
parent a8343a6c
......@@ -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])
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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,
......
......@@ -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);
}
......
<?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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment