statusMenu: change IM presence when needed (#617207)
This commit is contained in:
parent
88bcd0a9ce
commit
e8e36e8a66
@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
|
|||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
const Tp = imports.gi.TelepathyGLib;
|
||||||
const UPowerGlib = imports.gi.UPowerGlib;
|
const UPowerGlib = imports.gi.UPowerGlib;
|
||||||
const Gettext = imports.gettext.domain('gnome-shell');
|
const Gettext = imports.gettext.domain('gnome-shell');
|
||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
@ -39,6 +40,8 @@ StatusMenuButton.prototype = {
|
|||||||
this._presence = new GnomeSession.Presence();
|
this._presence = new GnomeSession.Presence();
|
||||||
this._presenceItems = {};
|
this._presenceItems = {};
|
||||||
|
|
||||||
|
this._account_mgr = Tp.AccountManager.dup()
|
||||||
|
|
||||||
this._upClient = new UPowerGlib.Client();
|
this._upClient = new UPowerGlib.Client();
|
||||||
|
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
@ -169,6 +172,8 @@ StatusMenuButton.prototype = {
|
|||||||
|
|
||||||
_setPresenceStatus: function(item, event, status) {
|
_setPresenceStatus: function(item, event, status) {
|
||||||
this._presence.setStatus(status);
|
this._presence.setStatus(status);
|
||||||
|
|
||||||
|
this._setIMStatus(status);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMyAccountActivate: function() {
|
_onMyAccountActivate: function() {
|
||||||
@ -206,5 +211,31 @@ StatusMenuButton.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
Util.spawn(['gnome-session-quit', '--power-off']);
|
Util.spawn(['gnome-session-quit', '--power-off']);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_setIMStatus: function(session_status) {
|
||||||
|
let [presence_type, presence_status, msg] = this._account_mgr.get_most_available_presence();
|
||||||
|
let type, status;
|
||||||
|
|
||||||
|
// We change the IM presence only if there are connected accounts
|
||||||
|
if (presence_type == Tp.ConnectionPresenceType.UNSET ||
|
||||||
|
presence_type == Tp.ConnectionPresenceType.OFFLINE ||
|
||||||
|
presence_type == Tp.ConnectionPresenceType.UNKNOWN ||
|
||||||
|
presence_type == Tp.ConnectionPresenceType.ERROR)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (session_status == GnomeSession.PresenceStatus.AVAILABLE) {
|
||||||
|
type = Tp.ConnectionPresenceType.AVAILABLE;
|
||||||
|
status = "available";
|
||||||
|
}
|
||||||
|
else if (session_status == GnomeSession.PresenceStatus.BUSY) {
|
||||||
|
type = Tp.ConnectionPresenceType.BUSY;
|
||||||
|
status = "busy";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._account_mgr.set_all_requested_presences(type, status, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user