[gnome-maps/wip/fix-geoloc: 2/2] MainWindow: split out signal setup



commit a4c34e7ca7b91759a0b4c6b42d59ce8772955f6a
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Wed Jul 17 07:19:40 2013 +0200

    MainWindow: split out signal setup
    
    Split out signal connection setup into its own method, finally
    making the _init of MainWindow reasonably short.

 src/mainWindow.js |   80 +++++++++++++++++++++++++++-------------------------
 1 files changed, 42 insertions(+), 38 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 60d00be..842a153 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -56,34 +56,14 @@ const MainWindow = new Lang.Class({
         this.window = ui.appWindow;
         this.window.application = app;
 
-        this._initActions();
-        this._restoreWindowGeometry();
-
-        this.window.connect('delete-event', Lang.bind(this, this._quit));
-        this.window.connect('configure-event',
-                            Lang.bind(this, this._onConfigureEvent));
-        this.window.connect('window-state-event',
-                            Lang.bind(this, this._onWindowStateEvent));
-
-        this._searchEntry.connect('activate',
-                                  Lang.bind(this, this._onSearchActivate));
-
         this.mapView = new MapView.MapView();
 
         if(Application.settings.get_boolean('track-user-location'))
             this.mapView.gotoUserLocation(false);
 
-        this._connectMapMove();
-        this.mapView.connect('going-to-user-location',
-                             this._disconnectMapMove.bind(this));
-        this.mapView.connect('gone-to-user-location',
-                             this._connectMapMove.bind(this));
-        
-        Application.settings.connect('changed::track-user-location', (function() {
-            if(Application.settings.get_boolean('track-user-location')) {
-                this.mapView.gotoUserLocation(true);
-            }
-        }).bind(this));
+        this._initActions();
+        this._initSignals();
+        this._restoreWindowGeometry();
 
         grid.add(this.mapView);
 
@@ -114,6 +94,45 @@ const MainWindow = new Lang.Class({
             Application.settings.create_action('track-user-location'));
     },
 
+    _initSignals: function() {
+        this.window.connect('delete-event', Lang.bind(this, this._quit));
+        this.window.connect('configure-event',
+                            Lang.bind(this, this._onConfigureEvent));
+        this.window.connect('window-state-event',
+                            Lang.bind(this, this._onWindowStateEvent));
+
+        this._searchEntry.connect('activate',
+                                  Lang.bind(this, this._onSearchActivate));
+
+        this._connectMapMove();
+        this.mapView.connect('going-to-user-location',
+                             this._disconnectMapMove.bind(this));
+        this.mapView.connect('gone-to-user-location',
+                             this._connectMapMove.bind(this));
+
+        Application.settings.connect('changed::track-user-location', (function() {
+            if(Application.settings.get_boolean('track-user-location')) {
+                this.mapView.gotoUserLocation(true);
+            }
+        }).bind(this));
+    },
+
+    _connectMapMove: function() {
+        if(!this._viewMovedId) {
+            this._viewMovedId = this.mapView.connect('view-moved', (function() {
+                if (!this.mapView.userLocationVisible())
+                    Application.settings.set_boolean('track-user-location', false);
+            }).bind(this));
+        }
+    },
+
+    _disconnectMapMove: function() {
+        if(this._viewMovedId) {
+            this.mapView.disconnect(this._viewMovedId);
+            this._viewMovedId = undefined;
+        }
+    },
+
     _saveWindowGeometry: function() {
         let window = this.window.get_window();
         let state = window.get_state();
@@ -167,21 +186,6 @@ const MainWindow = new Lang.Class({
             }));
     },
 
-    _connectMapMove: function() {
-        if(!this._viewMovedId) {
-            this._viewMovedId = this.mapView.connect('view-moved', (function() {
-                if (!this.mapView.userLocationVisible())
-                    Application.settings.set_boolean('track-user-location', false);
-            }).bind(this));
-        }
-    },
-    _disconnectMapMove: function() {
-        if(this._viewMovedId) {
-            this.mapView.disconnect(this._viewMovedId);
-            this._viewMovedId = undefined;
-        }
-    },
-    
     _onWindowStateEvent: function(widget, event) {
         let window = widget.get_window();
         let state = window.get_state();


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