[gnome-shell] messageTray: Move the notification policy classes here
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] messageTray: Move the notification policy classes here
- Date: Mon, 14 Oct 2013 19:25:37 +0000 (UTC)
commit 66a4cb5875e643cee1b369c37eac4695785f4595
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Oct 13 16:01:56 2013 -0400
messageTray: Move the notification policy classes here
The NotificationDaemon really should be for the hookup of remote
notifications, rather than policies.
https://bugzilla.gnome.org/show_bug.cgi?id=710115
js/ui/components/telepathyClient.js | 7 +-
js/ui/messageTray.js | 120 +++++++++++++++++++++++++++++++++
js/ui/notificationDaemon.js | 124 +----------------------------------
js/ui/status/bluetooth.js | 3 +-
js/ui/status/network.js | 3 +-
5 files changed, 127 insertions(+), 130 deletions(-)
---
diff --git a/js/ui/components/telepathyClient.js b/js/ui/components/telepathyClient.js
index 48dbae6..86a62bb 100644
--- a/js/ui/components/telepathyClient.js
+++ b/js/ui/components/telepathyClient.js
@@ -13,7 +13,6 @@ const Tp = imports.gi.TelepathyGLib;
const History = imports.misc.history;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
-const NotificationDaemon = imports.ui.notificationDaemon;
const Params = imports.misc.params;
const PopupMenu = imports.ui.popupMenu;
@@ -416,7 +415,7 @@ const TelepathyClient = new Lang.Class({
_ensureAppSource: function() {
if (this._appSource == null) {
this._appSource = new MessageTray.Source(_("Chat"), 'empathy');
- this._appSource.policy = new NotificationDaemon.NotificationApplicationPolicy('empathy');
+ this._appSource.policy = new MessageTray.NotificationApplicationPolicy('empathy');
Main.messageTray.add(this._appSource);
this._appSource.connect('destroy', Lang.bind(this, function () {
@@ -488,7 +487,7 @@ const ChatSource = new Lang.Class({
},
_createPolicy: function() {
- return new NotificationDaemon.NotificationApplicationPolicy('empathy');
+ return new MessageTray.NotificationApplicationPolicy('empathy');
},
_updateAlias: function() {
@@ -1061,7 +1060,7 @@ const ApproverSource = new Lang.Class({
},
_createPolicy: function() {
- return new NotificationDaemon.NotificationApplicationPolicy('empathy');
+ return new MessageTray.NotificationApplicationPolicy('empathy');
},
destroy: function() {
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 9e5ddad..65ab89b 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -310,6 +310,126 @@ const NotificationPolicy = new Lang.Class({
});
Signals.addSignalMethods(NotificationPolicy.prototype);
+const NotificationGenericPolicy = new Lang.Class({
+ Name: 'NotificationGenericPolicy',
+ Extends: NotificationPolicy,
+
+ _init: function() {
+ // Don't chain to parent, it would try setting
+ // our properties to the defaults
+
+ this.id = 'generic';
+
+ this._masterSettings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications' });
+ this._masterSettings.connect('changed', Lang.bind(this, this._changed));
+ },
+
+ store: function() { },
+
+ destroy: function() {
+ this._masterSettings.run_dispose();
+ },
+
+ _changed: function(settings, key) {
+ this.emit('policy-changed', key);
+ },
+
+ get enable() {
+ return true;
+ },
+
+ get enableSound() {
+ return true;
+ },
+
+ get showBanners() {
+ return this._masterSettings.get_boolean('show-banners');
+ },
+
+ get forceExpanded() {
+ return false;
+ },
+
+ get showInLockScreen() {
+ return this._masterSettings.get_boolean('show-in-lock-screen');
+ },
+
+ get detailsInLockScreen() {
+ return false;
+ }
+});
+
+const NotificationApplicationPolicy = new Lang.Class({
+ Name: 'NotificationApplicationPolicy',
+ Extends: NotificationPolicy,
+
+ _init: function(id) {
+ // Don't chain to parent, it would try setting
+ // our properties to the defaults
+
+ this.id = id;
+ this._canonicalId = this._canonicalizeId(id);
+
+ this._masterSettings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications' });
+ this._settings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications.application',
+ path: '/org/gnome/desktop/notifications/application/' +
this._canonicalId + '/' });
+
+ this._masterSettings.connect('changed', Lang.bind(this, this._changed));
+ this._settings.connect('changed', Lang.bind(this, this._changed));
+ },
+
+ store: function() {
+ this._settings.set_string('application-id', this.id + '.desktop');
+
+ let apps = this._masterSettings.get_strv('application-children');
+ if (apps.indexOf(this._canonicalId) < 0) {
+ apps.push(this._canonicalId);
+ this._masterSettings.set_strv('application-children', apps);
+ }
+ },
+
+ destroy: function() {
+ this._masterSettings.run_dispose();
+ this._settings.run_dispose();
+ },
+
+ _changed: function(settings, key) {
+ this.emit('policy-changed', key);
+ },
+
+ _canonicalizeId: function(id) {
+ // Keys are restricted to lowercase alphanumeric characters and dash,
+ // and two dashes cannot be in succession
+ return id.toLowerCase().replace(/[^a-z0-9\-]/g, '-').replace(/--+/g, '-');
+ },
+
+ get enable() {
+ return this._settings.get_boolean('enable');
+ },
+
+ get enableSound() {
+ return this._settings.get_boolean('enable-sound-alerts');
+ },
+
+ get showBanners() {
+ return this._masterSettings.get_boolean('show-banners') &&
+ this._settings.get_boolean('show-banners');
+ },
+
+ get forceExpanded() {
+ return this._settings.get_boolean('force-expanded');
+ },
+
+ get showInLockScreen() {
+ return this._masterSettings.get_boolean('show-in-lock-screen') &&
+ this._settings.get_boolean('show-in-lock-screen');
+ },
+
+ get detailsInLockScreen() {
+ return this._settings.get_boolean('details-in-lock-screen');
+ }
+});
+
// Notification:
// @source: the notification's Source
// @title: the title
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 9287774..4c41dd1 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -103,126 +103,6 @@ const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
'ibus-ui-gtk': 'keyboard'
};
-const NotificationGenericPolicy = new Lang.Class({
- Name: 'NotificationGenericPolicy',
- Extends: MessageTray.NotificationPolicy,
-
- _init: function() {
- // Don't chain to parent, it would try setting
- // our properties to the defaults
-
- this.id = 'generic';
-
- this._masterSettings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications' });
- this._masterSettings.connect('changed', Lang.bind(this, this._changed));
- },
-
- store: function() { },
-
- destroy: function() {
- this._masterSettings.run_dispose();
- },
-
- _changed: function(settings, key) {
- this.emit('policy-changed', key);
- },
-
- get enable() {
- return true;
- },
-
- get enableSound() {
- return true;
- },
-
- get showBanners() {
- return this._masterSettings.get_boolean('show-banners');
- },
-
- get forceExpanded() {
- return false;
- },
-
- get showInLockScreen() {
- return this._masterSettings.get_boolean('show-in-lock-screen');
- },
-
- get detailsInLockScreen() {
- return false;
- }
-});
-
-const NotificationApplicationPolicy = new Lang.Class({
- Name: 'NotificationApplicationPolicy',
- Extends: MessageTray.NotificationPolicy,
-
- _init: function(id) {
- // Don't chain to parent, it would try setting
- // our properties to the defaults
-
- this.id = id;
- this._canonicalId = this._canonicalizeId(id)
-
- this._masterSettings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications' });
- this._settings = new Gio.Settings({ schema: 'org.gnome.desktop.notifications.application',
- path: '/org/gnome/desktop/notifications/application/' +
this._canonicalId + '/' });
-
- this._masterSettings.connect('changed', Lang.bind(this, this._changed));
- this._settings.connect('changed', Lang.bind(this, this._changed));
- },
-
- store: function() {
- this._settings.set_string('application-id', this.id + '.desktop');
-
- let apps = this._masterSettings.get_strv('application-children');
- if (apps.indexOf(this._canonicalId) < 0) {
- apps.push(this._canonicalId);
- this._masterSettings.set_strv('application-children', apps);
- }
- },
-
- destroy: function() {
- this._masterSettings.run_dispose();
- this._settings.run_dispose();
- },
-
- _changed: function(settings, key) {
- this.emit('policy-changed', key);
- },
-
- _canonicalizeId: function(id) {
- // Keys are restricted to lowercase alphanumeric characters and dash,
- // and two dashes cannot be in succession
- return id.toLowerCase().replace(/[^a-z0-9\-]/g, '-').replace(/--+/g, '-');
- },
-
- get enable() {
- return this._settings.get_boolean('enable');
- },
-
- get enableSound() {
- return this._settings.get_boolean('enable-sound-alerts');
- },
-
- get showBanners() {
- return this._masterSettings.get_boolean('show-banners') &&
- this._settings.get_boolean('show-banners');
- },
-
- get forceExpanded() {
- return this._settings.get_boolean('force-expanded');
- },
-
- get showInLockScreen() {
- return this._masterSettings.get_boolean('show-in-lock-screen') &&
- this._settings.get_boolean('show-in-lock-screen');
- },
-
- get detailsInLockScreen() {
- return this._settings.get_boolean('details-in-lock-screen');
- }
-});
-
const NotificationDaemon = new Lang.Class({
Name: 'NotificationDaemon',
@@ -675,9 +555,9 @@ const Source = new Lang.Class({
_createPolicy: function() {
if (this.app) {
let id = this.app.get_id().replace(/\.desktop$/,'');
- return new NotificationApplicationPolicy(id);
+ return new MessageTray.NotificationApplicationPolicy(id);
} else {
- return new NotificationGenericPolicy();
+ return new MessageTray.NotificationGenericPolicy();
}
},
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index c808d10..fb4bad2 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -9,7 +9,6 @@ const St = imports.gi.St;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
-const NotificationDaemon = imports.ui.notificationDaemon;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
@@ -61,7 +60,7 @@ const Indicator = new Lang.Class({
_ensureSource: function() {
if (!this._source) {
this._source = new MessageTray.Source(_("Bluetooth"), 'bluetooth-active');
- this._source.policy = new
NotificationDaemon.NotificationApplicationPolicy('gnome-bluetooth-panel');
+ this._source.policy = new MessageTray.NotificationApplicationPolicy('gnome-bluetooth-panel');
Main.messageTray.add(this._source);
}
},
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index f43428f..fdd95a7 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -16,7 +16,6 @@ const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const MessageTray = imports.ui.messageTray;
-const NotificationDaemon = imports.ui.notificationDaemon;
const ModalDialog = imports.ui.modalDialog;
const ModemManager = imports.misc.modemManager;
const Util = imports.misc.util;
@@ -1367,7 +1366,7 @@ const NMApplet = new Lang.Class({
if (!this._source) {
this._source = new MessageTray.Source(_("Network Manager"),
'network-transmit-receive');
- this._source.policy = new
NotificationDaemon.NotificationApplicationPolicy('gnome-network-panel');
+ this._source.policy = new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
this._source.connect('destroy', Lang.bind(this, function() {
this._source = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]