Skip to content

Commit

Permalink
version 0.4.0 is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
inbasic committed Feb 22, 2014
1 parent e1151fa commit 8b3eb87
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/data/context.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ ul
text-overflow: ellipsis;
}
#content[type="expanded"] .sender {
max-width: 420px;
max-width: 410px;
}

#email {
Expand Down
Binary file modified src/gmail-notifier.xpi
Binary file not shown.
31 changes: 16 additions & 15 deletions src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var config = {
return temp;
},
maxCount: 20,
maxReport: 1 //Maximum number of simultaneous reports from a single account
maxReport: 1, //Maximum number of simultaneous reports from a single account
timeout: 9000
},
//Timing
get period () {return (prefs.period > 10 ? prefs.period : 10) * 1000},
Expand Down Expand Up @@ -88,7 +89,7 @@ var config = {

/** tray callback handling **/
tray.callback.install(function () {
console.error(windows.active.focus);
windows.active.focus();
timer.setTimeout(onCommand, 100);
});
/** libraries **/
Expand Down Expand Up @@ -664,7 +665,7 @@ function Server () {
return d.promise;
}
}
var emails = config.email.feeds.map((feed) => new Email(feed, 5000));
var emails = config.email.feeds.map((feed) => new Email(feed, config.email.timeout));
return (function () {
var color = "blue", count = -1;
return function (forced) {
Expand All @@ -680,14 +681,14 @@ function Server () {
icon(null, "blue");
color = "blue";
count = -1;
unreadObjs = [];
}
if (forced) {
open(config.email.url);
notify(_("gmail"), _("msg1"), false);
}
tray.remove();
gButton.tooltiptext = config.defaultTooltip;
console.error(objs, "exit 4");
return;
}
//Removing not logged-in accounts
Expand All @@ -704,7 +705,6 @@ console.error(objs, "exit 4");
var newCount = objs.reduce((p,c) => p + c.xml.fullcount, 0);
//
if (!anyNewEmails && !forced && count === newCount) {
console.error(objs, "exit 0", forced, anyNewEmails);
return; //Everything is clear
}
count = newCount;
Expand Down Expand Up @@ -743,33 +743,33 @@ console.error(objs, "exit 0", forced, anyNewEmails);
).replace(/\n$/, "");
if (!forced && !anyNewEmails) {
if (newCount) {
icon(newCount, "red"); color = "red";
icon(newCount, "red");
color = "red";
tray.set(newCount, tooltip);
gButton.tooltiptext = tooltip;
}
else {
icon(null, "gray"); color = "gray";
icon(null, "gray");
color = "gray";
tray.remove();
gButton.tooltiptext = tooltip;
}
console.error(objs, "exit 1", forced, anyNewEmails);
}
else if (forced && !newCount) {
icon(null, "gray"); color = "gray";
icon(null, "gray");
color = "gray";
tray.remove();
gButton.tooltiptext = tooltip;
console.error(objs, "exit 3", forced, anyNewEmails);
}
else {
icon(newCount, "new"); color = "new";
icon(newCount, "new");
color = "new";
if (prefs.notification) {
notify(_("gmail"), report, true);
}
if (prefs.tray) tray.set(newCount, tooltip);
if (prefs.alert) play();
gButton.tooltiptext = tooltip;

console.error(objs, "exit 2", forced, anyNewEmails);
}
//Updating the toolbar panel if exists
if (contextPanel.isShowing) {
Expand Down Expand Up @@ -811,6 +811,7 @@ sp.on("reset", function() {
prefs.soundVolume = 80;
prefs.tray = true;
prefs.notificationFormat = "From: [author_email][break]Title: [title][break]Summary: [summary]";
prefs.doTrayCallback = false;
});
sp.on("tray", function() {
if (!prefs.tray) {
Expand All @@ -819,7 +820,7 @@ sp.on("tray", function() {
else {
tm.reset(true);
}
})
});

/**
* Send archive, mark as read, mark as unread, and trash commands to Gmail server
Expand Down Expand Up @@ -958,7 +959,7 @@ var notify = (function () { // https://github.com/fwenzel/copy-shorturl/blob/mas
timer.setTimeout(function () {
// If main window is not focused, restore it first!
windows.active.focus();
onCommand();
timer.setTimeout(onCommand, 100);
}, 100);
}
}, "");
Expand Down
21 changes: 16 additions & 5 deletions src/lib/tray/winnt/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ nid.uTimeoutAndVersion = config.time.notification;
nid.uFlags = 0x00000001 /* NIF_MESSAGE */ | 0x00000002 /* NIF_ICON */ | 0x00000004 /* NIF_TIP */ /* | 0x000000010 NIF_INFO */;
nid.dwInfoFlags = 0x00000001 /* NIIF_INFO */;
//nid.szInfoTitle = _("gmail"); // "Balloon Tooltip" title
// Windows Version
var version = parseInt((/\d\.\d/.exec(windows.active.navigator.oscpu) || ["0"])[0].replace(".", ""));
nid.cbSize = (function () {
function FIELD_OFFSET(aType, aField, aPos) {
var addr2nb = (a) => ctypes.cast(a, ctypes.unsigned_long).value,
s = new aType(),
addr_field = typeof(aPos) === "undefined" ? addr2nb(s.addressOfField(aField)) : addr2nb(s[aField].addressOfElement(aPos));
return addr_field - addr2nb(s.address());
}
// Windows Version
var version = parseInt((/\d\.\d/.exec(windows.active.navigator.oscpu) || ["0"])[0].replace(".", ""));
if (version >= 60) { //Vista
return NOTIFYICONDATAW.size;
}
Expand All @@ -190,7 +190,17 @@ var proxyWndProc = WNDPROC (function (hWnd, uMsg, wParam, lParam) {
}
return user32.DefWindowProcW(hWnd, uMsg, wParam, lParam);
})
var oldOffset = user32.SetWindowLongW(hWnd, -4 /* GWLP_WNDPROC */, ctypes.cast(proxyWndProc, LONG_PTR));

var oldOffset;
if (!prefs.trayFirstRun) {
prefs.trayFirstRun = true;
if (version >= 60) { //Vista
prefs.doTrayCallback = true;
}
}
if (prefs.doTrayCallback) {
oldOffset = user32.SetWindowLongW(hWnd, -4 /* GWLP_WNDPROC */, ctypes.cast(proxyWndProc, LONG_PTR));
}

var isInstalled = false;
exports.set = function (badge, msg) {
Expand All @@ -216,8 +226,9 @@ exports.callback = {
callback = c;
},
remove: function () {
console.error(0, oldOffset.toSource())
user32.SetWindowLongW(hWnd, -4, oldOffset);
if (oldOffset) {
user32.SetWindowLongW(hWnd, -4, oldOffset);
}
}
}

9 changes: 8 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"contributors": ["CaTz", "ecaron"],

"url": "",
"version": "0.4.0b1",
"version": "0.4.0",
"lib": "lib",
"main": "main",

Expand Down Expand Up @@ -77,6 +77,13 @@
"type": "bool",
"value": true
},
{
"name": "doTrayCallback",
"title": "Open toolbar panel when click on the taskbar notification icon (beta):",
"description": "This feature is highly experimental and might make your Firefox browser unstable. [Restart required]",
"type": "bool",
"value": false
},
{
"name": "alphabetic",
"title": "Sort account selections alphabetically:",
Expand Down
2 changes: 1 addition & 1 deletion template/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>27.0</em:minVersion>
<em:minVersion>25.0</em:minVersion>
<em:maxVersion>30.0</em:maxVersion>
</Description>
</em:targetApplication>
Expand Down

0 comments on commit 8b3eb87

Please sign in to comment.