[gnome-maps] Split out notification manager to its own module



commit f2376aca41774dd516277a838b8d1a6f40192052
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Apr 23 14:43:25 2014 +0200

    Split out notification manager to its own module
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727706

 src/application.js              |    3 +-
 src/gnome-maps.js.gresource.xml |    1 +
 src/notification.js             |   40 -----------------------
 src/notificationManager.js      |   67 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 41 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 7ae8dbc..7c9682e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -36,6 +36,7 @@ const Main = imports.main;
 const Format = imports.format;
 const MainWindow = imports.mainWindow;
 const Notification = imports.notification;
+const NotificationManager = imports.notificationManager;
 const Utils = imports.utils;
 const Path = imports.path;
 const Settings = imports.settings;
@@ -108,7 +109,7 @@ const Application = new Lang.Class({
             return;
 
         let overlay = new Gtk.Overlay({ visible: true, can_focus: true });
-        notificationManager = new Notification.Manager(overlay);
+        notificationManager = new NotificationManager.NotificationManager(overlay);
         this._mainWindow = new MainWindow.MainWindow(this, overlay);
         this._mainWindow.window.connect('destroy', this._onWindowDestroy.bind(this));
     },
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index cc8ada0..37366f2 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -11,6 +11,7 @@
     <file>mapLocation.js</file>
     <file>mapView.js</file>
     <file>notification.js</file>
+    <file>notificationManager.js</file>
     <file>path.js</file>
     <file>placeStore.js</file>
     <file>searchPopup.js</file>
diff --git a/src/notification.js b/src/notification.js
index 6f3e83e..6e3e1d6 100644
--- a/src/notification.js
+++ b/src/notification.js
@@ -82,43 +82,3 @@ const Plain = new Lang.Class({
 
 const Type = {};
 
-const Manager = new Lang.Class({
-    Name: 'Manager',
-
-    _init: function(overlay) {
-        this._overlay = overlay;
-        this._cache = {};
-    },
-
-    showMessage: function (msg) {
-        let notification = new Plain(msg);
-        notification.connect('dismissed',
-                             notification.destroy.bind(notification));
-        this._overlay.add_overlay(notification);
-        notification.reveal();
-    },
-
-    // Shows a static (reusable) notification
-    showNotification: function(notificationType) {
-        let notification = this._getNotification(notificationType);
-        if(!notification.get_parent())
-            this._overlay.add_overlay(notification);
-        notification.reveal();
-    },
-
-    _getNotification: function(notificationType) {
-        if(!this._cache.hasOwnProperty(notificationType.name)) {
-            this._createNotification(notificationType);
-        }
-        return this._cache[notificationType.name];
-    },
-
-    _createNotification: function(notificationType) {
-        let notification = new notificationType.Class();
-        notification.connect('dismissed', (function() {
-            this._overlay.remove(notification);
-        }).bind(this));
-
-        this._cache[notificationType.name] = notification;
-    }
-});
diff --git a/src/notificationManager.js b/src/notificationManager.js
new file mode 100644
index 0000000..5b098a5
--- /dev/null
+++ b/src/notificationManager.js
@@ -0,0 +1,67 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2014 Mattias Bengtsson
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
+ *         Jonas Danielsson <jonas threetimestwo org>
+ */
+
+const Notification = imports.notification;
+
+const Lang = imports.lang;
+
+const NotificationManager = new Lang.Class({
+    Name: 'NotificationManager',
+
+    _init: function(overlay) {
+        this._overlay = overlay;
+        this._cache = {};
+    },
+
+    showMessage: function (msg) {
+        let notification = new Notification.Plain(msg);
+        notification.connect('dismissed',
+                             notification.destroy.bind(notification));
+        this._overlay.add_overlay(notification);
+        notification.reveal();
+    },
+
+    // Shows a static (reusable) notification
+    showNotification: function(notificationType) {
+        let notification = this._getNotification(notificationType);
+        if(!notification.get_parent())
+            this._overlay.add_overlay(notification);
+        notification.reveal();
+    },
+
+    _getNotification: function(notificationType) {
+        if(!this._cache.hasOwnProperty(notificationType.name)) {
+            this._createNotification(notificationType);
+        }
+        return this._cache[notificationType.name];
+    },
+
+    _createNotification: function(notificationType) {
+        let notification = new notificationType.Class();
+        notification.connect('dismissed', (function() {
+            this._overlay.remove(notification);
+        }).bind(this));
+
+        this._cache[notificationType.name] = notification;
+    }
+});


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