[gnome-maps/wip/notifications2: 3/4] Notifications: static example
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/notifications2: 3/4] Notifications: static example
- Date: Sat, 15 Feb 2014 06:13:43 +0000 (UTC)
commit 3b38187e8156d6361099ea2fe697cd7c2c5c0107
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.
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]