[gnome-sudoku] Use GResource for loading appmenu.
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] Use GResource for loading appmenu.
- Date: Fri, 5 Sep 2014 13:55:55 +0000 (UTC)
commit f946bd637060735d1483641061a17769dd6c52ef
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Sep 5 00:11:45 2014 +0200
Use GResource for loading appmenu.
https://bugzilla.gnome.org/show_bug.cgi?id=735806
data/gnome-sudoku-menu.ui | 2 +-
src/gnome-sudoku.gresource.xml.in | 6 ++++--
src/gnome-sudoku.vala | 17 ++---------------
src/sudoku-printer.vala | 10 +---------
4 files changed, 8 insertions(+), 27 deletions(-)
---
diff --git a/data/gnome-sudoku-menu.ui b/data/gnome-sudoku-menu.ui
index de03917..908c96b 100644
--- a/data/gnome-sudoku-menu.ui
+++ b/data/gnome-sudoku-menu.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.4 -->
- <menu id="sudoku-menu">
+ <menu id="app-menu">
<section>
<submenu>
<attribute name="label" translatable="yes">_Print</attribute>
diff --git a/src/gnome-sudoku.gresource.xml.in b/src/gnome-sudoku.gresource.xml.in
index 6887afb..b9845c0 100644
--- a/src/gnome-sudoku.gresource.xml.in
+++ b/src/gnome-sudoku.gresource.xml.in
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/gnome-sudoku/ui">
+ <gresource prefix="/org/gnome/sudoku/ui">
<file alias="gnome-sudoku.ui" preprocess="xml-stripblanks">@top_srcdir@/data/gnome-sudoku.ui</file>
- <file alias="gnome-sudoku-menu.ui"
preprocess="xml-stripblanks">@top_srcdir@/data/gnome-sudoku-menu.ui</file>
<file alias="print-games.ui" preprocess="xml-stripblanks">@top_srcdir@/data/print-games.ui</file>
</gresource>
+ <gresource prefix="/org/gnome/sudoku/gtk">
+ <file alias="menus.ui" preprocess="xml-stripblanks">@top_srcdir@/data/gnome-sudoku-menu.ui</file>
+ </gresource>
</gresources>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index ba4b25f..d241b03 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -11,8 +11,6 @@ public class Sudoku : Gtk.Application
private int window_width;
private int window_height;
- private Builder builder;
-
private ApplicationWindow window;
// The current game and view, if they exist
@@ -116,8 +114,6 @@ public class Sudoku : Gtk.Application
}
protected override void activate () {
- builder = new Builder ();
-
var css_provider = new Gtk.CssProvider ();
try
{
@@ -132,15 +128,8 @@ public class Sudoku : Gtk.Application
}
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- try
- {
- builder.add_from_resource ("/org/gnome/gnome-sudoku/ui/gnome-sudoku.ui");
- builder.add_from_resource ("/org/gnome/gnome-sudoku/ui/gnome-sudoku-menu.ui");
- }
- catch (GLib.Error e)
- {
- GLib.warning ("Could not load UI: %s", e.message);
- }
+ var builder = new Builder.from_resource ("/org/gnome/sudoku/ui/gnome-sudoku.ui");
+
window = (ApplicationWindow) builder.get_object ("sudoku_app");
window.configure_event.connect (window_configure_event_cb);
window.window_state_event.connect (window_state_event_cb);
@@ -150,8 +139,6 @@ public class Sudoku : Gtk.Application
add_window (window);
- set_app_menu (builder.get_object ("sudoku-menu") as MenuModel);
-
header_bar = (HeaderBar) builder.get_object ("headerbar");
main_stack = (Stack) builder.get_object ("main_stack");
game_box = (Box) builder.get_object ("game_box");
diff --git a/src/sudoku-printer.vala b/src/sudoku-printer.vala
index b94a7c5..e2ebb03 100644
--- a/src/sudoku-printer.vala
+++ b/src/sudoku-printer.vala
@@ -238,15 +238,7 @@ public class GamePrinter: GLib.Object
this.window = window;
this.settings = new GLib.Settings ("org.gnome.sudoku");
- Gtk.Builder builder = new Builder ();
- try
- {
- builder.add_from_resource ("/org/gnome/gnome-sudoku/ui/print-games.ui");
- }
- catch (GLib.Error e)
- {
- GLib.warning ("Could not load UI: %s", e.message);
- }
+ Gtk.Builder builder = new Builder.from_resource ("/org/gnome/sudoku/ui/print-games.ui");
builder.connect_signals (null);
this.dialog = builder.get_object ("dialog") as Dialog;
dialog.set_transient_for (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]