Skip to content

Commit 6d164b4

Browse files
author
raveit65
committed
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 libeom. Starting with eom.css and eom-ui.xml inspired from: https://gitlab.gnome.org/GNOME/eog/commit/94004b4
1 parent e12f285 commit 6d164b4

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

‎configure.ac‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ AC_PROG_LIBTOOL
3737

3838
AC_PROG_CC
3939
AM_PROG_CC_C_O
40+
AC_PATH_PROG([GLIB_COMPILE_RESOURCES], [glib-compile-resources])
4041
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
4142
AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
4243

‎data/Makefile.am‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,17 @@ ui_DATA = \
2525
eom-image-properties-dialog.ui \
2626
eom-multiple-save-as-dialog.ui \
2727
eom-preferences-dialog.ui \
28-
eom-ui.xml \
2928
eom-toolbar.xml
3029

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

34-
themedir = $(pkgdatadir)
35-
theme_DATA = \
36-
eom.css
37-
3833
EXTRA_DIST = \
39-
$(theme_DATA) \
40-
$(ui_DATA) \
41-
$(DESKTOP_IN_FILES) \
42-
$(appdata_in_files)
34+
$(ui_DATA) \
35+
eom.css \
36+
eom-ui.xml \
37+
$(DESKTOP_IN_FILES) \
38+
$(appdata_in_files)
4339

4440
CLEANFILES = \
4541
$(appdata_DATA)

‎src/Makefile.am‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ libeom_la_LIBADD += \
157157
$(X11_LIBS)
158158
endif
159159

160-
eom_SOURCES = main.c
160+
eom_SOURCES = \
161+
main.c \
162+
eom-resources.c
161163

162164
eom_CFLAGS = \
163165
-I$(top_srcdir)/cut-n-paste/toolbar-editor \
@@ -177,8 +179,13 @@ eom_LDADD = \
177179
BUILT_SOURCES = \
178180
eom-enum-types.c \
179181
eom-enum-types.h \
182+
eom-resources.c \
180183
$(MARSHAL_OUTPUT)
181184

185+
eom-resources.c: eom.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies eom.gresource.xml)
186+
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) "$<" --target=$@ \
187+
--sourcedir=$(top_srcdir)/data --c-name _eom --generate-source
188+
182189
eom-enum-types.h: eom-enum-types.h.template $(INST_H_FILES) $(GLIB_MKENUMS)
183190
$(AM_V_GEN)(cd $(srcdir) && $(GLIB_MKENUMS) --template eom-enum-types.h.template $(INST_H_FILES)) > $@
184191

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

194201
EXTRA_DIST = \
202+
eom.gresource.xml \
195203
eom-enum-types.h.template \
196204
eom-enum-types.c.template \
197205
eom-marshal.list

‎src/eom-window.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,9 +4380,9 @@ eom_window_construct_ui (EomWindow *window)
43804380

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

4383-
if (!gtk_ui_manager_add_ui_from_file (priv->ui_mgr,
4384-
EOM_DATA_DIR"/eom-ui.xml",
4385-
&error)) {
4383+
if (!gtk_ui_manager_add_ui_from_resource (priv->ui_mgr,
4384+
"/org/mate/eom/ui/eom-ui.xml",
4385+
&error)) {
43864386
g_warning ("building menus failed: %s", error->message);
43874387
g_error_free (error);
43884388
}

‎src/eom.gresource.xml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/org/mate/eom/ui">
4+
<file>eom.css</file>
5+
<file compressed="true" preprocess="xml-stripblanks">eom-ui.xml</file>
6+
</gresource>
7+
</gresources>
8+
9+
10+

‎src/main.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ main (int argc, char **argv)
9696
{
9797
GError *error = NULL;
9898
GOptionContext *ctx;
99+
GFile *css_file;
99100
GtkCssProvider *provider;
100101

101102
bindtextdomain (GETTEXT_PACKAGE, EOM_LOCALE_DIR);
@@ -140,10 +141,11 @@ main (int argc, char **argv)
140141
eom_thumbnail_init ();
141142

142143
/* Load special style properties for EomThumbView's scrollbar */
144+
css_file = g_file_new_for_uri ("resource:///org/mate/eom/ui/eom.css");
143145
provider = gtk_css_provider_new ();
144-
if (G_UNLIKELY (!gtk_css_provider_load_from_path(provider,
145-
EOM_CSS_FILE_PATH,
146-
&error)))
146+
if (G_UNLIKELY (!gtk_css_provider_load_from_file(provider,
147+
css_file,
148+
&error)))
147149
{
148150
g_critical ("Could not load CSS data: %s", error->message);
149151
g_clear_error (&error);

0 commit comments

Comments
 (0)