[aisleriot] window: Use GResource for the UI description
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aisleriot] window: Use GResource for the UI description
- Date: Mon, 4 Mar 2013 20:36:31 +0000 (UTC)
commit bb4eba3690f8a6dac8d29b84920836d227f2292d
Author: Christian Persch <chpe gnome org>
Date: Sat Oct 27 18:48:44 2012 +0200
window: Use GResource for the UI description
src/Makefile.am | 2 +
src/aisleriot-debug-ui.xml | 26 ++++++++++++
src/aisleriot-ui.xml | 52 ++++++++++++++++++++++++
src/aisleriot.gresource.xml.in | 2 +
src/window.c | 87 +++------------------------------------
5 files changed, 89 insertions(+), 80 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index aac4614..44593ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -161,6 +161,8 @@ EXTRA_DIST = \
$(icon_DATA) \
$(allicons) \
$(schema_in_files) \
+ aisleriot-ui.xml \
+ aisleriot-debug-ui.xml \
game-names.h
CLEANFILES = \
diff --git a/src/aisleriot-debug-ui.xml b/src/aisleriot-debug-ui.xml
new file mode 100644
index 0000000..972cd4b
--- /dev/null
+++ b/src/aisleriot-debug-ui.xml
@@ -0,0 +1,26 @@
+<ui>
+ <menubar name="MainMenu">
+ <menu action="DebugMenu">
+ <menuitem action="DebugTweakStyle"/>
+ <menuitem action="DebugTweakSettings"/>
+ <separator/>
+ <menuitem action="DebugChooseSeed"/>
+ <menuitem action="DebugMoveNextScreen"/>
+ <menuitem action="DebugDelayedMoveNextScreen"/>
+ <menuitem action="DebugException"/>
+ <separator/>
+ <menuitem action="DebugCycle"/>
+ <separator/>
+ <menuitem action="DebugGameFirst"/>
+ <menuitem action="DebugGamePrev"/>
+ <menuitem action="DebugGameNext"/>
+ <menuitem action="DebugGameLast"/>
+ </menu>
+ </menubar>
+ <toolbar name="Toolbar">
+ <toolitem action="DebugGameFirst"/>
+ <toolitem action="DebugGamePrev"/>
+ <toolitem action="DebugGameNext"/>
+ <toolitem action="DebugGameLast"/>
+ </toolbar>
+</ui>
diff --git a/src/aisleriot-ui.xml b/src/aisleriot-ui.xml
new file mode 100644
index 0000000..e35b5ae
--- /dev/null
+++ b/src/aisleriot-ui.xml
@@ -0,0 +1,52 @@
+<ui>
+ <menubar name="MainMenu">
+ <menu action="GameMenu">
+ <menuitem action="NewGame"/>
+ <menuitem action="RestartGame"/>
+ <menuitem action="Statistics"/>
+ <menuitem action="Select"/>
+ <menu action="RecentMenu"/>
+ <separator/>
+ <menuitem action="CloseWindow"/>
+ </menu>
+ <menu action="ViewMenu">
+ <menuitem action="Fullscreen"/>
+ <menuitem action="Toolbar"/>
+ <menuitem action="Statusbar"/>
+ <separator/>
+ <menu action="ThemeMenu">
+ <placeholder name="ThemesPH"/>
+ <separator/>
+ <menuitem action="InstallThemes"/>
+ </menu>
+ </menu>
+ <menu action="ControlMenu">
+ <menuitem action="UndoMove"/>
+ <menuitem action="RedoMove"/>
+ <menuitem action="Deal"/>
+ <menuitem action="Hint"/>
+ <separator/>
+ <menuitem action="ClickToMove"/>
+ <menuitem action="Sound"/>
+ <menuitem action="Animations"/>
+ </menu>
+ <menu action="OptionsMenu"/>
+ <menu action="HelpMenu">
+ <menuitem action="Contents"/>
+ <menuitem action="HelpGame"/>
+ <menuitem action="About"/>
+ </menu>
+ </menubar>
+ <toolbar name="Toolbar">
+ <toolitem action="NewGame"/>
+ <toolitem action="RestartGame"/>
+ <toolitem action="Select"/>
+ <separator/>
+ <toolitem action="UndoMove"/>
+ <toolitem action="RedoMove"/>
+ <toolitem action="Deal"/>
+ <toolitem action="Hint"/>
+ <separator name="LeaveFullscreenSep" expand="true"/>
+ <toolitem action="LeaveFullscreen"/>
+ </toolbar>
+</ui>
diff --git a/src/aisleriot.gresource.xml.in b/src/aisleriot.gresource.xml.in
index 327ed0e..b59c9ab 100644
--- a/src/aisleriot.gresource.xml.in
+++ b/src/aisleriot.gresource.xml.in
@@ -19,5 +19,7 @@
<gresource prefix="/org/gnome/aisleriot">
<file alias="art/slot.svg" compressed="true"
preprocess="xml-stripblanks">@top_srcdir@/data/slot.svg</file>
<file alias="art/baize.png">@top_srcdir@/data/baize.png</file>
+ <file alias="ui/menus.xml">@srcdir@/aisleriot-ui.xml</file>
+ <file alias="ui/debug-menus.xml">@srcdir@/aisleriot-debug-ui.xml</file>
</gresource>
</gresources>
diff --git a/src/window.c b/src/window.c
index 45b6713..166484d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2112,84 +2112,6 @@ aisleriot_window_init (AisleriotWindow *window)
"LeaveFullscreen",
};
- static const char ui_description[] =
- "<ui>"
- "<menubar name='MainMenu'>"
- "<menu action='GameMenu'>"
- "<menuitem action='NewGame'/>"
- "<menuitem action='RestartGame'/>"
- "<menuitem action='Statistics'/>"
- "<menuitem action='Select'/>"
- "<menu action='RecentMenu'/>"
- "<separator/>"
- "<menuitem action='CloseWindow'/>"
- "</menu>"
- "<menu action='ViewMenu'>"
- "<menuitem action='Fullscreen'/>"
- "<menuitem action='Toolbar'/>"
- "<menuitem action='Statusbar'/>"
- "<separator/>"
- "<menu action='ThemeMenu'>"
- "<placeholder name='ThemesPH'/>"
- "<separator/>"
- "<menuitem action='InstallThemes'/>"
- "</menu>"
- "</menu>"
- "<menu action='ControlMenu'>"
- "<menuitem action='UndoMove'/>"
- "<menuitem action='RedoMove'/>"
- "<menuitem action='Deal'/>"
- "<menuitem action='Hint'/>"
- "<separator/>"
- "<menuitem action='ClickToMove'/>"
- "<menuitem action='Sound'/>"
- "<menuitem action='Animations'/>"
- "</menu>"
- "<menu action='OptionsMenu'/>"
- "<menu action='HelpMenu'>"
- "<menuitem action='Contents'/>"
- "<menuitem action='HelpGame'/>"
- "<menuitem action='About'/>"
- "</menu>"
-#ifdef ENABLE_DEBUG_UI
- "<menu action='DebugMenu'>"
- "<menuitem action='DebugTweakStyle'/>"
- "<menuitem action='DebugTweakSettings'/>"
- "<separator/>"
- "<menuitem action='DebugChooseSeed'/>"
- "<menuitem action='DebugMoveNextScreen'/>"
- "<menuitem action='DebugDelayedMoveNextScreen'/>"
- "<menuitem action='DebugException'/>"
- "<separator/>"
- "<menuitem action='DebugCycle'/>"
- "<separator/>"
- "<menuitem action='DebugGameFirst'/>"
- "<menuitem action='DebugGamePrev'/>"
- "<menuitem action='DebugGameNext'/>"
- "<menuitem action='DebugGameLast'/>"
- "</menu>"
-#endif /* ENABLE_DEBUG_UI */
- "</menubar>"
- "<toolbar name='Toolbar'>"
- "<toolitem action='NewGame'/>"
- "<toolitem action='RestartGame'/>"
- "<toolitem action='Select'/>"
- "<separator/>"
- "<toolitem action='UndoMove'/>"
- "<toolitem action='RedoMove'/>"
- "<toolitem action='Deal'/>"
- "<toolitem action='Hint'/>"
- "<separator name='LeaveFullscreenSep' expand='true'/>"
- "<toolitem action='LeaveFullscreen'/>"
-#ifdef ENABLE_DEBUG_UI
- "<toolitem action='DebugGameFirst'/>"
- "<toolitem action='DebugGamePrev'/>"
- "<toolitem action='DebugGameNext'/>"
- "<toolitem action='DebugGameLast'/>"
-#endif
- "</toolbar>"
- "</ui>";
-
AisleriotWindowPrivate *priv;
GtkWidget *main_vbox;
GtkAccelGroup *accel_group;
@@ -2199,6 +2121,7 @@ aisleriot_window_init (AisleriotWindow *window)
guint i;
GtkStatusbar *statusbar;
GtkWidget *statusbar_hbox, *label, *time_box;
+ GError *error = NULL;
#ifdef HAVE_CLUTTER
ClutterContainer *stage;
#endif
@@ -2333,8 +2256,12 @@ aisleriot_window_init (AisleriotWindow *window)
/* Load the UI after we've connected the statusbar,
* otherwise not all actions will have statusbar help.
*/
- gtk_ui_manager_add_ui_from_string (priv->ui_manager, ui_description,
- strlen (ui_description), NULL);
+ gtk_ui_manager_add_ui_from_resource (priv->ui_manager, "/org/gnome/aisleriot/ui/menus.xml", &error);
+ g_assert_no_error (error);
+#ifdef ENABLE_DEBUG_UI
+ gtk_ui_manager_add_ui_from_resource (priv->ui_manager, "/org/gnome/aisleriot/ui/debug-menus.xml", &error);
+ g_assert_no_error (error);
+#endif /* ENABLE_DEBUG_UI */
priv->main_menu = gtk_ui_manager_get_widget (priv->ui_manager, MAIN_MENU_UI_PATH);
priv->toolbar = gtk_ui_manager_get_widget (priv->ui_manager, TOOLBAR_UI_PATH);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]