[gnome-maps/wip/fix-geoloc: 7/11] MainWindow: make _init smaller



commit 39562cfe172fbd3a2baf44c5b14f4cc23e30d610
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Thu Jul 11 04:02:02 2013 +0200

    MainWindow: make _init smaller
    
    Split out initialization of actions and restoration of window geometry
    from _init making it a bit more manageable.

 src/mainWindow.js |   88 ++++++++++++++++++++++++++++------------------------
 1 files changed, 47 insertions(+), 41 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 267c2ab..fd9a850 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -56,47 +56,8 @@ const MainWindow = new Lang.Class({
         this.window = ui.appWindow;
         this.window.application = app;
 
-        Utils.initActions(this.window, [
-            { 
-                properties: { name: 'about' }, 
-                signalHandlers: { activate: this._onAboutActivate }
-            }, {
-                properties: {
-                    name: 'map-type-menu', 
-                    state: GLib.Variant.new('b', false)
-                },
-                signalHandlers: { activate: this._onMapTypeMenuActivate }
-            }, {
-                properties: {
-                    name: 'map-type',
-                    parameter_type: GLib.VariantType.new('s'),
-                    state: GLib.Variant.new('s', 'STREET')
-                },
-                signalHandlers: { activate: this._onMapTypeActivate }
-            }
-        ], this);
-
-        // apply the last saved window size and position
-        let size = Application.settings.get_value('window-size');
-        if (size.n_children() == 2) {
-            let width = size.get_child_value(0);
-            let height = size.get_child_value(1);
-
-            this.window.set_default_size(width.get_int32(),
-                                         height.get_int32());
-        }
-
-        let position = Application.settings.get_value('window-position');
-        if (position.n_children() == 2) {
-            let x = position.get_child_value(0);
-            let y = position.get_child_value(1);
-
-            this.window.move(x.get_int32(),
-                             y.get_int32());
-        }
-
-        if (Application.settings.get_boolean('window-maximized'))
-            this.window.maximize();
+        this._initActions();
+        this._restoreWindowGeometry();
 
         this.window.connect('delete-event', Lang.bind(this, this._quit));
         this.window.connect('configure-event',
@@ -146,6 +107,28 @@ const MainWindow = new Lang.Class({
         grid.show_all();
     },
 
+    _initActions: function() {
+        Utils.initActions(this.window, [
+            {
+                properties: { name: 'about' },
+                signalHandlers: { activate: this._onAboutActivate }
+            }, {
+                properties: {
+                    name: 'map-type-menu',
+                    state: GLib.Variant.new('b', false)
+                },
+                signalHandlers: { activate: this._onMapTypeMenuActivate }
+            }, {
+                properties: {
+                    name: 'map-type',
+                    parameter_type: GLib.VariantType.new('s'),
+                    state: GLib.Variant.new('s', 'STREET')
+                },
+                signalHandlers: { activate: this._onMapTypeActivate }
+            }
+        ], this);
+    },
+
     _saveWindowGeometry: function() {
         let window = this.window.get_window();
         let state = window.get_state();
@@ -163,6 +146,29 @@ const MainWindow = new Lang.Class({
         Application.settings.set_value('window-position', variant);
     },
 
+    _restoreWindowGeometry: function() {
+        let size = Application.settings.get_value('window-size');
+        if (size.n_children() === 2) {
+            let width = size.get_child_value(0);
+            let height = size.get_child_value(1);
+
+            this.window.set_default_size(width.get_int32(),
+                                         height.get_int32());
+        }
+
+        let position = Application.settings.get_value('window-position');
+        if (position.n_children() === 2) {
+            let x = position.get_child_value(0);
+            let y = position.get_child_value(1);
+
+            this.window.move(x.get_int32(),
+                             y.get_int32());
+        }
+
+        if (Application.settings.get_boolean('window-maximized'))
+            this.window.maximize();
+    },
+
     _onConfigureEvent: function(widget, event) {
         if (this._configureId !== 0) {
             Mainloop.source_remove(this._configureId);


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