From d0061bb0ef949b6a726cce4931c02646f5f895ab Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Fri, 11 Sep 2015 06:50:23 +0200 Subject: [PATCH] Better connectivity check (hopefully). --- src/extension.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/extension.js b/src/extension.js index a2891cd..786e391 100644 --- a/src/extension.js +++ b/src/extension.js @@ -397,7 +397,17 @@ const OpenweatherMenuButton = new Lang.Class({ }, _checkConnectionState: function() { - this._connected = this._network_monitor.network_available; + let url = this.getWeatherProviderURL(); + let address = Gio.NetworkAddress.parse_uri(url, 80); + let cancellable = Gio.Cancellable.new(); + this._connected = false; + try { + this._connected = this._network_monitor.can_reach(address, cancellable); + } catch (err) { + let title = _("Can not not connect to %s").format(url); + // Main.notifyError(title, err.message); + log(title + '\n' + err.message); + } if (this._connected) this.parseWeatherCurrent(); },