[gnome-shell] messageTray: Add 'Notifications' switch to tray menu
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] messageTray: Add 'Notifications' switch to tray menu
- Date: Thu, 10 Oct 2013 21:27:53 +0000 (UTC)
commit 6e9a2fea8995cd7898124c6fc88f93902caf8417
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Sep 30 16:47:52 2013 +0200
messageTray: Add 'Notifications' switch to tray menu
According to the designs, the notifications switch was supposed
to move from the user menu to the new message tray menu. However
so far the new system status implementation only removed the old
switch, so add it back in its new place now.
https://bugzilla.gnome.org/show_bug.cgi?id=707073
js/ui/messageTray.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index e98be02..d8d1e36 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1507,9 +1507,33 @@ const MessageTrayMenu = new Lang.Class({
this._tray = tray;
+ this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
+ if (error) {
+ logError(error, 'Error while reading gnome-session presence');
+ return;
+ }
+
+ this._onStatusChanged(proxy.status);
+ }));
+ this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
+ this._onStatusChanged(status);
+ }));
+
+ this._accountManager = Tp.AccountManager.dup();
+ this._accountManager.connect('most-available-presence-changed',
+ Lang.bind(this, this._onIMPresenceChanged));
+ this._accountManager.prepare_async(null, Lang.bind(this, this._onIMPresenceChanged));
+
this.actor.hide();
Main.layoutManager.addChrome(this.actor);
+ this._busyItem = new PopupMenu.PopupSwitchMenuItem(_("Notifications"));
+ this._busyItem.connect('toggled', Lang.bind(this, this._updatePresence));
+ this.addMenuItem(this._busyItem);
+
+ let separator = new PopupMenu.PopupSeparatorMenuItem();
+ this.addMenuItem(separator);
+
this._clearItem = this.addAction(_("Clear Messages"), function() {
let toDestroy = [];
let sources = tray.getSources();
@@ -1541,9 +1565,43 @@ const MessageTrayMenu = new Lang.Class({
settingsItem.connect('activate', function() { tray.close(); });
},
+ _onStatusChanged: function(status) {
+ this._sessionStatus = status;
+ this._busyItem.setToggleState(status != GnomeSession.PresenceStatus.BUSY);
+ },
+
+ _onIMPresenceChanged: function(am, type) {
+ if (type == Tp.ConnectionPresenceType.AVAILABLE &&
+ this._sessionStatus == GnomeSession.PresenceStatus.BUSY)
+ this._presence.SetStatusRemote(GnomeSession.PresenceStatus.AVAILABLE);
+ },
+
_updateClearSensitivity: function() {
this._clearItem.setSensitive(this._tray.clearableCount > 0);
},
+
+ _updatePresence: function(item, state) {
+ let status = state ? GnomeSession.PresenceStatus.AVAILABLE
+ : GnomeSession.PresenceStatus.BUSY;
+ this._presence.SetStatusRemote(status);
+
+ let [type, s ,msg] = this._accountManager.get_most_available_presence();
+ let newType = 0;
+ let newStatus;
+ if (status == GnomeSession.PresenceStatus.BUSY &&
+ type == Tp.ConnectionPresenceType.AVAILABLE) {
+ newType = Tp.ConnectionPresenceType.BUSY;
+ newStatus = 'busy';
+ } else if (status == GnomeSession.PresenceStatus.AVAILABLE &&
+ type == Tp.ConnectionPresenceType.BUSY) {
+ newType = Tp.ConnectionPresenceType.AVAILABLE;
+ newStatus = 'available';
+ }
+
+ if (newType > 0)
+ this._accountManager.set_all_requested_presences(newType,
+ newStatus, msg);
+ }
});
const MessageTrayMenuButton = new Lang.Class({
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]