[gnome-shell/wip/fmuellner/notification-redux: 111/128] messageTray: Add NotificationBanner actor
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/notification-redux: 111/128] messageTray: Add NotificationBanner actor
- Date: Tue, 17 Feb 2015 11:28:59 +0000 (UTC)
commit ed58ce7c7aa5dab21f44d7b980dd3577658878bb
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Feb 17 01:13:48 2015 +0100
messageTray: Add NotificationBanner actor
data/theme/gnome-shell.css | 9 +++++++-
js/ui/messageTray.js | 48 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 3870344..983a884 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -1608,6 +1608,13 @@ StScrollBar StButton#vhandle:active {
link-color: #ccccff;
}
+.notification-banner {
+ border-radius: 5px;
+ margin: 5px;
+ background-color: rgb(72,72,72);
+ border: 1px solid rgb(35,40,41);
+}
+
.notification {
border-radius: 5px;
margin: 5px;
@@ -1624,7 +1631,7 @@ StScrollBar StButton#vhandle:active {
spacing: 5px;
}
-.notification, #notification-container {
+.notification, .notification-banner, #notification-container {
font-size: 11pt;
width: 34em;
}
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 8c69e78..ceb3901 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -14,6 +14,7 @@ const Shell = imports.gi.Shell;
const Signals = imports.signals;
const St = imports.gi.St;
+const Calendar = imports.ui.calendar;
const GnomeSession = imports.misc.gnomeSession;
const Layout = imports.ui.layout;
const Main = imports.ui.main;
@@ -1012,6 +1013,53 @@ const Notification = new Lang.Class({
});
Signals.addSignalMethods(Notification.prototype);
+const NotificationBanner = new Lang.Class({
+ Name: 'NotificationBanner',
+ Extends: Calendar.NotificationMessage,
+
+ _init: function(notification) {
+ this.parent(notification);
+
+ this.actor.add_style_class_name('notification-banner');
+
+ this._buttonBox = null;
+ },
+
+ addButton: function(button, callback) {
+ if (!this._buttonBox) {
+ this._buttonBox = new St.BoxLayout({ style_class: 'notification-actions',
+ x_expand: true });
+ this.setActionArea(this._buttonBox);
+ global.focus_manager.add_group(this._buttonBox);
+ }
+
+ this._buttonBox.add(button);
+ button.connect('clicked', Lang.bind(this, function() {
+ callback();
+
+ if (!this.notification.resident) {
+ // We don't hide a resident notification when the user invokes one of its actions,
+ // because it is common for such notifications to update themselves with new
+ // information based on the action. We'd like to display the updated information
+ // in place, rather than pop-up a new notification.
+ this.emit('done-displaying');
+ this.notification.destroy();
+ }
+ }));
+
+ return button;
+ },
+
+ addAction: function(label, callback) {
+ let button = new St.Button({ style_class: 'notification-button',
+ label: label,
+ x_expand: true,
+ can_focus: true });
+
+ return this.addButton(button, callback);
+ }
+});
+
const SourceActor = new Lang.Class({
Name: 'SourceActor',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]