Skip to content

Commit

Permalink
Initial GResource migration
Browse files Browse the repository at this point in the history
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 libeom.

Starting with eom.css and eom-ui.xml

inspired from:
https://gitlab.gnome.org/GNOME/eog/commit/94004b4
  • Loading branch information
raveit65 committed Jul 27, 2018
1 parent e12f285 commit 6d164b4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -37,6 +37,7 @@ AC_PROG_LIBTOOL

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])

Expand Down
14 changes: 5 additions & 9 deletions data/Makefile.am
Expand Up @@ -25,21 +25,17 @@ ui_DATA = \
eom-image-properties-dialog.ui \
eom-multiple-save-as-dialog.ui \
eom-preferences-dialog.ui \
eom-ui.xml \
eom-toolbar.xml

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = eom.pc

themedir = $(pkgdatadir)
theme_DATA = \
eom.css

EXTRA_DIST = \
$(theme_DATA) \
$(ui_DATA) \
$(DESKTOP_IN_FILES) \
$(appdata_in_files)
$(ui_DATA) \
eom.css \
eom-ui.xml \
$(DESKTOP_IN_FILES) \
$(appdata_in_files)

CLEANFILES = \
$(appdata_DATA)
Expand Down
10 changes: 9 additions & 1 deletion src/Makefile.am
Expand Up @@ -157,7 +157,9 @@ libeom_la_LIBADD += \
$(X11_LIBS)
endif

eom_SOURCES = main.c
eom_SOURCES = \
main.c \
eom-resources.c

eom_CFLAGS = \
-I$(top_srcdir)/cut-n-paste/toolbar-editor \
Expand All @@ -177,8 +179,13 @@ eom_LDADD = \
BUILT_SOURCES = \
eom-enum-types.c \
eom-enum-types.h \
eom-resources.c \
$(MARSHAL_OUTPUT)

eom-resources.c: eom.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies eom.gresource.xml)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) "$<" --target=$@ \
--sourcedir=$(top_srcdir)/data --c-name _eom --generate-source

eom-enum-types.h: eom-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
$(AM_V_GEN)(cd $(srcdir) && $(GLIB_MKENUMS) --template eom-enum-types.h.template $(INST_H_FILES)) > $@

Expand All @@ -192,6 +199,7 @@ eom-marshal.c: eom-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --header --prefix=eom_marshal > $@

EXTRA_DIST = \
eom.gresource.xml \
eom-enum-types.h.template \
eom-enum-types.c.template \
eom-marshal.list
Expand Down
6 changes: 3 additions & 3 deletions src/eom-window.c
Expand Up @@ -4380,9 +4380,9 @@ eom_window_construct_ui (EomWindow *window)

gtk_ui_manager_insert_action_group (priv->ui_mgr, priv->actions_collection, 0);

if (!gtk_ui_manager_add_ui_from_file (priv->ui_mgr,
EOM_DATA_DIR"/eom-ui.xml",
&error)) {
if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
"/org/mate/eom/ui/eom-ui.xml",
&error)) {
g_warning ("building menus failed: %s", error->message);
g_error_free (error);
}
Expand Down
10 changes: 10 additions & 0 deletions src/eom.gresource.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/mate/eom/ui">
<file>eom.css</file>
<file compressed="true" preprocess="xml-stripblanks">eom-ui.xml</file>
</gresource>
</gresources>



8 changes: 5 additions & 3 deletions src/main.c
Expand Up @@ -96,6 +96,7 @@ main (int argc, char **argv)
{
GError *error = NULL;
GOptionContext *ctx;
GFile *css_file;
GtkCssProvider *provider;

bindtextdomain (GETTEXT_PACKAGE, EOM_LOCALE_DIR);
Expand Down Expand Up @@ -140,10 +141,11 @@ main (int argc, char **argv)
eom_thumbnail_init ();

/* Load special style properties for EomThumbView's scrollbar */
css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
provider = gtk_css_provider_new ();
if (G_UNLIKELY (!gtk_css_provider_load_from_path(provider,
EOM_CSS_FILE_PATH,
&error)))
if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,
css_file,
&error)))
{
g_critical ("Could not load CSS data: %s", error->message);
g_clear_error (&error);
Expand Down

0 comments on commit 6d164b4

Please sign in to comment.