Permalink
Browse files

tray icon implementation for Windows OS (compatibility fixes)

  • Loading branch information...
1 parent 8fa478b commit e1151fac183517357bbc70504a9fc64c374715a4 @inbasic committed Feb 16, 2014
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Binary file not shown.
View
@@ -28,7 +28,10 @@ var tabs = require("sdk/tabs"),
return {
set: function () {},
remove: function () {},
- callback: function () {}
+ callback: {
+ install: function () {},
+ remove: function () {}
+ }
};
})();
@@ -84,9 +87,9 @@ var config = {
};
/** tray callback handling **/
-tray.callback(function () {
- windows.active.focus();
- onCommand();
+tray.callback.install(function () {
+ console.error(windows.active.focus);
+ timer.setTimeout(onCommand, 100);
});
/** libraries **/
Cu.import("resource://gre/modules/Promise.jsm");
@@ -242,7 +245,7 @@ contextPanel.port.on("clipboard", (function () {
.getService(Ci.nsIClipboardHelper);
return function (str) {
gClipboardHelper.copyString(str);
- notify(_("gmail"), _("msg13"), true);
+ notify(_("gmail"), _("msg13"));
}
})());
@@ -425,13 +428,14 @@ exports.main = function(options, callbacks) {
var aWindow = windows.active;
var aftercustomizationListener = function () {
let button = aWindow.document.getElementById(config.toolbar.id);
- if (!button) return;
+ if (!button || !button.nextSibling) return;
prefs.nextSibling = button.nextSibling.id;
}
aWindow.addEventListener("aftercustomization", aftercustomizationListener, false);
exports.onUnload = function (reason) {
aWindow.removeEventListener("aftercustomization", aftercustomizationListener, false);
tray.remove();
+ tray.callback.remove();
}
/** Prefs Listener**/
@@ -669,7 +673,6 @@ function Server () {
color = "load";
}
Promise.all(emails.map(e => e())).then(function (objs) {
- console.error(objs);
var isAuthorized = objs.reduce((p, c) => p || (!c.notAuthorized && c.network), false);
var anyNewEmails = objs.reduce((p, c) => p || (c.newIDs.length !== 0), false);
if (!isAuthorized) {
@@ -684,7 +687,7 @@ function Server () {
}
tray.remove();
gButton.tooltiptext = config.defaultTooltip;
-console.error("exit 4");
+console.error(objs, "exit 4");
return;
}
//Removing not logged-in accounts
@@ -701,7 +704,7 @@ console.error("exit 4");
var newCount = objs.reduce((p,c) => p + c.xml.fullcount, 0);
//
if (!anyNewEmails && !forced && count === newCount) {
-console.error("exit 0");
+console.error(objs, "exit 0", forced, anyNewEmails);
return; //Everything is clear
}
count = newCount;
@@ -737,7 +740,7 @@ console.error("exit 0");
p += c.xml.title +
(c.xml.label ? " [" + c.xml.label + "]" : "") +
" (" + c.xml.fullcount + ")" + "\n", ""
- );
+ ).replace(/\n$/, "");
if (!forced && !anyNewEmails) {
if (newCount) {
icon(newCount, "red"); color = "red";
@@ -749,13 +752,13 @@ console.error("exit 0");
tray.remove();
gButton.tooltiptext = tooltip;
}
-console.error("exit 1");
+console.error(objs, "exit 1", forced, anyNewEmails);
}
- else if (forced && !anyNewEmails) {
+ else if (forced && !newCount) {
icon(null, "gray"); color = "gray";
tray.remove();
gButton.tooltiptext = tooltip;
-console.error("exit 3");
+console.error(objs, "exit 3", forced, anyNewEmails);
}
else {
icon(newCount, "new"); color = "new";
@@ -766,7 +769,7 @@ console.error("exit 3");
if (prefs.alert) play();
gButton.tooltiptext = tooltip;
-console.error("exit 2");
+console.error(objs, "exit 2", forced, anyNewEmails);
}
//Updating the toolbar panel if exists
if (contextPanel.isShowing) {
@@ -806,7 +809,17 @@ sp.on("reset", function() {
prefs.currentTab = false;
prefs.doReadOnArchive = true;
prefs.soundVolume = 80;
+ prefs.tray = true;
+ prefs.notificationFormat = "From: [author_email][break]Title: [title][break]Summary: [summary]";
});
+sp.on("tray", function() {
+ if (!prefs.tray) {
+ tray.remove();
+ }
+ else {
+ tm.reset(true);
+ }
+})
/**
* Send archive, mark as read, mark as unread, and trash commands to Gmail server
View
@@ -18,7 +18,7 @@ Cu.import("resource://gre/modules/Promise.jsm");
var config = {
id: {
- msg: 336518, // A random number
+ msg: 665, // A random number
unique: 24342 // A random number
},
time: {
@@ -190,8 +190,7 @@ var proxyWndProc = WNDPROC (function (hWnd, uMsg, wParam, lParam) {
}
return user32.DefWindowProcW(hWnd, uMsg, wParam, lParam);
})
-user32.SetWindowLongW(hWnd, -4 /* GWLP_WNDPROC */, ctypes.cast(proxyWndProc, LONG_PTR));
-
+var oldOffset = user32.SetWindowLongW(hWnd, -4 /* GWLP_WNDPROC */, ctypes.cast(proxyWndProc, LONG_PTR));
var isInstalled = false;
exports.set = function (badge, msg) {
@@ -212,6 +211,13 @@ exports.remove = function () {
shell32.Shell_NotifyIconW(0x00000002 /* NIM_DELETE */, nid.address());
isInstalled = false;
}
-exports.callback = function (c) {
- callback = c;
-}
+exports.callback = {
+ install: function (c) {
+ callback = c;
+ },
+ remove: function () {
+ console.error(0, oldOffset.toSource())
+ user32.SetWindowLongW(hWnd, -4, oldOffset);
+ }
+}
+
View
@@ -10,7 +10,7 @@
"contributors": ["CaTz", "ecaron"],
"url": "",
- "version": "0.3.8b2",
+ "version": "0.4.0b1",
"lib": "lib",
"main": "main",
@@ -72,7 +72,7 @@
},
{
"name": "tray",
- "title": "Display Windows taskbar notification:",
+ "title": "Display Windows taskbar notification (beta):",
"description": "Taskbar notifications are only supported in Windows OS at the moment.",
"type": "bool",
"value": true
View
@@ -12,8 +12,8 @@
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
- <em:minVersion>14.0</em:minVersion>
- <em:maxVersion>28.0</em:maxVersion>
+ <em:minVersion>27.0</em:minVersion>
+ <em:maxVersion>30.0</em:maxVersion>
</Description>
</em:targetApplication>

0 comments on commit e1151fa

Please sign in to comment.