[polari/wip/bastianilso/irc-url-handling: 69/71] appNotification: Add class CloseNotification
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/bastianilso/irc-url-handling: 69/71] appNotification: Add class CloseNotification
- Date: Tue, 23 Feb 2016 23:36:41 +0000 (UTC)
commit b1131e9c16c24f4c85fa47a350ed6089ab8cef76
Author: Bastian Ilsø <hougaard junior gmail com>
Date: Thu Feb 11 16:43:57 2016 +0100
appNotification: Add class CloseNotification
We are about to land IRC URL parsing which error
handling requires using an app notification when
IRC URLs cannot be properly parsed. This adds a
new CloseNotification class which shows a notification
for 7 seconds along with a close button.
src/appNotifications.js | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index d8b4912..b80c2b1 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -68,6 +68,36 @@ const UndoNotification = new Lang.Class({
}
});
+const CloseNotification = new Lang.Class({
+ Name: 'CloseNotification',
+ Extends: AppNotification,
+ Signals: { closed: {} },
+
+ _init: function(label, icon_name) {
+ this.parent();
+
+ Mainloop.timeout_add_seconds(TIMEOUT, Lang.bind(this, this.close));
+
+ let box = new Gtk.Box({ spacing: 12 });
+ box.add(new Gtk.Image({ icon_name: icon_name }));
+ box.add(new Gtk.Label({ label: label, hexpand: true,
+ ellipsize: Pango.EllipsizeMode.END }));
+
+ let closeButton = new Gtk.Button({ relief: Gtk.ReliefStyle.NONE });
+ closeButton.image = new Gtk.Image({ icon_name: 'window-close-symbolic' });
+ closeButton.connect('clicked', Lang.bind(this, this.close));
+ box.add(closeButton);
+
+ this.add(box);
+ this.show_all();
+ },
+
+ close: function() {
+ this.emit(this._undo ? 'undo' : 'closed');
+ this.parent();
+ }
+});
+
const CommandOutputNotification = new Lang.Class({
Name: 'CommandOutputNotification',
Extends: AppNotification,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]