[polari/wip/dmoelgaard/initial-setup: 2/4] initialSetup: Add offline handling
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/dmoelgaard/initial-setup: 2/4] initialSetup: Add offline handling
- Date: Fri, 11 Aug 2017 00:39:00 +0000 (UTC)
commit d9972f38ff06f38d73d0b50d7067e0cd3c55b801
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 7 00:11:20 2017 +0200
initialSetup: Add offline handling
The guided setup assumes that we can connect to a newly connected
account and fetch the room list, which means it is fairly useless
without an internet connection - there's little we can do about
that, except for telling the user ...
https://bugzilla.gnome.org/show_bug.cgi?id=772458
data/resources/initial-setup-window.ui | 55 ++++++++++++++++++++++++++++++++
src/initialSetup.js | 32 ++++++++++++++----
2 files changed, 80 insertions(+), 7 deletions(-)
---
diff --git a/data/resources/initial-setup-window.ui b/data/resources/initial-setup-window.ui
index a183fc6..b663e7a 100644
--- a/data/resources/initial-setup-window.ui
+++ b/data/resources/initial-setup-window.ui
@@ -34,6 +34,61 @@
<property name="transition-type">slide-left-right</property>
<property name="vexpand">True</property>
<child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">18</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="pixel_size">64</property>
+ <property name="icon_name">network-offline-symbolic</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Not connected</property>
+ <style>
+ <class name="polari-setup-title"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Please connect to the internet to continue the
setup.</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">30</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="name">offline-hint</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="visible">True</property>
diff --git a/src/initialSetup.js b/src/initialSetup.js
index e677015..dc0149e 100644
--- a/src/initialSetup.js
+++ b/src/initialSetup.js
@@ -7,7 +7,8 @@ const Utils = imports.utils;
const SetupPage = {
CONNECTION: 0,
- ROOM: 1
+ ROOM: 1,
+ OFFLINE: 2
};
var InitialSetupWindow = new Lang.Class({
@@ -56,14 +57,29 @@ var InitialSetupWindow = new Lang.Class({
}
});
- this._setPage(SetupPage.CONNECTION);
+ this._networkMonitor = Gio.NetworkMonitor.get_default();
+ this._networkMonitor.connect('notify::network-available',
+ Lang.bind(this, this._onNetworkAvailableChanged));
+ this._onNetworkAvailableChanged();
+ },
+
+ _onNetworkAvailableChanged: function() {
+ if (this._networkMonitor.network_available)
+ this._setPage(this._currentAccount ? SetupPage.ROOM
+ : SetupPage.CONNECTION);
+ else
+ this._setPage(SetupPage.OFFLINE);
},
_setPage: function(page) {
- let isLastPage = page == SetupPage.ROOM;
+ if (page == SetupPage.CONNECTION)
+ this._contentStack.visible_child_name = 'connections';
+ else if (page == SetupPage.ROOM)
+ this._contentStack.visible_child_name = 'rooms';
+ else
+ this._contentStack.visible_child_name = 'offline-hint';
- this._contentStack.visible_child_name = isLastPage ? 'rooms'
- : 'connections';
+ let isLastPage = page == SetupPage.ROOM;
this._prevButton.label = isLastPage ? _("_Back") : _("_Cancel");
this._nextButton.label = isLastPage ? _("_Done") : _("_Next");
@@ -91,12 +107,14 @@ var InitialSetupWindow = new Lang.Class({
get _page() {
if (this._contentStack.visible_child_name == 'rooms')
return SetupPage.ROOM;
- else
+ else if (this._contentStack.visible_child_name == 'connections')
return SetupPage.CONNECTION;
+ else
+ return SetupPage.OFFLINE;
},
_updateNextSensitivity: function() {
- let sensitive = true;
+ let sensitive = this._page != SetupPage.OFFLINE;
if (this._page == SetupPage.ROOM)
sensitive = this._serverRoomList.can_join;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]