[gnome-games/sudoku-vala] Split off the main method from gnome-sudoku.vala in to main.vala, modifying Makefile.am acordingly.



commit f2fd9c1faa67fbcf2044dbecfc74b3ef79569970
Author: Christopher Baines <cbaines8 gmail com>
Date:   Wed May 9 13:50:29 2012 +0100

    Split off the main method from gnome-sudoku.vala in to main.vala, modifying Makefile.am acordingly.

 gnome-sudoku/src/Makefile.am       |    2 +
 gnome-sudoku/src/gnome-sudoku.vala |   47 --------------------------
 gnome-sudoku/src/main.vala         |   65 ++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 47 deletions(-)
---
diff --git a/gnome-sudoku/src/Makefile.am b/gnome-sudoku/src/Makefile.am
index b706d87..46546d1 100644
--- a/gnome-sudoku/src/Makefile.am
+++ b/gnome-sudoku/src/Makefile.am
@@ -2,6 +2,7 @@ bin_PROGRAMS = gnome-sudoku
 
 gnome_sudoku_SOURCES = \
 	config.vapi \
+	main.vala \
 	gnome-sudoku.vala \
 	sudoku-game.vala \
 	sudoku-generator.vala \
@@ -10,6 +11,7 @@ gnome_sudoku_SOURCES = \
 gnome_sudoku_CFLAGS = \
 	-DPKGDATADIR=\"@datadir@/gnome-sudoku\" \
 	-DLOCALEDIR=\"@localedir \" \
+	-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
 	$(GTK_CFLAGS) \
 	$(GMODULE_CFLAGS) \
 	$(WARN_CFLAGS)
diff --git a/gnome-sudoku/src/gnome-sudoku.vala b/gnome-sudoku/src/gnome-sudoku.vala
index 2c48107..a489d5f 100644
--- a/gnome-sudoku/src/gnome-sudoku.vala
+++ b/gnome-sudoku/src/gnome-sudoku.vala
@@ -221,50 +221,3 @@ public class Application
         about_dialog = null;
     }
 }
-
-class GNOMESudoku
-{
-    static bool show_version;
-    public static const OptionEntry[] options =
-    {
-        { "version", 'v', 0, OptionArg.NONE, ref show_version,
-          /* Help string for command line --version flag */
-          N_("Show release version"), null},
-        { null }
-    };
-
-    public static int main (string[] args)
-    {
-        Gtk.init (ref args);
-
-        var c = new OptionContext (/* Arguments and description for --help text */
-                                   _("[FILE] - Play Sudoku"));
-        c.add_main_entries (options, Config.GETTEXT_PACKAGE);
-        c.add_group (Gtk.get_option_group (true));
-        try
-        {
-            c.parse (ref args);
-        }
-        catch (Error e)
-        {
-            stderr.printf ("%s\n", e.message);
-            stderr.printf (/* Text printed out when an unknown command-line argument provided */
-                           _("Run '%s --help' to see a full list of available command line options."), args[0]);
-            stderr.printf ("\n");
-            return Posix.EXIT_FAILURE;
-        }
-        if (show_version)
-        {
-            /* Note, not translated so can be easily parsed */
-            stderr.printf ("gnome-sudoku %s\n", Config.VERSION);
-            return Posix.EXIT_SUCCESS;
-        }
-
-        Application app = new Application ();
-        app.start ();
-
-        Gtk.main ();
-
-        return 0;
-    }
-}
diff --git a/gnome-sudoku/src/main.vala b/gnome-sudoku/src/main.vala
new file mode 100644
index 0000000..267dec4
--- /dev/null
+++ b/gnome-sudoku/src/main.vala
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Robert Ancell <robert ancell gmail com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+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 */      
+    N_("Show release version"), null},
+    { null }
+};
+
+public static int main (string[] args)
+{
+    Gtk.init (ref args);
+
+    var c = new OptionContext (/* Arguments and description for --help text */
+                                   _("[FILE] - Play Sudoku"));
+    c.add_main_entries (options, Config.GETTEXT_PACKAGE);
+    c.add_group (Gtk.get_option_group (true));
+    try
+    {
+        c.parse (ref args);
+    }
+    catch (Error e)
+    {
+        stderr.printf ("%s\n", e.message);
+        stderr.printf (/* Text printed out when an unknown command-line argument provided */
+                       _("Run '%s --help' to see a full list of available command line options."), args[0]);
+        stderr.printf ("\n");
+        return Posix.EXIT_FAILURE;
+    }
+    if (show_version)
+    {
+        /* Note, not translated so can be easily parsed */
+        stderr.printf ("gnome-sudoku %s\n", Config.VERSION);
+        return Posix.EXIT_SUCCESS;
+    }
+
+    Application app = new Application ();
+    app.start ();
+
+    Gtk.main ();
+
+    return 0;
+}
+
+
+



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