[gnome-shell] statusMenu: change IM presence when needed (#617207)
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] statusMenu: change IM presence when needed (#617207)
- Date: Tue, 1 Mar 2011 09:10:25 +0000 (UTC)
commit e8e36e8a66620ec69e1c9d7393e8d20c0fde4d01
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Mon Feb 28 17:03:35 2011 +0100
statusMenu: change IM presence when needed (#617207)
js/ui/statusMenu.js | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index 931f024..60643e3 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -5,6 +5,7 @@ const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
+const Tp = imports.gi.TelepathyGLib;
const UPowerGlib = imports.gi.UPowerGlib;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
@@ -39,6 +40,8 @@ StatusMenuButton.prototype = {
this._presence = new GnomeSession.Presence();
this._presenceItems = {};
+ this._account_mgr = Tp.AccountManager.dup()
+
this._upClient = new UPowerGlib.Client();
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
@@ -169,6 +172,8 @@ StatusMenuButton.prototype = {
_setPresenceStatus: function(item, event, status) {
this._presence.setStatus(status);
+
+ this._setIMStatus(status);
},
_onMyAccountActivate: function() {
@@ -206,5 +211,31 @@ StatusMenuButton.prototype = {
} else {
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);
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]