Commit ba06a5e8 authored by Christian Persch's avatar Christian Persch Committed by Carlos Garcia Campos
Browse files

shell: Use GResource for data files

parent 8c240d93
......@@ -15,8 +15,6 @@ man_MANS=evince.1
uidir = $(pkgdatadir)
ui_DATA = \
evince-ui.xml \
evince-toolbar.xml \
hand-open.png
#
......
......@@ -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
......@@ -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;
}
......@@ -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
......
......@@ -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;
......
<?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>
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