[gnome-shell] NotificationDaemon: add rewriteRules infrastructure, use it for xchat
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] NotificationDaemon: add rewriteRules infrastructure, use it for xchat
- Date: Mon, 22 Feb 2010 22:09:45 +0000 (UTC)
commit d8800c095a67010a0dbaea59b74e9ffe300a9fa6
Author: Dan Winship <danw gnome org>
Date: Tue Feb 16 17:32:19 2010 -0500
NotificationDaemon: add rewriteRules infrastructure, use it for xchat
Changes notifications like:
XChat: Private message from: danw (GimpNet) blah...
to
danw: blah blah blah blah
(the "XChat" being unnecessary since there's already an xchat icon
there anyway.)
https://bugzilla.gnome.org/show_bug.cgi?id=608915
js/ui/notificationDaemon.js | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index de74714..6e53f1a 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -69,6 +69,16 @@ const Urgency = {
CRITICAL: 2
};
+const rewriteRules = {
+ 'XChat': [
+ { pattern: /^XChat: Private message from: (\S*) \(.*\)$/,
+ replacement: '<$1>' },
+ { pattern: /^XChat: New public message from: (\S*) \((.*)\)$/,
+ replacement: '$2 <$1>' },
+ { pattern: /^XChat: Highlighted message from: (\S*) \((.*)\)$/,
+ replacement: '$2 <$1>' }
+ ]
+};
function NotificationDaemon() {
this._init();
}
@@ -150,6 +160,15 @@ NotificationDaemon.prototype = {
summary = GLib.markup_escape_text(summary, -1);
+ let rewrites = rewriteRules[appName];
+ if (rewrites) {
+ for (let i = 0; i < rewrites.length; i++) {
+ let rule = rewrites[i];
+ if (summary.search(rule.pattern) != -1)
+ summary = summary.replace(rule.pattern, rule.replacement);
+ }
+ }
+
let notification = new MessageTray.Notification(source, summary, body, true);
if (actions.length) {
for (let i = 0; i < actions.length - 1; i += 2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]