[evince] shell: Use GResource for data files
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] shell: Use GResource for data files
- Date: Sun, 24 Jun 2012 10:07:57 +0000 (UTC)
commit ba06a5e89cc285cf8843650474868d08f21e30b5
Author: Christian Persch <chpe gnome org>
Date: Tue Jun 12 20:02:34 2012 +0200
shell: Use GResource for data files
data/Makefile.am | 2 --
shell/Makefile.am | 18 +++++++++++++++---
shell/ev-application.c | 21 ---------------------
shell/ev-application.h | 1 -
shell/ev-window.c | 24 ++++++++----------------
{data => shell}/evince-toolbar.xml | 0
{data => shell}/evince-ui.xml | 0
shell/evince.gresource.xml | 23 +++++++++++++++++++++++
8 files changed, 46 insertions(+), 43 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 33eac55..06061f6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -15,8 +15,6 @@ man_MANS=evince.1
uidir = $(pkgdatadir)
ui_DATA = \
- evince-ui.xml \
- evince-toolbar.xml \
hand-open.png
#
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 2d5d3fd..11361e3 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -67,6 +67,8 @@ evince_SOURCES= \
ev-properties-license.h \
ev-open-recent-action.c \
ev-open-recent-action.h \
+ ev-resources.c \
+ ev-resources.h \
ev-utils.c \
ev-utils.h \
ev-window.c \
@@ -123,7 +125,10 @@ evince-icon.o: $(srcdir)/evince-icon.rc $(top_srcdir)/data/evince.ico
$(AM_V_GEN)$(WINDRES) $(srcdir)/evince-icon.rc -I $(top_srcdir)/data evince-icon.o
endif
-BUILT_SOURCES = ev-marshal.h ev-marshal.c
+BUILT_SOURCES = \
+ ev-marshal.c \
+ ev-marshal.h \
+ ev-resources.c
if ENABLE_DBUS
evinced_SOURCES= \
@@ -144,8 +149,12 @@ evinced_LDADD= \
$(EV_DAEMON_LIBS)
endif
-EXTRA_DIST = ev-marshal.list \
- evince-icon.rc
+EXTRA_DIST = \
+ ev-marshal.list \
+ evince-icon.rc \
+ evince-ui.xml \
+ evince-toolbar.xml \
+ evince.gresource.xml
ev-marshal.h: $(srcdir)/ev-marshal.list
$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=ev_marshal $(srcdir)/ev-marshal.list --header > ev-marshal.h
@@ -154,6 +163,9 @@ ev-marshal.c: $(srcdir)/ev-marshal.list
$(AM_V_at)echo '#include "ev-marshal.h"' > ev-marshal.c
$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=ev_marshal $(srcdir)/ev-marshal.list --body >> ev-marshal.c
+ev-resources.c: evince.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/evince.gresource.xml)
+ $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate-source --c-name ev $<
+
DISTCLEANFILES =
-include $(top_srcdir)/git.mk
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 64415ce..34d67f5 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -55,7 +55,6 @@ struct _EvApplication {
gchar *uri;
gchar *dot_dir;
- gchar *data_dir;
#ifdef ENABLE_DBUS
GDBusConnection *connection;
@@ -1065,8 +1064,6 @@ ev_application_shutdown (EvApplication *application)
g_free (application->dot_dir);
application->dot_dir = NULL;
- g_free (application->data_dir);
- application->data_dir = NULL;
g_object_unref (application);
instance = NULL;
@@ -1091,18 +1088,6 @@ ev_application_init (EvApplication *ev_application)
if (!g_file_test (ev_application->dot_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
ev_application_migrate_config_dir (ev_application);
-#ifdef G_OS_WIN32
-{
- gchar *dir;
-
- dir = g_win32_get_package_installation_directory_of_module (NULL);
- ev_application->data_dir = g_build_filename (dir, "share", "evince", NULL);
- g_free (dir);
-}
-#else
- ev_application->data_dir = g_strdup (EVINCEDATADIR);
-#endif
-
ev_application_init_session (ev_application);
ev_application_accel_map_load (ev_application);
@@ -1229,9 +1214,3 @@ ev_application_get_dot_dir (EvApplication *application,
return application->dot_dir;
}
-
-const gchar *
-ev_application_get_data_dir (EvApplication *application)
-{
- return application->data_dir;
-}
diff --git a/shell/ev-application.h b/shell/ev-application.h
index 4f767e8..64b9c8a 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -75,7 +75,6 @@ void ev_application_screensaver_enable (EvApplication *application);
void ev_application_screensaver_disable (EvApplication *application);
const gchar *ev_application_get_dot_dir (EvApplication *application,
gboolean create);
-const gchar *ev_application_get_data_dir (EvApplication *application);
G_END_DECLS
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 1973776..d4ac059 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -274,6 +274,8 @@ struct _EvWindowPrivate {
#define EV_HELP_TOOLBAR "http://library.gnome.org/users/evince/stable/toolbar.html"
#endif
+#define TOOLBAR_RESOURCE_PATH "/org/gnome/evince/shell/ui/toolbar.xml"
+
static const gchar *document_print_settings[] = {
GTK_PRINT_SETTINGS_N_COPIES,
GTK_PRINT_SETTINGS_COLLATE,
@@ -6946,19 +6948,16 @@ get_toolbars_model (void)
{
EggToolbarsModel *toolbars_model;
gchar *toolbars_file;
- gchar *toolbars_path;
gint i;
toolbars_model = egg_toolbars_model_new ();
toolbars_file = g_build_filename (ev_application_get_dot_dir (EV_APP, FALSE),
"evince_toolbar.xml", NULL);
- toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP),
- "evince-toolbar.xml", NULL);
- egg_toolbars_model_load_names (toolbars_model, toolbars_path);
+ egg_toolbars_model_load_names_from_resource (toolbars_model, TOOLBAR_RESOURCE_PATH);
if (!egg_toolbars_model_load_toolbars (toolbars_model, toolbars_file)) {
- egg_toolbars_model_load_toolbars (toolbars_model, toolbars_path);
+ egg_toolbars_model_load_toolbars_from_resource (toolbars_model, TOOLBAR_RESOURCE_PATH);
goto skip_conversion;
}
@@ -6980,7 +6979,6 @@ get_toolbars_model (void)
skip_conversion:
g_free (toolbars_file);
- g_free (toolbars_path);
egg_toolbars_model_set_flags (toolbars_model, 0, EGG_TB_MODEL_NOT_REMOVABLE);
@@ -7177,7 +7175,6 @@ ev_window_init (EvWindow *ev_window)
GtkWidget *menuitem;
EggToolbarsModel *toolbars_model;
GObject *mpkeys;
- gchar *ui_path;
#ifdef ENABLE_DBUS
GDBusConnection *connection;
static gint window_id = 0;
@@ -7268,15 +7265,10 @@ ev_window_init (EvWindow *ev_window)
gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
action_group, 0);
- ui_path = g_build_filename (ev_application_get_data_dir (EV_APP),
- "evince-ui.xml", NULL);
- if (!gtk_ui_manager_add_ui_from_file (
- ev_window->priv->ui_manager, ui_path, &error))
- {
- g_warning ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- g_free (ui_path);
+ gtk_ui_manager_add_ui_from_resource (ev_window->priv->ui_manager,
+ "/org/gnome/evince/shell/ui/evince.xml",
+ &error);
+ g_assert_no_error (error);
ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
ev_window->priv->recent_action_group = NULL;
diff --git a/data/evince-toolbar.xml b/shell/evince-toolbar.xml
similarity index 100%
rename from data/evince-toolbar.xml
rename to shell/evince-toolbar.xml
diff --git a/data/evince-ui.xml b/shell/evince-ui.xml
similarity index 100%
rename from data/evince-ui.xml
rename to shell/evince-ui.xml
diff --git a/shell/evince.gresource.xml b/shell/evince.gresource.xml
new file mode 100644
index 0000000..2fac911
--- /dev/null
+++ b/shell/evince.gresource.xml
@@ -0,0 +1,23 @@
+<?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/shell">
+ <file alias="ui/evince.xml" compressed="true" preprocess="xml-stripblanks">evince-ui.xml</file>
+ <file alias="ui/toolbar.xml" compressed="true" preprocess="xml-stripblanks">evince-toolbar.xml</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]