[gnome-shell] userMenu: Delay restoring presence until the network comes up
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] userMenu: Delay restoring presence until the network comes up
- Date: Mon, 20 Aug 2012 22:10:48 +0000 (UTC)
commit 0f065ebce60225186ff70e199747a636c53dd201
Author: Florian MÃllner <fmuellner gnome org>
Date: Wed Jun 13 01:03:33 2012 +0200
userMenu: Delay restoring presence until the network comes up
Trying to connect to IM servers while offline is pointless, in
particular now that we added a progress indication which makes
the connection attempt very visible.
To fix, wait for the network to become available until restoring
a previous IM presence.
https://bugzilla.gnome.org/show_bug.cgi?id=677982
js/ui/userMenu.js | 38 ++++++++++++++++++++++++++------------
1 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index c981e61..ce4f8ca 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -205,20 +205,19 @@ const IMStatusChooserItem = new Lang.Class({
Lang.bind(this, this._IMAccountsChanged));
this._accountMgr.prepare_async(null, Lang.bind(this,
function(mgr) {
- let [presence, status, msg] = mgr.get_most_available_presence();
-
- let savedPresence = global.settings.get_int('saved-im-presence');
-
this._IMAccountsChanged(mgr);
- if (savedPresence == presence) {
- this._IMStatusChanged(mgr, presence, status, msg);
- } else {
- this._setComboboxPresence(savedPresence);
- status = this._statusForPresence(savedPresence);
- msg = msg ? msg : '';
- mgr.set_all_requested_presences(savedPresence, status, msg);
- }
+ if (this._networkMonitor.network_available)
+ this._restorePresence();
+ else
+ this._setComboboxPresence(Tp.ConnectionPresenceType.OFFLINE);
+ }));
+
+ this._networkMonitor = Gio.NetworkMonitor.get_default();
+ this._networkMonitor.connect('network-changed',
+ Lang.bind(this, function(monitor, available) {
+ if (available && !this._imPresenceRestored)
+ this._restorePresence();
}));
this._userLoadedId = this._user.connect('notify::is-loaded',
@@ -233,6 +232,21 @@ const IMStatusChooserItem = new Lang.Class({
}));
},
+ _restorePresence: function() {
+ let [presence, status, msg] = this._accountMgr.get_most_available_presence();
+
+ let savedPresence = global.settings.get_int('saved-im-presence');
+
+ if (savedPresence == presence) {
+ this._IMStatusChanged(this._accountMgr, presence, status, msg);
+ } else {
+ this._setComboboxPresence(savedPresence);
+ status = this._statusForPresence(savedPresence);
+ msg = msg ? msg : '';
+ this._accountMgr.set_all_requested_presences(savedPresence, status, msg);
+ }
+ },
+
destroy: function() {
// clean up signal handlers
if (this._userLoadedId != 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]