/usr/share/gnome-shell/extensions/mailnag@pulb.github.com/source.js is in gnome-shell-mailnag 3.14.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | /* Mailnag - GNOME-Shell extension frontend
*
* Copyright 2013, 2014 Patrick Ulbrich <zulu99@gmx.net>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
const Main = imports.ui.main;
const St = imports.gi.St;
const MessageTray = imports.ui.messageTray;
const Lang = imports.lang;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const SOURCE_ICON = 'mail-unread';
const MailnagSource = new Lang.Class({
Name: 'MailnagSource',
Extends: MessageTray.Source,
_init: function(maxVisibleMails) {
this._count = 0;
this._maxVisisbleMails = maxVisibleMails;
this.parent("Mailnag", SOURCE_ICON);
Main.messageTray.connect("source-added",
Lang.bind(this, this._onSourceAdded));
},
get count() {
return this._count;
},
get indicatorCount() {
return this._count;
},
get unseenCount() {
// TODO : Return count of mails newly reported by mailnag?
if ((this.notifications.length > 0) && (!this.notifications[0].acknowledged)) {
return this._count;
} else {
return 0;
}
},
open: function() {
Utils.openDefaultMailReader();
},
notifySummary: function(mails) {
let summary = "";
let body = "";
let maxMails = (mails.length <= this._maxVisisbleMails) ?
mails.length : this._maxVisisbleMails;
this._count = mails.length;
for (let i = 0; i < maxMails; i++) {
let sender = mails[i]['sender_name'].get_string()[0];
if (sender.length == 0) sender = mails[i]['sender_addr'].get_string()[0];
body += sender + ":\n<i>" + mails[i]['subject'].get_string()[0] + "</i>\n\n";
}
if (mails.length > this._maxVisisbleMails) {
body += "<i>" + _("(and {0} more)").replace("{0}", (mails.length - this._maxVisisbleMails)) + "</i>";
}
if (mails.length > 1) {
summary = _("{0} new mails").replace("{0}", mails.length);
} else {
summary = _("New mail");
}
let params = { bannerMarkup : true };
let n = null;
if (this.notifications.length == 0) {
n = new Main.MessageTray.Notification(this,
summary, body, params);
n.connect('clicked', function() {
Utils.openDefaultMailReader();
});
} else {
n = this.notifications[0];
n.update(summary, body, params);
// this.notify() updates the counter badge for *new* notifications only
// so update the counter manually in case of an updated notification.
this.countUpdated();
}
this.notify(n);
},
_onSourceAdded: function(sender, source) {
if (source != this)
return;
// Patch the Source's SummaryItem (left-click popup banner)
// to always scroll to the top instead of to the bottom
// (new mails are shown on top of the notification stack).
let obj = Main.messageTray._sources.get(this);
if (obj != null) {
let summaryItem = obj.summaryItem;
let origMethod = summaryItem.prepareNotificationStackForShowing;
summaryItem.prepareNotificationStackForShowing = function() {
origMethod.call(this);
summaryItem.scrollTo(St.Side.TOP);
}
summaryItem._oldMaxScrollAdjustment = -1;
}
}
});
|