[gnome-maps] mainWindow: no-network-view on no connection



commit 0702eb59da11026d9e9ec2a890cb155f3b8c181e
Author: Shipra <bangashipra gmail com>
Date:   Mon Oct 13 13:47:16 2014 +0530

    mainWindow: no-network-view on no connection
    
    Check for connected property and switch to a 'no-network'
    view when not connected.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737221

 src/main-window.ui |   63 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/mainWindow.js  |   67 ++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 118 insertions(+), 12 deletions(-)
---
diff --git a/src/main-window.ui b/src/main-window.ui
index 3fcf81d..3e725a8 100644
--- a/src/main-window.ui
+++ b/src/main-window.ui
@@ -82,6 +82,69 @@
       <object class="GtkGrid" id="grid">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <child>
+          <object class="GtkStack" id="main-stack">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="transition-type">crossfade</property>
+            <child>
+              <object class="GtkSpinner" id="network-spinner">
+                <property name="visible">True</property>
+                <property name="active">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkGrid" id="no-network-view">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <child>
+                  <object class="GtkImage" id="no-network-conn-image">
+                    <property name="visible">True</property>
+                    <property name="pixel-size">100</property>
+                    <property name="icon-name">network-offline-symbolic</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkGrid" id="no-network-conn-message">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="margin-start">15</property>
+                    <child>
+                      <object class="GtkLabel" id="no-network-conn-header">
+                        <attributes>
+                          <attribute name="weight" value="bold" />
+                          <attribute name="scale" value="2" />
+                        </attributes>
+                        <property name="label" translatable="yes">Maps is offline!</property>
+                        <property name="halign">start</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="no-network-conn-text-1">
+                        <property name="wrap">True</property>
+                        <property name="max-width-chars">45</property>
+                        <property name="margin_top">10</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Maps need an active internet connection to 
function properly, but one can't be found.</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="no-network-conn-text-2">
+                        <property name="margin-top">2</property>
+                        <property name="wrap">True</property>
+                        <property name="max-width-chars">45</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Check your connection and proxy 
settings.</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
   </object>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 975e224..8a6ecfe 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -52,6 +52,10 @@ const MainWindow = new Lang.Class({
         let ui = Utils.getUIObject('main-window', [ 'app-window',
                                                     'header-bar',
                                                     'grid',
+                                                    'main-stack',
+                                                    'no-network-view',
+                                                    'goto-user-location-button',
+                                                    'toggle-sidebar-button',
                                                     'layers-button']);
         this.window = ui.appWindow;
         this.window.application = app;
@@ -62,28 +66,27 @@ const MainWindow = new Lang.Class({
 
         this.mapView.gotoUserLocation(false);
 
-        this._sidebar = new Sidebar.Sidebar(this.mapView);
-        Application.routeService.route.connect('update',
-                                               this._setRevealSidebar.bind(this, true));
-        this._sidebar.bind_property('reveal-child',
-                                    this.mapView, 'routeVisible',
-                                    GObject.BindingFlags.DEFAULT);
+        this._sidebar = this._createSidebar();
 
         this._contextMenu = new ContextMenu.ContextMenu(this.mapView);
 
         ui.layersButton.popover = new LayersPopover.LayersPopover();
 
-        let placeEntry = this._createPlaceEntry();
-        ui.headerBar.set_custom_title(placeEntry);
-        placeEntry.has_focus = true;
+        this._overlay.add_overlay(new ZoomControl.ZoomControl(this.mapView));
+
+        this._mainStack = ui.mainStack;
+        this._mainStack.add(this._overlay);
+        this._noNetworkView = ui.noNetworkView;
+        this._headerBar = ui.headerBar;
+        this._gotoUserLocationButton = ui.gotoUserLocationButton;
+        this._toggleSidebarButton = ui.toggleSidebarButton;
+        this._layersButton = ui.layersButton;
 
         this._initActions();
         this._initSignals();
+        this._initHeaderbar();
         this._restoreWindowGeometry();
 
-        this._overlay.add_overlay(new ZoomControl.ZoomControl(this.mapView));
-
-        ui.grid.attach(this._overlay, 0, 0, 1, 1);
         ui.grid.attach(this._sidebar, 1, 0, 1, 1);
 
         ui.grid.show_all();
@@ -111,6 +114,19 @@ const MainWindow = new Lang.Class({
         return placeEntry;
     },
 
+    _createSidebar: function() {
+        let sidebar = new Sidebar.Sidebar(this.mapView);
+        Application.routeService.route.connect('update',
+                                               this._setRevealSidebar.bind(this, true));
+        sidebar.bind_property('reveal-child',
+                              this.mapView, 'routeVisible',
+                              GObject.BindingFlags.DEFAULT);
+        this.window.application.bind_property('connected',
+                                              sidebar, 'visible',
+                                              GObject.BindingFlags.DEFAULT);
+        return sidebar;
+    },
+
     _initActions: function() {
         Utils.initActions(this.window, [
             {
@@ -163,9 +179,36 @@ const MainWindow = new Lang.Class({
 
         this.mapView.view.connect('button-press-event',
                                   this._overlay.grab_focus.bind(this._overlay));
+
+        this.window.application.connect('notify::connected', (function() {
+            if(this.window.application.connected)
+                this._mainStack.visible_child = this._overlay;
+            else
+                this._mainStack.visible_child = this._noNetworkView;
+        }).bind(this));
         this._viewMovedId = 0;
     },
 
+    _initHeaderbar: function() {
+        let placeEntry = this._createPlaceEntry();
+        this._headerBar.custom_title = placeEntry;
+        placeEntry.has_focus = true;
+
+        let app = this.window.application;
+        app.bind_property('connected',
+                          this._gotoUserLocationButton, 'sensitive',
+                          GObject.BindingFlags.DEFAULT);
+        app.bind_property('connected',
+                          this._layersButton, 'sensitive',
+                          GObject.BindingFlags.DEFAULT);
+        app.bind_property('connected',
+                          this._toggleSidebarButton, 'sensitive',
+                          GObject.BindingFlags.DEFAULT);
+        app.bind_property('connected',
+                          placeEntry, 'sensitive',
+                          GObject.BindingFlags.DEFAULT);
+    },
+
     _saveWindowGeometry: function() {
         let window = this.window.get_window();
         let state = window.get_state();


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