[gnome-maps/wip/fix-geoloc: 7/11] MainWindow: make _init smaller
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/fix-geoloc: 7/11] MainWindow: make _init smaller
- Date: Wed, 24 Jul 2013 05:58:22 +0000 (UTC)
commit ccacf84dda39d2b1d9d04ab0535439d0a22d81bd
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.
https://bugzilla.gnome.org/show_bug.cgi?id=704537
src/mainWindow.js | 88 ++++++++++++++++++++++++++++------------------------
1 files changed, 47 insertions(+), 41 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 9a901c8..7fd2eb1 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', this._quit.bind(this));
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]