user-menu: Disable combo box if no accounts are enabled
If no telepathy accounts have been set up or enabled, the IM status chooser won't have any effect. To avoid confusing behavior, make the status selector insensitive in that case. https://bugzilla.gnome.org/show_bug.cgi?id=662800
This commit is contained in:
parent
b88657ab83
commit
e279ef1c7c
@ -168,11 +168,20 @@ IMStatusChooserItem.prototype = {
|
|||||||
this._accountMgr = Tp.AccountManager.dup();
|
this._accountMgr = Tp.AccountManager.dup();
|
||||||
this._accountMgr.connect('most-available-presence-changed',
|
this._accountMgr.connect('most-available-presence-changed',
|
||||||
Lang.bind(this, this._IMStatusChanged));
|
Lang.bind(this, this._IMStatusChanged));
|
||||||
|
this._accountMgr.connect('account-enabled',
|
||||||
|
Lang.bind(this, this._IMAccountsChanged));
|
||||||
|
this._accountMgr.connect('account-disabled',
|
||||||
|
Lang.bind(this, this._IMAccountsChanged));
|
||||||
|
this._accountMgr.connect('account-removed',
|
||||||
|
Lang.bind(this, this._IMAccountsChanged));
|
||||||
this._accountMgr.prepare_async(null, Lang.bind(this,
|
this._accountMgr.prepare_async(null, Lang.bind(this,
|
||||||
function(mgr) {
|
function(mgr) {
|
||||||
let [presence, status, msg] = mgr.get_most_available_presence();
|
let [presence, status, msg] = mgr.get_most_available_presence();
|
||||||
|
|
||||||
let savedPresence = global.settings.get_int('saved-im-presence');
|
let savedPresence = global.settings.get_int('saved-im-presence');
|
||||||
|
|
||||||
|
this._IMAccountsChanged(mgr);
|
||||||
|
|
||||||
if (savedPresence == presence) {
|
if (savedPresence == presence) {
|
||||||
this._IMStatusChanged(mgr, presence, status, msg);
|
this._IMStatusChanged(mgr, presence, status, msg);
|
||||||
} else {
|
} else {
|
||||||
@ -282,6 +291,13 @@ IMStatusChooserItem.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_IMAccountsChanged: function(mgr) {
|
||||||
|
let accounts = mgr.get_valid_accounts().filter(function(account) {
|
||||||
|
return account.enabled;
|
||||||
|
});
|
||||||
|
this._combo.setSensitive(accounts.length > 0);
|
||||||
|
},
|
||||||
|
|
||||||
_IMStatusChanged: function(accountMgr, presence, status, message) {
|
_IMStatusChanged: function(accountMgr, presence, status, message) {
|
||||||
if (!this._imPresenceRestored)
|
if (!this._imPresenceRestored)
|
||||||
this._imPresenceRestored = true;
|
this._imPresenceRestored = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user