[gnome-robots] introduce RobotsApplication and RobotsWindow classes



commit 2b6ab8dde1d81337cb720da5c174339ed11ea71c
Author: Andrey Kutejko <andy128k gmail com>
Date:   Mon Sep 21 00:52:11 2020 +0200

    introduce RobotsApplication and RobotsWindow classes

 src/robots.vala | 637 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 318 insertions(+), 319 deletions(-)
---
diff --git a/src/robots.vala b/src/robots.vala
index cf01e0a..ed5bd57 100644
--- a/src/robots.vala
+++ b/src/robots.vala
@@ -20,64 +20,188 @@
 using Gtk;
 using Cairo;
 
-const string KEY_GEOMETRY_GROUP = "geometry";
-
-ApplicationWindow window = null;
+RobotsWindow window = null;
 int window_width = 0;
 int window_height = 0;
 bool window_is_maximized = false;
 GameArea game_area = null;
 Games.Scores.Context highscores;
 GLib.Settings settings;
-
-const GLib.ActionEntry[] app_entries = {
-    { "new-game",         new_game_cb    },
-    { "preferences",      preferences_cb },
-    { "scores",           scores_cb,     },
-    { "help",             help_cb,       },
-    { "about",            about_cb,      },
-    { "quit",             quit_cb,       },
-};
-
-const GLib.ActionEntry[] win_entries = {
-    { "random-teleport",  random_teleport_cb },
-    { "safe-teleport",    safe_teleport_cb   },
-    { "wait",             wait_cb            },
-};
-
-int safe_teleports = 0;
-Label safe_teleports_label;
-HeaderBar headerbar;
-
-EventControllerKey key_controller;
 uint control_keys[12];
 
-public void set_move_action_sensitivity (bool state) {
-    var action1 = (SimpleAction) window.lookup_action ("random-teleport");
-    action1.set_enabled (state);
+public class RobotsWindow : ApplicationWindow {
+
+    private HeaderBar headerbar;
+    private Label safe_teleports_label;
+    // private GameArea game_area;
+    private EventControllerKey key_controller;
+
+    public RobotsWindow (Gtk.Application app, GameArea game_area) {
+        Object (application: app);
+        // this.game_area = game_area;
+
+        headerbar = new HeaderBar ();
+        headerbar.set_title (_("Robots"));
+        headerbar.set_show_close_button (true);
+        set_titlebar (headerbar);
+
+        var appmenu = app.get_menu_by_id ("primary-menu");
+        var menu_button = new MenuButton ();
+        var icon = new Image.from_icon_name ("open-menu-symbolic", IconSize.BUTTON);
+        menu_button.set_image (icon);
+        menu_button.set_menu_model (appmenu);
+        menu_button.show ();
+        headerbar.pack_end (menu_button);
+
+        configure_event.connect (window_configure_event_cb);
+        window_state_event.connect (window_state_event_cb);
+        set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
+        if (settings.get_boolean ("window-is-maximized")) {
+            maximize ();
+        }
 
-    var action2 = (SimpleAction) window.lookup_action ("safe-teleport");
-    action2.set_enabled (state && safe_teleports > 0);
+        GLib.ActionEntry[] win_entries = {
+            { "random-teleport",  random_teleport_cb },
+            { "safe-teleport",    safe_teleport_cb   },
+            { "wait",             wait_cb            },
+        };
+        add_action_entries (win_entries, this);
 
-    var action3 = (SimpleAction) window.lookup_action ("wait");
-    action3.set_enabled (state);
-}
+        game_area.updated.connect (game => update_game_status (game));
+
+        var gridframe = new Games.GridFrame (game.width, game.height);
+        gridframe.add (game_area);
+
+        var hbox = button_box ();
+
+        var vbox = new Box (Orientation.VERTICAL, 0);
+        vbox.pack_start (gridframe, true, true, 0);
+        vbox.pack_start (hbox, false, false, 0);
+
+        add (vbox);
+
+        key_controller = new EventControllerKey (this);
+        key_controller.key_pressed.connect (keyboard_cb);
+    }
+
+    private Box button_box () {
+        var hbox = new Box (Orientation.HORIZONTAL, 0);
+        var size_group = new SizeGroup (SizeGroupMode.BOTH);
+
+        var style_context = hbox.get_style_context ();
+        style_context.add_class ("linked");
+
+        {
+            var label = new Label.with_mnemonic (_("Teleport _Randomly"));
+            label.margin_top = 15;
+            label.margin_bottom = 15;
+            var button = new Button ();
+            button.add (label);
+            button.set_action_name ("win.random-teleport");
+            size_group.add_widget (button);
+            hbox.pack_start (button, true, true, 0);
+        }
+
+        {
+            safe_teleports_label = new Label (null);
+            safe_teleports_label.set_justify (Justification.CENTER);
+            safe_teleports_label.margin_top = 15;
+            safe_teleports_label.margin_bottom = 15;
+            var button = new Button ();
+            button.add (safe_teleports_label);
+            button.set_action_name ("win.safe-teleport");
+            size_group.add_widget (button);
+            hbox.pack_start (button, true, true, 0);
+        }
+
+        {
+            var label = new Label.with_mnemonic (_("_Wait for Robots"));
+            label.margin_top = 15;
+            label.margin_bottom = 15;
+            var button = new Button ();
+            button.add (label);
+            button.set_action_name ("win.wait");
+            size_group.add_widget (button);
+            hbox.pack_start (button, true, true, 0);
+        }
+
+        return hbox;
+    }
+
+    public void update_game_status (Game game) {
+        headerbar.set_subtitle (
+            _("Level: %d\tScore: %d").printf (game.status.current_level, game.status.score));
+
+        /* Second line of safe teleports button label. %d is the number of teleports remaining. */
+        var remaining_teleports_text = _("(Remaining: %d)").printf (game.status.safe_teleports);
+        /* First line of safe teleports button label. */
+        var button_text = "%s\n<small>%s</small>".printf (_("Teleport _Safely"), remaining_teleports_text);
+        safe_teleports_label.set_markup_with_mnemonic (button_text);
+
+        var is_playing = game.state != Game.State.COMPLETE && game.state != Game.State.DEAD;
+
+        var action1 = (SimpleAction) window.lookup_action ("random-teleport");
+        action1.set_enabled (is_playing);
+
+        var action2 = (SimpleAction) window.lookup_action ("safe-teleport");
+        action2.set_enabled (is_playing && game.status.safe_teleports > 0);
+
+        var action3 = (SimpleAction) window.lookup_action ("wait");
+        action3.set_enabled (is_playing);
+    }
+
+    private void random_teleport_cb () {
+        if (game.player_command (Game.PlayerCommand.RANDOM_TELEPORT)) {
+            game_area.queue_draw ();
+        }
+    }
 
-public void update_game_status (int score, int current_level, int safes) {
-    /* Window subtitle. The first %d is the level, the second is the score. \t creates a tab. */
-    var subtitle = _("Level: %d\tScore: %d").printf (current_level, score);
-    headerbar.set_subtitle (subtitle);
+    private void safe_teleport_cb () {
+        if (game.player_command (Game.PlayerCommand.SAFE_TELEPORT)) {
+            game_area.queue_draw ();
+        }
+    }
+
+    private void wait_cb () {
+        if (game.player_command (Game.PlayerCommand.WAIT)) {
+            game_area.queue_draw ();
+        }
+    }
+
+    private bool keyboard_cb (uint keyval, uint keycode, Gdk.ModifierType state) {
+        /* This is a bit of a kludge to let through accelerator keys, otherwise
+         * if N is used as a key, then Ctrl-N is never picked up. The cleaner
+         * option, making the signal a connect_after signal skims the arrow keys
+         * before we can get to them which is a bigger problem. */
+        if ((state & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)) != 0) {
+            return false;
+        }
 
-    safe_teleports = safes;
+        char pressed = ((char) keyval).toupper ();
 
-    var action = (SimpleAction) window.lookup_action ("safe-teleport");
-    action.set_enabled (safe_teleports > 0);
+        for (var i = 0; i < control_keys.length; ++i) {
+            if (pressed == ((char)control_keys[i]).toupper ()) {
+                if (game.player_command ((Game.PlayerCommand)i)) {
+                    game_area.queue_draw ();
+                }
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private bool window_configure_event_cb () {
+        if (!window_is_maximized)
+            window.get_size (out window_width, out window_height);
+        return false;
+    }
 
-    /* Second line of safe teleports button label. %d is the number of teleports remaining. */
-    var remaining_teleports_text = _("(Remaining: %d)").printf (safe_teleports);
-    /* First line of safe teleports button label. */
-    var button_text = "%s\n<small>%s</small>".printf (_("Teleport _Safely"), remaining_teleports_text);
-    safe_teleports_label.set_markup_with_mnemonic (button_text);
+    private bool window_state_event_cb (Gdk.EventWindowState event) {
+        if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
+            window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
+        return false;
+    }
 }
 
 public string? category_name_from_key (string key) {
@@ -117,314 +241,194 @@ public string? category_name_from_key (string key) {
     }
 }
 
-void preferences_cb () {
-    show_properties_dialog ();
-}
-
-void scores_cb () {
-    game.show_scores ();
+Games.Scores.Category? create_category_from_key (string key) {
+    string name = category_name_from_key (key);
+    if (name == null)
+        return null;
+    return new Games.Scores.Category (key, name);
 }
 
-void help_cb () {
-    try {
-        show_uri_on_window (window, "help:gnome-robots", get_current_event_time ());
-    } catch (Error error) {
-        warning ("Failed to show help: %s", error.message);
+void keyboard_set (uint[] keys) {
+    for (int i = 0; i < 12; ++i) {
+        control_keys[i] = keys[i];
     }
 }
 
-void about_cb () {
-  string[] authors = { "Mark Rae <m rae inpharmatica co uk>" };
-
-  string[] artists = { "Kirstie Opstad <K Opstad ed ac uk>", "Rasoul M.P. Aghdam (player death sound)" };
-
-  string[] documenters = { "Aruna Sankaranarayanan" };
-
-  show_about_dialog (window,
-                     "name", _("Robots"),
-                     "version", VERSION,
-                     "copyright", "Copyright © 1998–2008 Mark Rae\nCopyright © 2014–2016 Michael Catanzaro",
-                     "license-type", License.GPL_3_0,
-                     "comments", _("Based on classic BSD Robots"),
-                     "authors", authors,
-                     "artists", artists,
-                     "documenters", documenters,
-                     "translator-credits", _("translator-credits"),
-                     "logo-icon-name", "org.gnome.Robots",
-                     "website",
-                     "https://wiki.gnome.org/Apps/Robots";);
-}
+class RobotsApplication : Gtk.Application {
+    public RobotsApplication () {
+        Object (
+            application_id: "org.gnome.Robots",
+            flags: ApplicationFlags.FLAGS_NONE);
+    }
 
-void quit_cb () {
-    quit_game ();
-}
+    protected override void startup () {
+        base.startup ();
 
-void new_game_cb () {
-    var dialog = new MessageDialog (window,
-                                    DialogFlags.MODAL,
-                                    MessageType.QUESTION,
-                                    ButtonsType.NONE,
-                                    _("Are you sure you want to discard the current game?"));
+        Environment.set_application_name (_("Robots"));
 
-    dialog.add_button (_("Keep _Playing"), ResponseType.REJECT);
-    dialog.add_button (_("_New Game"), ResponseType.ACCEPT);
+        settings = new GLib.Settings ("org.gnome.Robots");
 
-    var ret = dialog.run ();
-    dialog.destroy ();
+        Window.set_default_icon_name ("org.gnome.Robots");
 
-    if (ret == ResponseType.ACCEPT) {
-        game.start_new_game ();
-        game_area.queue_draw ();
-    }
-}
+        GLib.ActionEntry[] app_entries = {
+            { "new-game",         new_game_cb    },
+            { "preferences",      preferences_cb },
+            { "scores",           scores_cb      },
+            { "help",             help_cb        },
+            { "about",            about_cb       },
+            { "quit",             quit           },
+        };
+        add_action_entries (app_entries, this);
 
-void random_teleport_cb () {
-    if (game.player_command (Game.PlayerCommand.RANDOM_TELEPORT)) {
-        game_area.queue_draw ();
-    }
-}
+        set_accels_for_action ("app.new-game", { "<Primary>n" });
+        set_accels_for_action ("app.help", { "F1" });
+        set_accels_for_action ("app.quit", { "<Primary>q" });
 
-void safe_teleport_cb () {
-    if (game.player_command (Game.PlayerCommand.SAFE_TELEPORT)) {
-        game_area.queue_draw ();
+        make_cursors ();
     }
-}
 
-void wait_cb () {
-    if (game.player_command (Game.PlayerCommand.WAIT)) {
-        game_area.queue_draw ();
+    protected override void shutdown () {
+        base.shutdown ();
+        settings.set_int ("window-width", window_width);
+        settings.set_int ("window-height", window_height);
+        settings.set_boolean ("window-is-maximized", window_is_maximized);
     }
-}
-
-bool window_configure_event_cb () {
-    if (!window_is_maximized)
-        window.get_size (out window_width, out window_height);
-    return false;
-}
-
-bool window_state_event_cb (Widget widget, Gdk.EventWindowState event) {
-    if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
-        window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
-    return false;
-}
-
-public void quit_game () {
-    window.close ();
-}
-
-void startup (Gtk.Application app) {
-    Environment.set_application_name (_("Robots"));
-
-    settings = new GLib.Settings ("org.gnome.Robots");
 
-    Window.set_default_icon_name ("org.gnome.Robots");
+    protected override void activate () {
+        load_properties ();
 
-    app.add_action_entries (app_entries, app);
-
-    app.set_accels_for_action ("app.new-game", { "<Primary>n" });
-    app.set_accels_for_action ("app.help", { "F1" });
-    app.set_accels_for_action ("app.quit", { "<Primary>q" });
-
-    make_cursors ();
-}
+        if (window != null) {
+            window.present_with_time (get_current_event_time ());
+            return;
+        }
 
-void shutdown (Gtk.Application app) {
-    settings.set_int ("window-width", window_width);
-    settings.set_int ("window-height", window_height);
-    settings.set_boolean ("window-is-maximized", window_is_maximized);
-}
+        game_area = create_game_area ();
+        window = new RobotsWindow (this, game_area);
+
+        var importer = new Games.Scores.DirectoryImporter ();
+        highscores = new Games.Scores.Context.with_importer_and_icon_name ("gnome-robots",
+                                                                           /* Label on the scores dialog, 
next to map type dropdown */
+                                                                           _("Game Type:"),
+                                                                           window,
+                                                                           create_category_from_key,
+                                                                           
Games.Scores.Style.POINTS_GREATER_IS_BETTER,
+                                                                           importer,
+                                                                           "org.gnome.Robots");
+
+        window.show_all ();
+
+        try {
+            game_configs = new GameConfigs.load ();
+        } catch (Error e) {
+            /* Oops, no configs, we probably haven't been installed properly. */
+            var errordialog = new MessageDialog.with_markup (window,
+                                                             DialogFlags.MODAL,
+                                                             MessageType.ERROR,
+                                                             ButtonsType.OK,
+                                                             "<b>%s</b>\n\n%s",
+                                                             _("No game data could be found."),
+                                                             _("The program Robots was unable to find any 
valid game configuration files. Please check that the program is installed correctly."));
+            errordialog.set_resizable (false);
+            errordialog.run ();
+            quit ();
+        }
 
-Games.Scores.Category? create_category_from_key (string key) {
-    string name = category_name_from_key (key);
-    if (name == null)
-        return null;
-    return new Games.Scores.Category (key, name);
-}
+        game_area.background_color = properties.bgcolour;
 
-/**
- * Initialises the keyboard actions when the game first starts up
- **/
-void init_keyboard () {
-    key_controller = new EventControllerKey (window);
-    key_controller.key_pressed.connect (keyboard_cb);
-}
+        keyboard_set (properties.keys);
 
-void keyboard_set (uint[] keys) {
-    for (int i = 0; i < 12; ++i) {
-        control_keys[i] = keys[i];
-    }
-}
+        game.config = game_configs.find_by_name (properties.selected_config);
+        game.start_new_game ();
+        game_area.queue_draw ();
 
-bool keyboard_cb (EventControllerKey controller, uint keyval, uint keycode, Gdk.ModifierType state) {
-    /* This is a bit of a kludge to let through accelerator keys, otherwise
-     * if N is used as a key, then Ctrl-N is never picked up. The cleaner
-     * option, making the signal a connect_after signal skims the arrow keys
-     * before we can get to them which is a bigger problem. */
-    if ((state & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)) != 0) {
-        return false;
+        GLib.Settings.sync ();
     }
 
-    char pressed = ((char) keyval).toupper ();
-
-    for (var i = 0; i < control_keys.length; ++i) {
-        if (pressed == ((char)control_keys[i]).toupper ()) {
-            if (game.player_command ((Game.PlayerCommand)i)) {
-                game_area.queue_draw ();
-            }
-            return true;
+    private GameArea? create_game_area () {
+        try {
+            game = new Game ();
+            Theme theme = get_theme_from_properties ();
+            Bubble yahoo_bubble = new Bubble.from_data_file ("yahoo.png");
+            Bubble aieee_bubble = new Bubble.from_data_file ("aieee.png");
+            Bubble splat_bubble = new Bubble.from_data_file ("splat.png");
+            return new GameArea (game,
+                                 theme,
+                                 aieee_bubble,
+                                 yahoo_bubble,
+                                 splat_bubble);
+        } catch (Error e) {
+            critical ("%s", e.message);
+            // TODO message box
+            quit ();
+            return null; // this line should be unreachable
         }
     }
 
-    return false;
-}
+    private void new_game_cb () {
+        var dialog = new MessageDialog (get_active_window (),
+                                        DialogFlags.MODAL,
+                                        MessageType.QUESTION,
+                                        ButtonsType.NONE,
+                                        _("Are you sure you want to discard the current game?"));
 
-void activate (Gtk.Application app) {
-    load_properties ();
+        dialog.add_button (_("Keep _Playing"), ResponseType.REJECT);
+        dialog.add_button (_("_New Game"), ResponseType.ACCEPT);
 
-    if (window != null) {
-        window.present_with_time (get_current_event_time ());
-        return;
-    }
+        var ret = dialog.run ();
+        dialog.destroy ();
 
-    game = new Game ();
-
-    headerbar = new HeaderBar ();
-    headerbar.set_title (_("Robots"));
-    headerbar.set_show_close_button (true);
-
-    var appmenu = app.get_menu_by_id ("primary-menu");
-    var menu_button = new MenuButton ();
-    var icon = new Image.from_icon_name ("open-menu-symbolic", IconSize.BUTTON);
-    menu_button.set_image (icon);
-    menu_button.set_menu_model (appmenu);
-    menu_button.show ();
-    headerbar.pack_end (menu_button);
-
-    window = new ApplicationWindow (app);
-    window.set_titlebar (headerbar);
-    window.configure_event.connect (window_configure_event_cb);
-    window.window_state_event.connect (window_state_event_cb);
-    window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
-    if (settings.get_boolean ("window-is-maximized")) {
-        window.maximize ();
-    }
-
-    window.add_action_entries (win_entries, app);
-
-    Theme theme = null;
-    Bubble aieee_bubble = null;
-    Bubble yahoo_bubble = null;
-    Bubble splat_bubble = null;
-    try {
-        theme = get_theme_from_properties ();
-        yahoo_bubble = new Bubble.from_data_file ("yahoo.png");
-        aieee_bubble = new Bubble.from_data_file ("aieee.png");
-        splat_bubble = new Bubble.from_data_file ("splat.png");
-    } catch (Error e) {
-        critical ("%s", e.message);
-        // TODO message box
-        app.quit ();
+        if (ret == ResponseType.ACCEPT) {
+            game.start_new_game ();
+            game_area.queue_draw ();
+        }
     }
 
-    game_area = new GameArea (game,
-                              theme,
-                              aieee_bubble,
-                              yahoo_bubble,
-                              splat_bubble);
-    game_area.destroy.connect (() => game_area = null);
-    game_area.updated.connect (game => {
-        var status = game.status;
-        update_game_status (status.score, status.current_level, status.safe_teleports);
-        set_move_action_sensitivity (game.state != Game.State.COMPLETE && game.state != Game.State.DEAD);
-    });
-
-    var gridframe = new Games.GridFrame (game.width, game.height);
-    gridframe.add (game_area);
-
-    var hbox = new Box (Orientation.HORIZONTAL, 0);
-    var size_group = new SizeGroup (SizeGroupMode.BOTH);
-
-    var style_context = hbox.get_style_context ();
-    style_context.add_class ("linked");
-
-    {
-        var label = new Label.with_mnemonic (_("Teleport _Randomly"));
-        label.margin_top = 15;
-        label.margin_bottom = 15;
-        var button = new Button ();
-        button.add (label);
-        button.set_action_name ("win.random-teleport");
-        size_group.add_widget (button);
-        hbox.pack_start (button, true, true, 0);
+    private void preferences_cb () {
+        show_properties_dialog ();
     }
 
-    {
-        safe_teleports_label = new Label (null);
-        safe_teleports_label.set_justify (Justification.CENTER);
-        safe_teleports_label.margin_top = 15;
-        safe_teleports_label.margin_bottom = 15;
-        var button = new Button ();
-        button.add (safe_teleports_label);
-        button.set_action_name ("win.safe-teleport");
-        size_group.add_widget (button);
-        hbox.pack_start (button, true, true, 0);
+    private void scores_cb () {
+        game.show_scores ();
     }
 
-    {
-        var label = new Label.with_mnemonic (_("_Wait for Robots"));
-        label.margin_top = 15;
-        label.margin_bottom = 15;
-        var button = new Button ();
-        button.add (label);
-        button.set_action_name ("win.wait");
-        size_group.add_widget (button);
-        hbox.pack_start (button, true, true, 0);
+    private void help_cb () {
+        try {
+            show_uri_on_window (window, "help:gnome-robots", get_current_event_time ());
+        } catch (Error error) {
+            warning ("Failed to show help: %s", error.message);
+        }
     }
 
-    var vbox = new Box (Orientation.VERTICAL, 0);
-    vbox.pack_start (gridframe, true, true, 0);
-    vbox.pack_start (hbox, false, false, 0);
-
-    window.add (vbox);
-
-    var importer = new Games.Scores.DirectoryImporter ();
-    highscores = new Games.Scores.Context.with_importer_and_icon_name ("gnome-robots",
-                                                                       /* Label on the scores dialog, next 
to map type dropdown */
-                                                                       _("Game Type:"),
-                                                                       window,
-                                                                       create_category_from_key,
-                                                                       
Games.Scores.Style.POINTS_GREATER_IS_BETTER,
-                                                                       importer,
-                                                                       "org.gnome.Robots");
-
-    window.show_all ();
-
-    try {
-        game_configs = new GameConfigs.load ();
-    } catch (Error e) {
-        /* Oops, no configs, we probably haven't been installed properly. */
-        var errordialog = new MessageDialog.with_markup (window,
-                                                         DialogFlags.MODAL,
-                                                         MessageType.ERROR,
-                                                         ButtonsType.OK,
-                                                         "<b>%s</b>\n\n%s",
-                                                         _("No game data could be found."),
-                                                         _("The program Robots was unable to find any valid 
game configuration files. Please check that the program is installed correctly."));
-        errordialog.set_resizable (false);
-        errordialog.run ();
-        app.quit ();
+    private void about_cb () {
+        string[] authors = {
+            "Mark Rae <m rae inpharmatica co uk>"
+        };
+
+        string[] artists = {
+            "Kirstie Opstad <K Opstad ed ac uk>",
+            "Rasoul M.P. Aghdam (player death sound)"
+        };
+
+        string[] documenters = {
+            "Aruna Sankaranarayanan"
+        };
+
+        show_about_dialog (get_active_window (),
+                           "name", _("Robots"),
+                           "version", VERSION,
+                           "copyright", "Copyright © 1998–2008 Mark Rae\n"
+                                + "Copyright © 2014–2016 Michael Catanzaro\n"
+                                + "Copyright © 2020 Andrey Kutejko",
+                           "license-type", License.GPL_3_0,
+                           "comments", _("Based on classic BSD Robots"),
+                           "authors", authors,
+                           "artists", artists,
+                           "documenters", documenters,
+                           "translator-credits", _("translator-credits"),
+                           "logo-icon-name", "org.gnome.Robots",
+                           "website",
+                           "https://wiki.gnome.org/Apps/Robots";);
     }
-
-    game_area.background_color = properties.bgcolour;
-
-    keyboard_set (properties.keys);
-    init_keyboard ();
-
-    game.config = game_configs.find_by_name (properties.selected_config);
-    game.start_new_game ();
-    game_area.queue_draw ();
-
-    GLib.Settings.sync ();
 }
 
 public static int main (string[] args) {
@@ -433,12 +437,7 @@ public static int main (string[] args) {
     Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
     Intl.textdomain (GETTEXT_PACKAGE);
 
-    var app = new Gtk.Application ("org.gnome.Robots", ApplicationFlags.FLAGS_NONE);
-
-    app.startup.connect (() => startup (app));
-    app.shutdown.connect (() => shutdown (app));
-    app.activate.connect (() => activate (app));
-
+    var app = new RobotsApplication ();
     return app.run (args);
 }
 


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