[gnome-games] lightsoff: Use GMenu
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] lightsoff: Use GMenu
- Date: Mon, 20 Feb 2012 05:07:20 +0000 (UTC)
commit 566efb7db942a8c70a16ae8beb0b26a54f8b7e42
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Feb 20 16:07:07 2012 +1100
lightsoff: Use GMenu
lightsoff/data/Makefile.am | 1 -
lightsoff/data/lightsoff.ui | 98 ------------------------------------------
lightsoff/src/lightsoff.vala | 45 ++++++++-----------
3 files changed, 18 insertions(+), 126 deletions(-)
---
diff --git a/lightsoff/data/Makefile.am b/lightsoff/data/Makefile.am
index c4439a8..690983d 100644
--- a/lightsoff/data/Makefile.am
+++ b/lightsoff/data/Makefile.am
@@ -1,6 +1,5 @@
lightsoffdir = $(datadir)/lightsoff
lightsoff_DATA = \
- lightsoff.ui \
arrow.svg \
backing.svg \
led-back.svg \
diff --git a/lightsoff/src/lightsoff.vala b/lightsoff/src/lightsoff.vala
index 0874950..003fe51 100644
--- a/lightsoff/src/lightsoff.vala
+++ b/lightsoff/src/lightsoff.vala
@@ -1,40 +1,35 @@
public class LightsOff : Gtk.Application
{
private Settings settings;
- private Gtk.Builder ui;
private Gtk.Window window;
private GameView game_view;
+
+ private const GLib.ActionEntry[] action_entries =
+ {
+ { "new-game", new_game_cb },
+ { "quit", quit_cb },
+ { "help", help_cb },
+ { "about", about_cb }
+ };
private LightsOff ()
{
Object (application_id: "org.gnome.lightsoff", flags: ApplicationFlags.FLAGS_NONE);
}
-
+
protected override void startup ()
{
base.startup ();
- settings = new Settings ("org.gnome.lightsoff");
+ add_action_entries (action_entries, this);
- ui = new Gtk.Builder();
- try
- {
- ui.add_from_file (Path.build_filename (Config.DATADIR, "lightsoff.ui"));
- }
- catch (Error e)
- {
- warning ("Could not load UI: %s", e.message);
- }
- ui.connect_signals (this);
-
- window = (Gtk.Window) ui.get_object ("game_window");
- add_window (window);
+ settings = new Settings ("org.gnome.lightsoff");
- var box = (Gtk.Box) ui.get_object ("game_vbox");
+ window = new Gtk.ApplicationWindow (this);
var clutter_embed = new GtkClutter.Embed ();
clutter_embed.show ();
- box.pack_start (clutter_embed, true, true);
+ window.add (clutter_embed);
var stage = (Clutter.Stage) clutter_embed.get_stage ();
stage.key_release_event.connect (key_release_event_cb);
@@ -84,23 +79,20 @@ public class LightsOff : Gtk.Application
public override void activate ()
{
- window.show ();
+ window.present ();
}
- [CCode (cname = "G_MODULE_EXPORT new_game_cb", instance_pos = -1)]
- public void new_game_cb (Gtk.Widget widget)
+ private void new_game_cb ()
{
game_view.reset_game();
}
- [CCode (cname = "G_MODULE_EXPORT quit_cb", instance_pos = -1)]
- public void quit_cb (Gtk.Widget widget)
+ private void quit_cb ()
{
window.destroy ();
}
- [CCode (cname = "G_MODULE_EXPORT help_cb", instance_pos = -1)]
- public void help_cb (Gtk.Widget widget)
+ private void help_cb ()
{
try
{
@@ -112,8 +104,7 @@ public class LightsOff : Gtk.Application
}
}
- [CCode (cname = "G_MODULE_EXPORT about_cb", instance_pos = -1)]
- public void about_cb (Gtk.Widget widget)
+ private void about_cb ()
{
string[] authors =
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]