From 39c5d23a871fb2b3e2a7860162ff56284c2f2226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 30 Sep 2011 18:54:45 +0200 Subject: [PATCH] user-menu: Restore previous IM presence on startup Move the saved user-set presence to GSettings, so it is preserved between logins. https://bugzilla.gnome.org/show_bug.cgi?id=659021 --- data/org.gnome.shell.gschema.xml.in | 4 ++++ js/ui/userMenu.js | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index 55db42a89..a848818d2 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -50,6 +50,10 @@ [] <_summary>History for the looking glass dialog + + 0 + <_summary> + diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 22988faba..85d98028e 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -163,17 +163,23 @@ IMStatusChooserItem.prototype = { Lang.bind(this, this._sessionStatusChanged)); this._currentPresence = undefined; - this._previousPresence = undefined; this._accountMgr = Tp.AccountManager.dup() this._accountMgr.connect('most-available-presence-changed', Lang.bind(this, this._IMStatusChanged)); this._accountMgr.prepare_async(null, Lang.bind(this, function(mgr) { - let [presence, s, msg] = mgr.get_most_available_presence(); + let [presence, status, msg] = mgr.get_most_available_presence(); - this._previousPresence = presence; - this._IMStatusChanged(mgr, presence, s, msg); + let savedPresence = global.settings.get_int('saved-im-presence'); + 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); + } })); this._userManager = AccountsService.UserManager.get_default(); @@ -265,15 +271,18 @@ IMStatusChooserItem.prototype = { return; this._currentPresence = presence; + this._setComboboxPresence(presence); if (presence == Tp.ConnectionPresenceType.AVAILABLE) this._presence.setStatus(GnomeSession.PresenceStatus.AVAILABLE); if (!this._expectedPresence || presence != this._expectedPresence) - this._previousPresence = presence; + global.settings.set_int('saved-im-presence', presence); else this._expectedPresence = undefined; + }, + _setComboboxPresence: function(presence) { let activatedItem; if (presence == Tp.ConnectionPresenceType.AVAILABLE) @@ -315,8 +324,11 @@ IMStatusChooserItem.prototype = { }, getIMPresenceForSessionStatus: function(sessionStatus) { + // Restore the last user-set presence when coming back from + // BUSY/IDLE (otherwise the last user-set presence matches + // the current one) if (sessionStatus == GnomeSession.PresenceStatus.AVAILABLE) - return this._previousPresence; + return global.settings.get_int('saved-im-presence'); if (sessionStatus == GnomeSession.PresenceStatus.BUSY) { // Only change presence if the current one is "more present" than