[polari/wip/bastianilso/irc-url-handling: 2/5] fWIP! appNotification: Add class GenericNotification



commit 753afb73f678981ce42562064b4f3245cd410dc9
Author: Bastian Ilsø <hougaard junior gmail com>
Date:   Thu Feb 11 16:43:57 2016 +0100

    fWIP! appNotification: Add class GenericNotification
    
    We are about to land IRC Url parsing which error
    handling requires using an appNotification.

 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]