[gnome-games/sudoku-vala] Use GTKApplication



commit f80c2370e830d69402413f9b4ee2604fbe4b50c4
Author: Christopher Baines <cbaines8 gmail com>
Date:   Wed May 9 23:16:07 2012 +0100

    Use GTKApplication
    
    Have the main class extend GTKApplication.
    Remove incorrect whitespace introduced in a previous commit.

 gnome-sudoku/src/Makefile.am       |    4 +++-
 gnome-sudoku/src/gnome-sudoku.vala |   26 +++++++++++++-------------
 gnome-sudoku/src/main.vala         |   11 +++--------
 3 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/gnome-sudoku/src/Makefile.am b/gnome-sudoku/src/Makefile.am
index 46546d1..5c68a71 100644
--- a/gnome-sudoku/src/Makefile.am
+++ b/gnome-sudoku/src/Makefile.am
@@ -23,7 +23,9 @@ gnome_sudoku_LDADD = \
 gnome_sudoku_VALAFLAGS = \
     --pkg posix \
     --pkg gtk+-3.0 \
-    --pkg gmodule-2.0
+    --pkg gmodule-2.0 \
+    --vapidir $(top_srcdir)/libgames-support \
+    --pkg GnomeGamesSupport-1.0
 
 DISTCLEANFILES = \
 	Makefile.in
diff --git a/gnome-sudoku/src/gnome-sudoku.vala b/gnome-sudoku/src/gnome-sudoku.vala
index a489d5f..e7c775d 100644
--- a/gnome-sudoku/src/gnome-sudoku.vala
+++ b/gnome-sudoku/src/gnome-sudoku.vala
@@ -1,4 +1,4 @@
-public class Application
+public class Sudoku : Gtk.Application
 {
     private Settings settings;
     private Gtk.Builder builder;
@@ -11,8 +11,12 @@ public class Application
 
     private Gtk.AboutDialog? about_dialog = null;
 
-    public Application ()
+    public Sudoku ()
     {
+        Object (application_id: "org.gnome.gnome-sudoku", flags: ApplicationFlags.FLAGS_NONE);
+    }
+
+    protected override void activate () {
         settings = new Settings ("org.gnome.gnome-sudoku");
 
         builder = new Gtk.Builder ();
@@ -25,6 +29,12 @@ public class Application
             GLib.warning ("Could not load UI: %s", e.message);
         }
         window = (Gtk.Window) builder.get_object ("sudoku_app");
+
+        if (settings.get_boolean ("fullscreen"))
+            window.fullscreen ();
+
+        add_window (window);
+
         fullscreen_menu = (Gtk.CheckMenuItem) builder.get_object ("toggle_fullscreen_imagemenuitem");
         var main_vbox = (Gtk.VBox) builder.get_object ("main_vbox");
         toolbar = (Gtk.Toolbar) builder.get_object ("sudoku_toolbar");
@@ -37,17 +47,7 @@ public class Application
         view.show ();
         main_vbox.pack_start (view);
         builder.connect_signals (this);
-    }
-    
-    public void start ()
-    {
-        if (settings.get_boolean ("fullscreen"))
-            window.fullscreen ();
-        show ();
-    }
 
-    public void show ()
-    {
         window.show ();
     }
 
@@ -96,7 +96,7 @@ public class Application
     [CCode (cname = "G_MODULE_EXPORT quit_cb", instance_pos = -1)]
     public void quit_cb (Gtk.Widget widget)
     {
-        Gtk.main_quit ();
+        window.destroy ();
     }
 
     [CCode (cname = "G_MODULE_EXPORT sudoku_app_window_state_event_cb", instance_pos = -1)]
diff --git a/gnome-sudoku/src/main.vala b/gnome-sudoku/src/main.vala
index 267dec4..38c7751 100644
--- a/gnome-sudoku/src/main.vala
+++ b/gnome-sudoku/src/main.vala
@@ -21,7 +21,7 @@ private static bool show_version;
 private static const OptionEntry[] options =
 {
     { "version", 'v', 0, OptionArg.NONE, ref show_version,
-    /* Help string for command line --version flag */      
+    /* Help string for command line --version flag */
     N_("Show release version"), null},
     { null }
 };
@@ -53,13 +53,8 @@ public static int main (string[] args)
         return Posix.EXIT_SUCCESS;
     }
 
-    Application app = new Application ();
-    app.start ();
+    var app = new Sudoku ();
 
-    Gtk.main ();
-
-    return 0;
+    return app.run ();
 }
 
-
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]