From 11fc5dc635d544b7d19b5774ab11dcd5e5c2638c Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 12 Jun 2012 20:02:34 +0200 Subject: shell: Use GResource for data files origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-6&id=ba06a5e --- shell/Makefile.am | 12 +++- shell/atril-toolbar.xml | 41 +++++++++++++ shell/atril-ui.xml | 149 ++++++++++++++++++++++++++++++++++++++++++++++ shell/atril.gresource.xml | 24 ++++++++ shell/ev-application.c | 9 --- shell/ev-application.h | 1 - shell/ev-window.c | 24 +++----- 7 files changed, 233 insertions(+), 27 deletions(-) create mode 100644 shell/atril-toolbar.xml create mode 100644 shell/atril-ui.xml create mode 100644 shell/atril.gresource.xml (limited to 'shell') diff --git a/shell/Makefile.am b/shell/Makefile.am index 1bf3cba4..ea8d91d8 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -65,6 +65,8 @@ atril_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 \ @@ -115,7 +117,8 @@ atril_LDADD= \ $(top_builddir)/libmisc/libevmisc.la \ $(SHELL_LIBS) -BUILT_SOURCES = +BUILT_SOURCES = \ + ev-resources.c if ENABLE_DBUS BUILT_SOURCES += \ @@ -150,9 +153,13 @@ atrild_LDADD= \ endif EXTRA_DIST = \ + atril-ui.xml \ + atril-toolbar.xml \ + atril.gresource.xml \ ev-gdbus.xml \ ev-daemon-gdbus.xml + ev-gdbus-generated.c ev-gdbus-generated.h: ev-gdbus.xml Makefile $(AM_V_GEN) $(GDBUS_CODEGEN) \ --interface-prefix=org.mate.atril \ @@ -169,6 +176,9 @@ ev-daemon-gdbus-generated.c ev-daemon-gdbus-generated.h: ev-daemon-gdbus.xml Mak --generate-c-code ev-daemon-gdbus-generated \ $< +ev-resources.c: atril.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/atril.gresource.xml) + $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate-source --c-name ev $< + DISTCLEANFILES = $(BUILT_SOURCES) -include $(top_srcdir)/git.mk diff --git a/shell/atril-toolbar.xml b/shell/atril-toolbar.xml new file mode 100644 index 00000000..eb641581 --- /dev/null +++ b/shell/atril-toolbar.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell/atril-ui.xml b/shell/atril-ui.xml new file mode 100644 index 00000000..851a014c --- /dev/null +++ b/shell/atril-ui.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell/atril.gresource.xml b/shell/atril.gresource.xml new file mode 100644 index 00000000..f66c2a10 --- /dev/null +++ b/shell/atril.gresource.xml @@ -0,0 +1,24 @@ + + + + + atril-ui.xml + atril-toolbar.xml + + + diff --git a/shell/ev-application.c b/shell/ev-application.c index 601a09a6..6307c7fe 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -49,7 +49,6 @@ struct _EvApplication { gchar *uri; gchar *dot_dir; - gchar *data_dir; #ifdef ENABLE_DBUS EvAtrilApplication *skeleton; @@ -990,8 +989,6 @@ static void ev_application_init(EvApplication* ev_application) ev_application->dot_dir = g_build_filename(g_get_user_config_dir(), "atril", NULL); } - ev_application->data_dir = g_strdup (ATRILDATADIR); - ev_application_init_session (ev_application); ev_application_accel_map_load (ev_application); @@ -1063,9 +1060,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 d8d9cff1..b5187509 100644 --- a/shell/ev-application.h +++ b/shell/ev-application.h @@ -70,7 +70,6 @@ const gchar * ev_application_get_uri (EvApplication *applicati GObject *ev_application_get_media_keys (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 f323a4f9..065ada89 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -288,6 +288,8 @@ struct _EvWindowPrivate { #define MAX_RECENT_ITEM_LEN (40) +#define TOOLBAR_RESOURCE_PATH "/org/mate/atril/shell/ui/toolbar.xml" + static const gchar *document_print_settings[] = { GTK_PRINT_SETTINGS_N_COPIES, GTK_PRINT_SETTINGS_COLLATE, @@ -7520,19 +7522,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), "atril_toolbar.xml", NULL); - toolbars_path = g_build_filename (ev_application_get_data_dir (EV_APP), - "atril-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; } @@ -7554,7 +7553,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); @@ -7660,7 +7658,6 @@ ev_window_init (EvWindow *ev_window) GtkWidget *overlay; GObject *mpkeys; guint page_cache_mb; - gchar *ui_path; #ifdef ENABLE_DBUS GDBusConnection *connection; static gint window_id = 0; @@ -7756,15 +7753,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), - "atril-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/mate/atril/shell/ui/atril.xml", + &error); + g_assert_no_error (error); ev_window->priv->recent_manager = gtk_recent_manager_get_default (); ev_window->priv->recent_action_group = NULL; -- cgit v1.2.1