[evince] previewer: Use GResource for data files
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] previewer: Use GResource for data files
- Date: Sun, 24 Jun 2012 10:07:47 +0000 (UTC)
commit 45be4867d85a973edc749057ff3be8224118ad05
Author: Christian Persch <chpe gnome org>
Date: Tue Jun 12 19:51:29 2012 +0200
previewer: Use GResource for data files
data/Makefile.am | 4 ---
previewer/Makefile.am | 21 +++++++++++---
previewer/ev-previewer-window.c | 29 ++-----------------
.../previewer-ui.xml | 0
previewer/previewer.gresource.xml | 22 +++++++++++++++
5 files changed, 42 insertions(+), 34 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index f4295df..33eac55 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -19,10 +19,6 @@ ui_DATA = \
evince-toolbar.xml \
hand-open.png
-if ENABLE_PREVIEWER
-ui_DATA += evince-previewer-ui.xml
-endif
-
#
# Desktop file
#
diff --git a/previewer/Makefile.am b/previewer/Makefile.am
index b6fdcb1..d9352b2 100644
--- a/previewer/Makefile.am
+++ b/previewer/Makefile.am
@@ -1,13 +1,15 @@
+NULL =
bin_PROGRAMS = evince-previewer
evince_previewer_SOURCES = \
- ev-previewer.c \
- ev-previewer-window.h \
- ev-previewer-window.c
+ ev-previewer.c \
+ ev-previewer-resources.c \
+ ev-previewer-window.h \
+ ev-previewer-window.c \
+ $(NULL)
evince_previewer_CPPFLAGS = \
- -DEVINCEDATADIR=\"$(pkgdatadir)\" \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_srcdir)/libdocument \
@@ -33,5 +35,16 @@ evince_previewer_LDADD = \
$(top_builddir)/libmisc/libevmisc.la \
$(PREVIEWER_LIBS)
+ev-previewer-resources.c: previewer.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/previewer.gresource.xml)
+ $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate-source --c-name ev_previewer $<
+
+EXTRA_DIST = \
+ previewer.gresource.xml \
+ previewer-ui.xml \
+ $(NULL)
+
+CLEANFILES = \
+ ev-previewer-resources.c \
+ $(NULL)
-include $(top_srcdir)/git.mk
diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c
index 39ace40..83cbe64 100644
--- a/previewer/ev-previewer-window.c
+++ b/previewer/ev-previewer-window.c
@@ -476,23 +476,6 @@ ev_previewer_window_dispose (GObject *object)
G_OBJECT_CLASS (ev_previewer_window_parent_class)->dispose (object);
}
-static gchar*
-data_dir (void)
-{
- gchar *datadir;
-#ifdef G_OS_WIN32
- gchar *dir;
-
- dir = g_win32_get_package_installation_directory_of_module (NULL);
- datadir = g_build_filename (dir, "share", "evince", NULL);
- g_free (dir);
-#else
- datadir = g_strdup (EVINCEDATADIR);
-#endif
-
- return datadir;
-}
-
static void
ev_previewer_window_init (EvPreviewerWindow *window)
{
@@ -527,7 +510,6 @@ ev_previewer_window_constructor (GType type,
GtkWidget *toolbar;
GtkAction *action;
GError *error = NULL;
- gchar *datadir, *ui_path;
gdouble dpi;
object = G_OBJECT_CLASS (ev_previewer_window_parent_class)->constructor (type,
@@ -580,14 +562,9 @@ ev_previewer_window_constructor (GType type,
window->accels_group, 1);
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (window->ui_manager));
- datadir = data_dir ();
- ui_path = g_build_filename (datadir, "evince-previewer-ui.xml", NULL);
- if (!gtk_ui_manager_add_ui_from_file (window->ui_manager, ui_path, &error)) {
- g_warning ("Failed to load ui from evince-previewer-ui.xml: %s", error->message);
- g_error_free (error);
- }
- g_free (ui_path);
- g_free (datadir);
+
+ gtk_ui_manager_add_ui_from_resource (window->ui_manager, "/org/gnome/evince/previewer/ui/previewer.xml", &error);
+ g_assert_no_error (error);
/* GTKUIManager connects actions accels only for menu items,
* but not for tool items. See bug #612972.
diff --git a/data/evince-previewer-ui.xml b/previewer/previewer-ui.xml
similarity index 100%
rename from data/evince-previewer-ui.xml
rename to previewer/previewer-ui.xml
diff --git a/previewer/previewer.gresource.xml b/previewer/previewer.gresource.xml
new file mode 100644
index 0000000..010c6bf
--- /dev/null
+++ b/previewer/previewer.gresource.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright  2012 Christian Persch
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope conf it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<gresources>
+ <gresource prefix="/org/gnome/evince/previewer">
+ <file alias="ui/previewer.xml" compressed="true" preprocess="xml-stripblanks">previewer-ui.xml</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]