summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2018-05-04 17:55:29 +0200
committerFlorian Müllner <fmuellner@gnome.org>2018-07-14 03:30:46 +0200
commit44d68e35a2fd31a4d7f567744082f9c784adb83f (patch)
treead89bd488714a31a4cf1e6867a19589aa1398133
parent1a266e435f294e9efae4ed0b338a4e9e0861dc7d (diff)
downloadgnome-shell-wip/fmuellner/dont-disturb.tar.gz
calendar: Add "Do Not Disturb" switchwip/fmuellner/dont-disturb
We've had the ability to temporarily disable notification banners all the way back to 3.0, but we stopped exposing it in the UI with the 3.16 notification redesign. With the message list being more concise nowadays and the "Clear All" button reduced to a single icon, we now have space for a "Do Not Disturb" switch again. https://gitlab.gnome.org/GNOME/gnome-shell/issues/239
-rw-r--r--data/theme/gnome-shell-sass/_common.scss6
-rw-r--r--js/ui/calendar.js43
2 files changed, 47 insertions, 2 deletions
diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
index 1940239bb..e21f61433 100644
--- a/data/theme/gnome-shell-sass/_common.scss
+++ b/data/theme/gnome-shell-sass/_common.scss
@@ -1014,10 +1014,14 @@ StScrollBar {
width: 31.5em;
}
+ .message-list-controls {
+ margin: 1.5em 1.5em 0;
+ spacing: 0.8em;
+ }
+
.message-list-clear-button.button {
background-color: transparent;
&:hover,&:focus { background-color: lighten($bg_color,5%); }
- margin: 1.5em 1.5em 0;
padding: 8px;
}
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index e6b595b52..43d6ea6f4 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -9,10 +9,12 @@ const St = imports.gi.St;
const Signals = imports.signals;
const Shell = imports.gi.Shell;
+const GnomeSession = imports.misc.gnomeSession;
const Main = imports.ui.main;
const MessageList = imports.ui.messageList;
const MessageTray = imports.ui.messageTray;
const Mpris = imports.ui.mpris;
+const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
var MSECS_IN_DAY = 24 * 60 * 60 * 1000;
@@ -1105,6 +1107,32 @@ var Placeholder = new Lang.Class({
}
});
+var DoNotDisturbSwitch = new Lang.Class({
+ Name: 'DoNotDisturbSwitch',
+ Extends: PopupMenu.Switch,
+
+ _init() {
+ this._presence = new GnomeSession.Presence((proxy, error) => {
+ this._onStatusChanged(proxy.status);
+ });
+ this._presence.connectSignal('StatusChanged', (proxy, sender, [status]) => {
+ this._onStatusChanged(status);
+ });
+ this.parent(false);
+ },
+
+ _onStatusChanged(status) {
+ this.setToggleState(status == GnomeSession.PresenceStatus.BUSY);
+ },
+
+ setToggleState(state) {
+ this.parent(state);
+
+ this._presence.SetStatusRemote(state ? GnomeSession.PresenceStatus.BUSY
+ : GnomeSession.PresenceStatus.AVAILABLE);
+ }
+});
+
var CalendarMessageList = new Lang.Class({
Name: 'CalendarMessageList',
@@ -1127,7 +1155,20 @@ var CalendarMessageList = new Lang.Class({
this._scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
box.add_actor(this._scrollView);
+ let hbox = new St.BoxLayout({ style_class: 'message-list-controls' });
+ box.add_actor(hbox);
+
+ hbox.add_actor(new St.Label({ text: _("Do Not Disturb"),
+ y_align: Clutter.ActorAlign.CENTER }));
+
+ this._dndSwitch = new DoNotDisturbSwitch();
+ this._dndButton = new St.Button({ can_focus: true,
+ child: this._dndSwitch.actor });
+ this._dndButton.connect('clicked', () => { this._dndSwitch.toggle(); });
+ hbox.add_actor(this._dndButton);
+
this._clearButton = new St.Button({ style_class: 'message-list-clear-button button',
+ x_expand: true,
can_focus: true });
this._clearButton.add_actor(new St.Icon({ icon_name: 'edit-clear-all-symbolic' }));
this._clearButton.set_x_align(Clutter.ActorAlign.END);
@@ -1135,7 +1176,7 @@ var CalendarMessageList = new Lang.Class({
let sections = [...this._sections.keys()];
sections.forEach((s) => { s.clear(); });
});
- box.add_actor(this._clearButton);
+ hbox.add_actor(this._clearButton);
this._sectionList = new St.BoxLayout({ style_class: 'message-list-sections',
vertical: true,