2010-01-13 15:05:20 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
|
|
|
const DBus = imports.dbus;
|
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const Mainloop = imports.mainloop;
|
2010-03-08 08:13:59 -05:00
|
|
|
const St = imports.gi.St;
|
2010-10-27 16:00:51 -04:00
|
|
|
const Gettext = imports.gettext.domain('gnome-shell');
|
|
|
|
const _ = Gettext.gettext;
|
2010-01-13 15:05:20 -05:00
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
const MessageTray = imports.ui.messageTray;
|
|
|
|
const Params = imports.misc.params;
|
|
|
|
|
|
|
|
let nextNotificationId = 1;
|
|
|
|
|
2010-02-15 12:27:28 -05:00
|
|
|
// Should really be defined in dbus.js
|
|
|
|
const BusIface = {
|
|
|
|
name: 'org.freedesktop.DBus',
|
|
|
|
methods: [{ name: 'GetConnectionUnixProcessID',
|
|
|
|
inSignature: 's',
|
|
|
|
outSignature: 'i' }]
|
2010-03-15 09:50:05 -04:00
|
|
|
};
|
2010-02-15 12:27:28 -05:00
|
|
|
|
|
|
|
const Bus = function () {
|
|
|
|
this._init();
|
2010-03-15 09:50:05 -04:00
|
|
|
};
|
2010-02-15 12:27:28 -05:00
|
|
|
|
|
|
|
Bus.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
DBus.session.proxifyObject(this, 'org.freedesktop.DBus', '/org/freedesktop/DBus');
|
|
|
|
}
|
2010-03-15 09:50:05 -04:00
|
|
|
};
|
2010-02-15 12:27:28 -05:00
|
|
|
|
|
|
|
DBus.proxifyPrototype(Bus.prototype, BusIface);
|
|
|
|
|
2010-01-13 15:05:20 -05:00
|
|
|
const NotificationDaemonIface = {
|
|
|
|
name: 'org.freedesktop.Notifications',
|
|
|
|
methods: [{ name: 'Notify',
|
|
|
|
inSignature: 'susssasa{sv}i',
|
|
|
|
outSignature: 'u'
|
|
|
|
},
|
|
|
|
{ name: 'CloseNotification',
|
|
|
|
inSignature: 'u',
|
|
|
|
outSignature: ''
|
|
|
|
},
|
|
|
|
{ name: 'GetCapabilities',
|
|
|
|
inSignature: '',
|
|
|
|
outSignature: 'as'
|
|
|
|
},
|
|
|
|
{ name: 'GetServerInformation',
|
|
|
|
inSignature: '',
|
|
|
|
outSignature: 'ssss'
|
|
|
|
}],
|
|
|
|
signals: [{ name: 'NotificationClosed',
|
|
|
|
inSignature: 'uu' },
|
|
|
|
{ name: 'ActionInvoked',
|
|
|
|
inSignature: 'us' }]
|
|
|
|
};
|
|
|
|
|
|
|
|
const NotificationClosedReason = {
|
|
|
|
EXPIRED: 1,
|
|
|
|
DISMISSED: 2,
|
|
|
|
APP_CLOSED: 3,
|
|
|
|
UNDEFINED: 4
|
|
|
|
};
|
|
|
|
|
|
|
|
const Urgency = {
|
|
|
|
LOW: 0,
|
|
|
|
NORMAL: 1,
|
|
|
|
CRITICAL: 2
|
|
|
|
};
|
|
|
|
|
2010-02-16 17:32:19 -05:00
|
|
|
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>' }
|
|
|
|
]
|
|
|
|
};
|
2010-06-23 15:20:39 -04:00
|
|
|
|
2010-01-13 15:05:20 -05:00
|
|
|
function NotificationDaemon() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationDaemon.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
DBus.session.exportObject('/org/freedesktop/Notifications', this);
|
|
|
|
|
|
|
|
this._everAcquiredName = false;
|
|
|
|
DBus.session.acquire_name('org.freedesktop.Notifications',
|
|
|
|
// We pass MANY_INSTANCES so that if
|
|
|
|
// notification-daemon is running, we'll
|
|
|
|
// get queued behind it and then get the
|
|
|
|
// name after killing it below
|
|
|
|
DBus.MANY_INSTANCES,
|
|
|
|
Lang.bind(this, this._acquiredName),
|
|
|
|
Lang.bind(this, this._lostName));
|
2010-02-22 17:19:32 -05:00
|
|
|
|
2010-08-09 13:18:15 -04:00
|
|
|
this._sources = {};
|
2010-09-02 10:45:53 -04:00
|
|
|
this._senderToPid = {};
|
|
|
|
this._notifications = {};
|
|
|
|
this._busProxy = new Bus();
|
2010-02-21 00:25:23 -05:00
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
Main.statusIconDispatcher.connect('message-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
|
|
|
Main.statusIconDispatcher.connect('message-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
|
|
|
|
|
2010-02-21 00:25:23 -05:00
|
|
|
Shell.WindowTracker.get_default().connect('notify::focus-app',
|
|
|
|
Lang.bind(this, this._onFocusAppChanged));
|
2010-02-24 15:46:00 -05:00
|
|
|
Main.overview.connect('hidden',
|
|
|
|
Lang.bind(this, this._onFocusAppChanged));
|
2010-01-13 15:05:20 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_acquiredName: function() {
|
|
|
|
this._everAcquiredName = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_lostName: function() {
|
|
|
|
if (this._everAcquiredName)
|
|
|
|
log('Lost name org.freedesktop.Notifications!');
|
|
|
|
else if (GLib.getenv('GNOME_SHELL_NO_REPLACE'))
|
|
|
|
log('Failed to acquire org.freedesktop.Notifications');
|
|
|
|
else {
|
|
|
|
log('Failed to acquire org.freedesktop.Notifications; trying again');
|
|
|
|
|
|
|
|
// kill the notification-daemon. pkill is more portable
|
|
|
|
// than killall, but on Linux at least it won't match if
|
|
|
|
// you pass more than 15 characters of the process name...
|
2010-05-13 15:46:04 -04:00
|
|
|
// However, if you use the '-f' flag to match the entire
|
2010-01-13 15:05:20 -05:00
|
|
|
// command line, it will work, but we have to be careful
|
2010-05-13 15:46:04 -04:00
|
|
|
// in that case that we don't match 'gedit
|
|
|
|
// notification-daemon.c' or whatever...
|
2010-01-13 15:05:20 -05:00
|
|
|
let p = new Shell.Process({ args: ['pkill', '-f',
|
|
|
|
'^([^ ]*/)?(notification-daemon|notify-osd)$']});
|
|
|
|
p.run();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-08-05 13:09:27 -04:00
|
|
|
_iconForNotificationData: function(icon, hints, size) {
|
|
|
|
let textureCache = St.TextureCache.get_default();
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
if (icon.substr(0, 7) == 'file://')
|
|
|
|
return textureCache.load_uri_async(icon, size, size);
|
|
|
|
else if (icon[0] == '/') {
|
|
|
|
let uri = GLib.filename_to_uri(icon, null);
|
|
|
|
return textureCache.load_uri_async(uri, size, size);
|
|
|
|
} else
|
2010-09-16 11:04:51 -04:00
|
|
|
return textureCache.load_icon_name(icon, St.IconType.FULLCOLOR, size);
|
2010-08-05 13:09:27 -04:00
|
|
|
} else if (hints.icon_data) {
|
|
|
|
let [width, height, rowStride, hasAlpha,
|
|
|
|
bitsPerSample, nChannels, data] = hints.icon_data;
|
|
|
|
return textureCache.load_from_raw(data, data.length, hasAlpha,
|
|
|
|
width, height, rowStride, size);
|
|
|
|
} else {
|
|
|
|
let stockIcon;
|
|
|
|
switch (hints.urgency) {
|
|
|
|
case Urgency.LOW:
|
|
|
|
case Urgency.NORMAL:
|
|
|
|
stockIcon = 'gtk-dialog-info';
|
|
|
|
break;
|
|
|
|
case Urgency.CRITICAL:
|
|
|
|
stockIcon = 'gtk-dialog-error';
|
|
|
|
break;
|
|
|
|
}
|
2010-09-16 11:04:51 -04:00
|
|
|
return textureCache.load_icon_name(stockIcon, St.IconType.FULLCOLOR, size);
|
2010-08-05 13:09:27 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
_newSource: function(title, pid) {
|
|
|
|
let source = new Source(title, pid);
|
|
|
|
this._sources[pid] = source;
|
|
|
|
|
|
|
|
source.connect('destroy', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
delete this._sources[pid];
|
|
|
|
}));
|
|
|
|
|
|
|
|
Main.messageTray.add(source);
|
|
|
|
return source;
|
|
|
|
},
|
|
|
|
|
2010-01-13 15:05:20 -05:00
|
|
|
Notify: function(appName, replacesId, icon, summary, body,
|
|
|
|
actions, hints, timeout) {
|
2010-09-02 10:45:53 -04:00
|
|
|
let id;
|
2010-01-13 15:05:20 -05:00
|
|
|
|
2010-02-02 10:21:47 -05:00
|
|
|
// Filter out notifications from Empathy, since we
|
|
|
|
// handle that information from telepathyClient.js
|
|
|
|
if (appName == 'Empathy') {
|
2010-09-02 10:45:53 -04:00
|
|
|
// Ignore replacesId since we already sent back a
|
|
|
|
// NotificationClosed for that id.
|
2010-02-02 10:21:47 -05:00
|
|
|
id = nextNotificationId++;
|
|
|
|
Mainloop.idle_add(Lang.bind(this,
|
|
|
|
function () {
|
|
|
|
this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
|
|
|
|
}));
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2010-01-13 15:05:20 -05:00
|
|
|
summary = GLib.markup_escape_text(summary, -1);
|
2010-02-01 15:23:49 -05:00
|
|
|
|
2010-02-16 17:32:19 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-02 10:45:53 -04:00
|
|
|
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
|
|
|
|
|
|
|
|
let ndata = { appName: appName,
|
|
|
|
icon: icon,
|
|
|
|
summary: summary,
|
|
|
|
body: body,
|
|
|
|
actions: actions,
|
|
|
|
hints: hints,
|
|
|
|
timeout: timeout };
|
|
|
|
if (replacesId != 0 && this._notifications[replacesId]) {
|
|
|
|
ndata.id = id = replacesId;
|
|
|
|
ndata.notification = this._notifications[replacesId].notification;
|
|
|
|
} else {
|
|
|
|
replacesId = 0;
|
|
|
|
ndata.id = id = nextNotificationId++;
|
|
|
|
}
|
|
|
|
this._notifications[id] = ndata;
|
|
|
|
|
|
|
|
let sender = DBus.getCurrentMessageContext().sender;
|
|
|
|
let pid = this._senderToPid[sender];
|
|
|
|
let source = pid ? this._sources[pid] : null;
|
|
|
|
|
|
|
|
if (source) {
|
|
|
|
this._notifyForSource(source, ndata);
|
|
|
|
return id;
|
2010-02-23 10:50:35 -05:00
|
|
|
}
|
|
|
|
|
2010-09-02 10:45:53 -04:00
|
|
|
if (replacesId) {
|
|
|
|
// There's already a pending call to GetConnectionUnixProcessID,
|
|
|
|
// which will see the new notification data when it finishes,
|
|
|
|
// so we don't have to do anything.
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._busProxy.GetConnectionUnixProcessIDRemote(sender, Lang.bind(this,
|
|
|
|
function (pid, ex) {
|
|
|
|
// The app may have updated or removed the notification
|
|
|
|
ndata = this._notifications[id];
|
|
|
|
if (!ndata)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._senderToPid[sender] = pid;
|
|
|
|
source = this._sources[pid];
|
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
if (!source)
|
|
|
|
source = this._newSource(appName, pid);
|
|
|
|
source.connect('destroy', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
delete this._senderToPid[sender];
|
|
|
|
}));
|
2010-09-02 10:45:53 -04:00
|
|
|
|
|
|
|
this._notifyForSource(source, ndata);
|
|
|
|
}));
|
|
|
|
|
|
|
|
return id;
|
|
|
|
},
|
|
|
|
|
|
|
|
_notifyForSource: function(source, ndata) {
|
|
|
|
let [id, icon, summary, body, actions, hints, notification] =
|
|
|
|
[ndata.id, ndata.icon, ndata.summary, ndata.body,
|
|
|
|
ndata.actions, ndata.hints, ndata.notification];
|
|
|
|
|
2010-08-05 13:09:27 -04:00
|
|
|
let iconActor = this._iconForNotificationData(icon, hints, source.ICON_SIZE);
|
2010-09-02 10:45:53 -04:00
|
|
|
|
2010-02-22 17:19:32 -05:00
|
|
|
if (notification == null) {
|
2010-09-02 10:45:53 -04:00
|
|
|
notification = new MessageTray.Notification(source, summary, body, { icon: iconActor });
|
|
|
|
ndata.notification = notification;
|
MessageTray: untangle click notifications
Previously, when you clicked on a notification, it would call
this.source.clicked(), which would emit a 'clicked' signal on the
source, and then various other stuff would happen from there. This
used to make a little bit of sense, when clicking on a notification
was supposed to do the same thing as clicking on its source, but makes
less sense now, when clicking on the source itself *doesn't* call
source.clicked()...
Change it so that when you click on a notification, the notification
emits 'clicked' itself, and the source notices that and calls its
notificationClicked() method, and the various source subclasses do
what they need to do with that, and Source no longer has a clicked
method/signal.
https://bugzilla.gnome.org/show_bug.cgi?id=631042
2010-09-30 16:41:38 -04:00
|
|
|
notification.connect('clicked', Lang.bind(this,
|
2010-02-22 17:19:32 -05:00
|
|
|
function(n) {
|
2010-08-11 09:43:40 -04:00
|
|
|
this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
|
2010-02-22 17:19:32 -05:00
|
|
|
}));
|
2010-07-14 17:07:06 -04:00
|
|
|
notification.connect('destroy', Lang.bind(this,
|
|
|
|
function(n) {
|
2010-09-02 10:45:53 -04:00
|
|
|
delete this._notifications[id];
|
2010-07-14 17:07:06 -04:00
|
|
|
}));
|
|
|
|
notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
|
2010-02-22 17:19:32 -05:00
|
|
|
} else {
|
2010-08-05 13:09:27 -04:00
|
|
|
notification.update(summary, body, { icon: iconActor,
|
|
|
|
clear: true });
|
2010-02-22 17:19:32 -05:00
|
|
|
}
|
|
|
|
|
2010-02-01 15:41:22 -05:00
|
|
|
if (actions.length) {
|
2010-10-30 02:29:21 -04:00
|
|
|
notification.setUseActionIcons(hints['action-icons'] == true);
|
2010-02-01 15:41:22 -05:00
|
|
|
for (let i = 0; i < actions.length - 1; i += 2)
|
2010-02-22 14:23:36 -05:00
|
|
|
notification.addButton(actions[i], actions[i + 1]);
|
2010-02-01 15:41:22 -05:00
|
|
|
}
|
|
|
|
|
2010-04-28 15:34:27 -04:00
|
|
|
notification.setUrgent(hints.urgency == Urgency.CRITICAL);
|
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
let sourceIconActor = source.useNotificationIcon ? this._iconForNotificationData(icon, hints, source.ICON_SIZE) : null;
|
2010-09-02 10:45:53 -04:00
|
|
|
source.notify(notification, sourceIconActor);
|
2010-01-13 15:05:20 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
CloseNotification: function(id) {
|
2010-09-02 10:45:53 -04:00
|
|
|
let ndata = this._notifications[id];
|
|
|
|
if (ndata) {
|
|
|
|
if (ndata.notification)
|
|
|
|
ndata.notification.destroy();
|
|
|
|
delete this._notifications[id];
|
|
|
|
}
|
2010-01-13 15:05:20 -05:00
|
|
|
this._emitNotificationClosed(id, NotificationClosedReason.APP_CLOSED);
|
|
|
|
},
|
|
|
|
|
|
|
|
GetCapabilities: function() {
|
|
|
|
return [
|
2010-02-01 15:41:22 -05:00
|
|
|
'actions',
|
2010-10-30 02:29:21 -04:00
|
|
|
'action-icons',
|
2010-01-13 15:05:20 -05:00
|
|
|
'body',
|
|
|
|
// 'body-hyperlinks',
|
|
|
|
// 'body-images',
|
|
|
|
'body-markup',
|
|
|
|
// 'icon-multi',
|
2010-06-11 17:19:18 -04:00
|
|
|
'icon-static',
|
2010-10-08 22:34:04 -04:00
|
|
|
'persistence',
|
2010-01-13 15:05:20 -05:00
|
|
|
// 'sound',
|
|
|
|
];
|
|
|
|
},
|
|
|
|
|
|
|
|
GetServerInformation: function() {
|
|
|
|
return [
|
|
|
|
'GNOME Shell',
|
|
|
|
'GNOME',
|
|
|
|
'0.1', // FIXME, get this from somewhere
|
|
|
|
'1.0'
|
|
|
|
];
|
|
|
|
},
|
|
|
|
|
2010-02-24 15:46:00 -05:00
|
|
|
_onFocusAppChanged: function() {
|
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
2010-08-09 13:18:15 -04:00
|
|
|
if (!tracker.focus_app)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (let id in this._sources) {
|
|
|
|
let source = this._sources[id];
|
|
|
|
if (source.app == tracker.focus_app) {
|
2010-09-30 16:56:50 -04:00
|
|
|
source.activated();
|
2010-08-09 13:18:15 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-02-21 00:25:23 -05:00
|
|
|
},
|
|
|
|
|
2010-02-01 15:41:22 -05:00
|
|
|
_actionInvoked: function(notification, action, source, id) {
|
2010-09-30 16:56:50 -04:00
|
|
|
source.activated();
|
2010-07-14 17:07:06 -04:00
|
|
|
this._emitActionInvoked(id, action);
|
2010-02-01 15:41:22 -05:00
|
|
|
},
|
|
|
|
|
2010-01-13 15:05:20 -05:00
|
|
|
_emitNotificationClosed: function(id, reason) {
|
|
|
|
DBus.session.emit_signal('/org/freedesktop/Notifications',
|
|
|
|
'org.freedesktop.Notifications',
|
|
|
|
'NotificationClosed', 'uu',
|
|
|
|
[id, reason]);
|
2010-02-01 15:41:22 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_emitActionInvoked: function(id, action) {
|
|
|
|
DBus.session.emit_signal('/org/freedesktop/Notifications',
|
|
|
|
'org.freedesktop.Notifications',
|
|
|
|
'ActionInvoked', 'us',
|
|
|
|
[id, action]);
|
2010-08-09 12:33:34 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onTrayIconAdded: function(o, icon) {
|
|
|
|
let source = this._sources[icon.pid];
|
|
|
|
if (!source)
|
2010-10-24 08:31:41 -04:00
|
|
|
source = this._newSource(icon.title || icon.wm_class || _("Unknown"), icon.pid);
|
2010-08-09 12:33:34 -04:00
|
|
|
source.setTrayIcon(icon);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onTrayIconRemoved: function(o, icon) {
|
|
|
|
let source = this._sources[icon.pid];
|
|
|
|
if (source)
|
|
|
|
source.destroy();
|
2010-01-13 15:05:20 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
DBus.conformExport(NotificationDaemon.prototype, NotificationDaemonIface);
|
|
|
|
|
2010-09-02 10:45:53 -04:00
|
|
|
function Source(title, pid) {
|
|
|
|
this._init(title, pid);
|
2010-01-13 15:05:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Source.prototype = {
|
|
|
|
__proto__: MessageTray.Source.prototype,
|
|
|
|
|
2010-09-02 10:45:53 -04:00
|
|
|
_init: function(title, pid) {
|
2010-08-09 13:18:15 -04:00
|
|
|
MessageTray.Source.prototype._init.call(this, title);
|
2010-01-13 15:05:20 -05:00
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
this._pid = pid;
|
|
|
|
this._setApp();
|
|
|
|
if (this.app)
|
2010-09-02 10:45:53 -04:00
|
|
|
this.title = this.app.get_name();
|
2010-08-09 12:33:34 -04:00
|
|
|
else
|
|
|
|
this.useNotificationIcon = true;
|
2010-09-30 16:56:50 -04:00
|
|
|
this._isTrayIcon = false;
|
2010-01-13 15:05:20 -05:00
|
|
|
},
|
|
|
|
|
2010-09-02 10:45:53 -04:00
|
|
|
notify: function(notification, icon) {
|
2010-08-09 12:33:34 -04:00
|
|
|
if (!this.app)
|
|
|
|
this._setApp();
|
|
|
|
if (!this.app && icon)
|
2010-09-02 10:45:53 -04:00
|
|
|
this._setSummaryIcon(icon);
|
2010-08-05 13:09:27 -04:00
|
|
|
MessageTray.Source.prototype.notify.call(this, notification);
|
2010-02-15 12:27:28 -05:00
|
|
|
},
|
|
|
|
|
2010-08-09 12:33:34 -04:00
|
|
|
_setApp: function() {
|
|
|
|
this.app = Shell.WindowTracker.get_default().get_app_from_pid(this._pid);
|
|
|
|
if (!this.app)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Only override the icon if we were previously using
|
|
|
|
// notification-based icons (ie, not a trayicon)
|
|
|
|
if (this.useNotificationIcon) {
|
|
|
|
this.useNotificationIcon = false;
|
|
|
|
this._setSummaryIcon(this.app.create_icon_texture (this.ICON_SIZE));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setTrayIcon: function(icon) {
|
|
|
|
this._setSummaryIcon(icon);
|
|
|
|
this.useNotificationIcon = false;
|
2010-09-30 16:56:50 -04:00
|
|
|
this._isTrayIcon = true;
|
2010-08-09 12:33:34 -04:00
|
|
|
},
|
|
|
|
|
2010-09-30 16:56:50 -04:00
|
|
|
_notificationClicked: function(notification) {
|
|
|
|
notification.destroy();
|
2010-02-15 12:27:28 -05:00
|
|
|
this.openApp();
|
2010-09-30 16:56:50 -04:00
|
|
|
this.activated();
|
|
|
|
},
|
|
|
|
|
|
|
|
activated: function() {
|
|
|
|
if (!this._isTrayIcon)
|
|
|
|
this.destroy();
|
2010-02-15 12:27:28 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
openApp: function() {
|
2010-09-02 10:45:53 -04:00
|
|
|
if (this.app == null)
|
2010-02-15 12:27:28 -05:00
|
|
|
return;
|
2010-09-02 10:45:53 -04:00
|
|
|
|
2010-02-15 12:27:28 -05:00
|
|
|
let windows = this.app.get_windows();
|
|
|
|
if (windows.length > 0) {
|
|
|
|
let mostRecentWindow = windows[0];
|
|
|
|
Main.activateWindow(mostRecentWindow);
|
|
|
|
}
|
2010-01-13 15:05:20 -05:00
|
|
|
}
|
|
|
|
};
|