[gnome-maps/wip/notifications3: 3/4] Notifications: static example
- From: Mattias Bengtsson <mattiasb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/notifications3: 3/4] Notifications: static example
- Date: Mon, 24 Feb 2014 01:09:25 +0000 (UTC)
commit 42a63e69b1ba45715e08a6575ac20a31c1c9bed9
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 285d4f7..db52d94 100644
--- a/src/notification.js
+++ b/src/notification.js
@@ -80,7 +80,56 @@ 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 }
+};
const Manager = new Lang.Class({
Name: 'Manager',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]