[gnumeric] UI: Use a resource for the ui definition file.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] UI: Use a resource for the ui definition file.
- Date: Mon, 7 May 2018 13:26:33 +0000 (UTC)
commit 3d2d4891a40d00789ff6e6d54055b4a9259a90bf
Author: Morten Welinder <terra gnome org>
Date: Mon May 7 09:25:04 2018 -0400
UI: Use a resource for the ui definition file.
This allows running in-tree without an install ui file. That, in turn,
saves a step in "git bisect" operations across versions of Gnumeric.
ChangeLog | 5 ++++
src/.gitignore | 1 -
..._Gnumeric-gtk.xml.in => GNOME_Gnumeric-gtk.xml} | 6 ++--
src/Makefile.am | 9 +-------
src/gnm.gresource.xml | 1 +
src/wbc-gtk.c | 21 +++++++++++++++++--
6 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1f39ce7..6099d52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-07 Morten Welinder <terra gnome org>
+
+ * src/wbc-gtk.c (wbc_gtk_init): Use a resource for the default ui
+ definition.
+
2018-05-06 Morten Welinder <terra gnome org>
* src/commands.c (cmd_area_set_array_expr): The clipboard now
diff --git a/src/.gitignore b/src/.gitignore
index c7e89e8..4159f39 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -27,7 +27,6 @@ sstest
sstest.exe
ssdiff
ssdiff.exe
-GNOME_Gnumeric-gtk.xml
libspreadsheet.def
local.def
stamp-local.def
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml
similarity index 99%
rename from src/GNOME_Gnumeric-gtk.xml.in
rename to src/GNOME_Gnumeric-gtk.xml
index f726625..58a621c 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml
@@ -331,7 +331,7 @@
<menuitem action="HelpAbout"/>
</menu>
</menubar>
- <toolbar _name="StandardToolbar">
+ <toolbar name="StandardToolbar">
<toolitem action="FileNew"/>
<toolitem action="FileOpen"/>
<toolitem action="FileSave"/>
@@ -358,7 +358,7 @@
<toolitem action="Zoom"/>
<toolitem action="VZoom"/>
</toolbar>
- <toolbar _name="FormatToolbar">
+ <toolbar name="FormatToolbar">
<toolitem action="FontName"/>
<toolitem action="VFontName"/>
<toolitem action="FontBold"/>
@@ -388,7 +388,7 @@
<toolitem action="ColorBack"/>
<toolitem action="ColorFore"/>
</toolbar>
- <toolbar _name="ObjectToolbar">
+ <toolbar name="ObjectToolbar">
<toolitem action="CreateRectangle"/>
<toolitem action="CreateEllipse"/>
<toolitem action="CreateFrame"/>
diff --git a/src/Makefile.am b/src/Makefile.am
index 34a88c2..3170dc5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -527,14 +527,7 @@ EXTRA_DIST = \
gnm-marshalers.list \
README.gnm_float \
gnumeric.rc \
- GNOME_Gnumeric-gtk.xml.in
-
-gtkactiondir=$(gnumeric_datadir)
-
-gtkaction_DATA = GNOME_Gnumeric-gtk.xml
-GNOME_Gnumeric-gtk.xml: GNOME_Gnumeric-gtk.xml.in
- sed -e 's/ _name *=/ name=/' <$< >$@
-DISTCLEANFILES = GNOME_Gnumeric-gtk.xml
+ GNOME_Gnumeric-gtk.xml
if HAVE_INTROSPECTION
diff --git a/src/gnm.gresource.xml b/src/gnm.gresource.xml
index 61a71f7..fa2c11d 100644
--- a/src/gnm.gresource.xml
+++ b/src/gnm.gresource.xml
@@ -181,5 +181,6 @@
<file alias="images/unknown_image.png">src/pixmaps/unknown_image.png</file>
<file alias="images/sheet_move_marker.png">src/pixmaps/sheet_move_marker.png</file>
<file alias="ui/gnumeric.css">src/gnumeric.css</file>
+ <file alias="ui/GNOME_Gnumeric-gtk.xml">src/GNOME_Gnumeric-gtk.xml</file>
</gresource>
</gresources>
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index c983e2f..9ec30a4 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -4996,6 +4996,7 @@ wbc_gtk_init (GObject *obj)
unsigned i;
GEnumClass *posclass;
GtkStyleContext *ctxt;
+ guint merge_id;
wbcg->gui = gnm_gtk_builder_load ("wbcg.ui", NULL, NULL);
wbcg->cancel_button = GET_GUI_ITEM ("cancel_button");
@@ -5074,13 +5075,27 @@ wbc_gtk_init (GObject *obj)
gtk_action_group_add_actions (wbcg->actions, extra_actions,
extra_actions_nb, wbcg);
- uifile = g_build_filename (gnm_sys_data_dir (),
- (uifilename? uifilename: "GNOME_Gnumeric-gtk.xml"), NULL);
+ if (uifilename) {
+ if (strncmp (uifilename, "res:", 4) == 0)
+ uifile = g_strdup (uifilename);
+ else
+ uifile = g_build_filename (gnm_sys_data_dir (),
+ uifilename,
+ NULL);
+ } else
+ uifile = g_strdup ("res:/org/gnumeric/gnumeric/ui/GNOME_Gnumeric-gtk.xml");
- if (!gtk_ui_manager_add_ui_from_file (wbcg->ui, uifile, &error)) {
+ if (strncmp (uifile, "res:", 4) == 0)
+ merge_id = gtk_ui_manager_add_ui_from_resource
+ (wbcg->ui, uifile + 4, &error);
+ else
+ merge_id = gtk_ui_manager_add_ui_from_file
+ (wbcg->ui, uifile, &error);
+ if (!merge_id) {
g_message ("building menus failed: %s", error->message);
g_error_free (error);
}
+
g_free (uifile);
wbcg->custom_uis = g_hash_table_new_full (g_direct_hash, g_direct_equal,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]