[gnome-maps/wip/notifications2: 13/14] Notifications: static example



commit c11992cb6d9ca0c9d839eb9c8b9544e4ec8513be
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Sat Feb 15 06:53:46 2014 +0100

    Notifications: static example
    
    Two stubs for example static (reusable) notifications. Not meant to be
    pushed as is, but as a demonstration on how to work with this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723996

 src/notification.js |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/src/notification.js b/src/notification.js
index d2e2e02..56fe5fe 100644
--- a/src/notification.js
+++ b/src/notification.js
@@ -80,4 +80,53 @@ const Plain = new Lang.Class({
     }
 });
 
-const Type = { };
+const WithButton = new Lang.Class({
+    Name: 'WithButton',
+    Extends: Notification,
+    Abstract: true,
+
+    _init: function(msg, buttonLabel, callback) {
+        this.parent();
+        let label = new Gtk.Label({ visible : true,
+                                    hexpand : true,
+                                    halign  : Gtk.Align.START,
+                                    label   : msg });
+        let button = new Gtk.Button({ visible : true,
+                                      label   : buttonLabel });
+        button.connect('clicked', callback);
+
+        this._ui.body.add(label);
+        this._ui.body.add(button);
+    }
+});
+
+const NoNetwork = new Lang.Class({
+    Name: 'NoNetwork',
+    Extends: WithButton,
+
+    _init: function() {
+        this.parent("Maps need a working network connection to function properly",
+                    "Turn On",
+                    (function() {
+                        log("TODO: connect to network here…");
+                    }));
+    }
+});
+
+const NoLocation = new Lang.Class({
+    Name: 'NoLocation',
+    Extends: WithButton,
+
+    _init: function() {
+        this.parent("Turn on location services to find your location",
+                    "Turn On",
+                    (function() {
+                        log("TODO: turn on location services here…");
+                    }));
+    }
+});
+
+const Type = {
+    NO_NETWORK  : { name: "NO_NETWORK",  Class: NoNetwork },
+    NO_LOCATION : { name: "NO_LOCATION", Class: NoLocation }
+};


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]