[gnome-games] Mahjongg: Use GtkApplication and Remove Gtk.main_quit()
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Mahjongg: Use GtkApplication and Remove Gtk.main_quit()
- Date: Thu, 22 Dec 2011 11:02:27 +0000 (UTC)
commit 54d1aca66a2d0a68d0f8e38da9fa2ca239b656ee
Author: Sophia Yu <sophia receiving gmail com>
Date: Thu Dec 22 01:54:02 2011 -0600
Mahjongg: Use GtkApplication and Remove Gtk.main_quit()
mahjongg/src/mahjongg.vala | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/mahjongg/src/mahjongg.vala b/mahjongg/src/mahjongg.vala
index a5afc3d..ee04ad5 100644
--- a/mahjongg/src/mahjongg.vala
+++ b/mahjongg/src/mahjongg.vala
@@ -1,4 +1,4 @@
-public class Mahjongg
+public class Mahjongg : Gtk.Application
{
private Settings settings;
@@ -26,6 +26,8 @@ public class Mahjongg
public Mahjongg ()
{
+ Object (application_id: "org.gnome.mahjongg", flags: ApplicationFlags.FLAGS_NONE);
+
settings = new Settings ("org.gnome.mahjongg");
load_maps ();
@@ -44,6 +46,7 @@ public class Mahjongg
window.title = _("Mahjongg");
window.set_default_size (530, 440);
GnomeGamesSupport.settings_bind_window_state ("/org/gnome/mahjongg/", window);
+ add_window (window);
var status_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
@@ -84,8 +87,6 @@ public class Mahjongg
window.add_accel_group (ui_manager.get_accel_group ());
var box = ui_manager.get_widget ("/MainMenu");
- window.delete_event.connect (window_delete_event_cb);
-
game_view = new GameView ();
game_view.button_press_event.connect (view_button_press_event);
game_view.set_size_request (320, 200);
@@ -111,6 +112,11 @@ public class Mahjongg
game_view.grab_focus ();
}
+ public override void activate ()
+ {
+ window.show ();
+ }
+
public void start ()
{
window.show_all ();
@@ -273,7 +279,7 @@ public class Mahjongg
switch (scores_dialog.run ())
{
case Gtk.ResponseType.REJECT:
- Gtk.main_quit ();
+ window.destroy ();
break;
default:
new_game ();
@@ -575,15 +581,9 @@ public class Mahjongg
game_view.queue_draw ();
}
- private bool window_delete_event_cb (Gdk.EventAny event)
- {
- Gtk.main_quit ();
- return true;
- }
-
private void quit_cb ()
{
- Gtk.main_quit ();
+ window.destroy ();
}
private void redo_cb (Gtk.Action action)
@@ -801,12 +801,12 @@ public class Mahjongg
var app = new Mahjongg ();
app.start ();
- Gtk.main ();
+ var result = app.run ();
Settings.sync();
GnomeGamesSupport.runtime_shutdown ();
- return Posix.EXIT_SUCCESS;
+ return result;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]