mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-23 06:18:48 -05:00
wrap "loose" variables and functions within a JavaScript object
This commit is contained in:
parent
6c94d75dc2
commit
a7516e379e
@ -137,7 +137,7 @@ $(build_dir)/$(chrome_source_root)/%.js: $(chrome_source_root)/%.js
|
|||||||
cp -f $< $@; \
|
cp -f $< $@; \
|
||||||
else \
|
else \
|
||||||
echo "Stripping debug calls from JS file $<"; \
|
echo "Stripping debug calls from JS file $<"; \
|
||||||
sed '/LOG(/d' $< > $@; \
|
sed '/firetray.LOG(/d' $< > $@; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
||||||
@ -147,7 +147,7 @@ $(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
|||||||
cp -f $< $@; \
|
cp -f $< $@; \
|
||||||
else \
|
else \
|
||||||
echo "Stripping debug calls from module $<"; \
|
echo "Stripping debug calls from module $<"; \
|
||||||
sed '/LOG(/d' $< > $@; \
|
sed '/firetray.LOG(/d' $< > $@; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(build_dir):
|
$(build_dir):
|
||||||
|
@ -74,7 +74,7 @@ var firetrayUIOptions = {
|
|||||||
updateWindowAndIconOptions: function() {
|
updateWindowAndIconOptions: function() {
|
||||||
let hides_on_close = document.getElementById("ui_hides_on_close").checked;
|
let hides_on_close = document.getElementById("ui_hides_on_close").checked;
|
||||||
let hides_on_minimize = document.getElementById("ui_hides_on_minimize").checked;
|
let hides_on_minimize = document.getElementById("ui_hides_on_minimize").checked;
|
||||||
LOG("hides_on_close="+hides_on_close+", hides_on_minimize="+hides_on_minimize);
|
firetray.LOG("hides_on_close="+hides_on_close+", hides_on_minimize="+hides_on_minimize);
|
||||||
document.getElementById('ui_hides_single_window').disabled =
|
document.getElementById('ui_hides_single_window').disabled =
|
||||||
!(hides_on_close || hides_on_minimize);
|
!(hides_on_close || hides_on_minimize);
|
||||||
},
|
},
|
||||||
@ -129,7 +129,7 @@ var firetrayUIOptions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateNotificationSettings: function() {
|
updateNotificationSettings: function() {
|
||||||
LOG("updateNotificationSettings");
|
firetray.LOG("updateNotificationSettings");
|
||||||
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
||||||
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
||||||
firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
|
firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
|
||||||
@ -155,7 +155,7 @@ var firetrayUIOptions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
disableMessageCountMaybe: function(msgCountType) {
|
disableMessageCountMaybe: function(msgCountType) {
|
||||||
LOG("disableMessageCountMaybe: "+msgCountType);
|
firetray.LOG("disableMessageCountMaybe: "+msgCountType);
|
||||||
let msgCountTypeIsNewMessages = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
|
let msgCountTypeIsNewMessages = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
|
||||||
|
|
||||||
let notificationUnreadCount = document.getElementById("ui_mail_notification_unread_count");
|
let notificationUnreadCount = document.getElementById("ui_mail_notification_unread_count");
|
||||||
@ -219,7 +219,7 @@ var firetrayUIOptions = {
|
|||||||
let localizedFolderType = this.strings.getString(folderType);
|
let localizedFolderType = this.strings.getString(folderType);
|
||||||
let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
|
let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
|
||||||
item.setAttribute("observes", "broadcaster-notification-disabled");
|
item.setAttribute("observes", "broadcaster-notification-disabled");
|
||||||
LOG("folder: "+folderType);
|
firetray.LOG("folder: "+folderType);
|
||||||
if (!(FLDRS_UNINTERESTING[folderType] & prefExcludedFoldersFlags))
|
if (!(FLDRS_UNINTERESTING[folderType] & prefExcludedFoldersFlags))
|
||||||
excludedFoldersList.addItemToSelection(item); // doesn't trigger onselect
|
excludedFoldersList.addItemToSelection(item); // doesn't trigger onselect
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ var firetrayUIOptions = {
|
|||||||
updateExcludedFoldersPref: function() {
|
updateExcludedFoldersPref: function() {
|
||||||
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
||||||
|
|
||||||
LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
|
firetray.LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
|
||||||
let excludedFoldersFlags = null;
|
let excludedFoldersFlags = null;
|
||||||
for (let i = 0, len=excludedFoldersList.itemCount; i<len; ++i) {
|
for (let i = 0, len=excludedFoldersList.itemCount; i<len; ++i) {
|
||||||
let folder = excludedFoldersList.getItemAtIndex(i);
|
let folder = excludedFoldersList.getItemAtIndex(i);
|
||||||
@ -237,7 +237,7 @@ var firetrayUIOptions = {
|
|||||||
else
|
else
|
||||||
excludedFoldersFlags |= FLDRS_UNINTERESTING[folder.value];
|
excludedFoldersFlags |= FLDRS_UNINTERESTING[folder.value];
|
||||||
}
|
}
|
||||||
LOG("excluded folders flags: "+excludedFoldersFlags);
|
firetray.LOG("excluded folders flags: "+excludedFoldersFlags);
|
||||||
|
|
||||||
firetray.Utils.prefService.setIntPref("excluded_folders_flags",
|
firetray.Utils.prefService.setIntPref("excluded_folders_flags",
|
||||||
excludedFoldersFlags);
|
excludedFoldersFlags);
|
||||||
@ -252,9 +252,9 @@ var firetrayUIOptions = {
|
|||||||
let that = this;
|
let that = this;
|
||||||
try {
|
try {
|
||||||
let cells = row.childNodes; // .getElementsByTagName('treecell');
|
let cells = row.childNodes; // .getElementsByTagName('treecell');
|
||||||
LOG("CELLS: "+cells);
|
firetray.LOG("CELLS: "+cells);
|
||||||
for (let i=0, len=cells.length; i<len; ++i) {
|
for (let i=0, len=cells.length; i<len; ++i) {
|
||||||
LOG("i: "+i+", cell:"+cells[i]);
|
firetray.LOG("i: "+i+", cell:"+cells[i]);
|
||||||
if (disable === true) {
|
if (disable === true) {
|
||||||
cells[i].setAttribute('properties', "disabled");
|
cells[i].setAttribute('properties', "disabled");
|
||||||
if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
|
if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
|
||||||
@ -272,7 +272,7 @@ var firetrayUIOptions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
ERROR(e);
|
firetray.ERROR(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -280,8 +280,8 @@ var firetrayUIOptions = {
|
|||||||
* needed for triggering actual preference change and saving
|
* needed for triggering actual preference change and saving
|
||||||
*/
|
*/
|
||||||
_userChangeValueTree: function(event) {
|
_userChangeValueTree: function(event) {
|
||||||
if (event.attrName == "label") LOG("label changed!");
|
if (event.attrName == "label") firetray.LOG("label changed!");
|
||||||
if (event.attrName == "value") LOG("value changed!");
|
if (event.attrName == "value") firetray.LOG("value changed!");
|
||||||
document.getElementById("pane1")
|
document.getElementById("pane1")
|
||||||
.userChangedValue(document.getElementById("ui_tree_mail_accounts"));
|
.userChangedValue(document.getElementById("ui_tree_mail_accounts"));
|
||||||
|
|
||||||
@ -296,14 +296,14 @@ var firetrayUIOptions = {
|
|||||||
let subRows = firetray.Utils.XPath(
|
let subRows = firetray.Utils.XPath(
|
||||||
checkboxCell,
|
checkboxCell,
|
||||||
'ancestor::xul:treeitem[1]/descendant::xul:treechildren//xul:treerow');
|
'ancestor::xul:treeitem[1]/descendant::xul:treechildren//xul:treerow');
|
||||||
LOG("subRows="+subRows);
|
firetray.LOG("subRows="+subRows);
|
||||||
for (let i=0, len=subRows.length; i<len; ++i) {
|
for (let i=0, len=subRows.length; i<len; ++i) {
|
||||||
firetrayUIOptions._disableTreeRow(
|
firetrayUIOptions._disableTreeRow(
|
||||||
subRows[i], (checkboxCell.getAttribute("value") === "false"));
|
subRows[i], (checkboxCell.getAttribute("value") === "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (event.attrName == "label") { // text
|
} else if (event.attrName == "label") { // text
|
||||||
WARN("NOT IMPLEMENTED YET: move row to new rank"); // TODO
|
firetray.WARN("NOT IMPLEMENTED YET: move row to new rank"); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
this._userChangeValueTree(event);
|
this._userChangeValueTree(event);
|
||||||
@ -322,7 +322,7 @@ var firetrayUIOptions = {
|
|||||||
let serverTypes = mailAccounts["serverTypes"];
|
let serverTypes = mailAccounts["serverTypes"];
|
||||||
let accountsExcluded = mailAccounts["excludedAccounts"];
|
let accountsExcluded = mailAccounts["excludedAccounts"];
|
||||||
let accountsByServerType = firetray.Messaging.accountsByServerType();
|
let accountsByServerType = firetray.Messaging.accountsByServerType();
|
||||||
LOG(JSON.stringify(accountsByServerType));
|
firetray.LOG(JSON.stringify(accountsByServerType));
|
||||||
|
|
||||||
// sort serverTypes according to order
|
// sort serverTypes according to order
|
||||||
let serverTypesSorted = Object.keys(serverTypes);
|
let serverTypesSorted = Object.keys(serverTypes);
|
||||||
@ -335,7 +335,7 @@ var firetrayUIOptions = {
|
|||||||
return 1;
|
return 1;
|
||||||
return 0; // no sorting
|
return 0; // no sorting
|
||||||
});
|
});
|
||||||
LOG("serverTypesSorted: "+serverTypesSorted);
|
firetray.LOG("serverTypesSorted: "+serverTypesSorted);
|
||||||
|
|
||||||
let target = document.getElementById("ui_mail_accounts");
|
let target = document.getElementById("ui_mail_accounts");
|
||||||
for (let i=0, len=serverTypesSorted.length; i<len; ++i) {
|
for (let i=0, len=serverTypesSorted.length; i<len; ++i) {
|
||||||
@ -373,7 +373,7 @@ var firetrayUIOptions = {
|
|||||||
// add actual accounts as children
|
// add actual accounts as children
|
||||||
let subChildren = document.createElement('treechildren');
|
let subChildren = document.createElement('treechildren');
|
||||||
let typeAccounts = accountsByServerType[serverTypeName];
|
let typeAccounts = accountsByServerType[serverTypeName];
|
||||||
LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
|
firetray.LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
|
||||||
if (typeof(typeAccounts) == "undefined")
|
if (typeof(typeAccounts) == "undefined")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ var firetrayUIOptions = {
|
|||||||
saveTreeAccountsOrServerTypes: function() {
|
saveTreeAccountsOrServerTypes: function() {
|
||||||
let tree = document.getElementById("ui_tree_mail_accounts");
|
let tree = document.getElementById("ui_tree_mail_accounts");
|
||||||
|
|
||||||
LOG("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
|
firetray.LOG("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
|
||||||
let prefObj = {"serverTypes":{}, "excludedAccounts":[]};
|
let prefObj = {"serverTypes":{}, "excludedAccounts":[]};
|
||||||
for (let i=0, len=tree.view.rowCount; i<len; ++i) {
|
for (let i=0, len=tree.view.rowCount; i<len; ++i) {
|
||||||
let accountOrServerTypeName = tree.view.getCellText(
|
let accountOrServerTypeName = tree.view.getCellText(
|
||||||
@ -444,7 +444,7 @@ var firetrayUIOptions = {
|
|||||||
let accountOrServerTypeOrder = parseInt(
|
let accountOrServerTypeOrder = parseInt(
|
||||||
tree.view.getCellText(
|
tree.view.getCellText(
|
||||||
i, tree.columns.getNamedColumn("account_or_server_type_order")));
|
i, tree.columns.getNamedColumn("account_or_server_type_order")));
|
||||||
LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
|
firetray.LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
|
||||||
|
|
||||||
if (tree.view.getLevel(i) === TREELEVEL_SERVER_TYPES) {
|
if (tree.view.getLevel(i) === TREELEVEL_SERVER_TYPES) {
|
||||||
prefObj["serverTypes"][accountOrServerTypeName] =
|
prefObj["serverTypes"][accountOrServerTypeName] =
|
||||||
@ -464,14 +464,14 @@ var firetrayUIOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let prefStr = JSON.stringify(prefObj);
|
let prefStr = JSON.stringify(prefObj);
|
||||||
LOG("prefStr"+prefStr);
|
firetray.LOG("prefStr"+prefStr);
|
||||||
|
|
||||||
/* return the new prefString to be stored by pref system */
|
/* return the new prefString to be stored by pref system */
|
||||||
return prefStr;
|
return prefStr;
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyPressTreeAccountsOrServerTypes: function(event) {
|
onKeyPressTreeAccountsOrServerTypes: function(event) {
|
||||||
LOG("TREE KEYPRESS: "+event.originalTarget);
|
firetray.LOG("TREE KEYPRESS: "+event.originalTarget);
|
||||||
let tree = document.getElementById("ui_tree_mail_accounts");
|
let tree = document.getElementById("ui_tree_mail_accounts");
|
||||||
let col = tree.editingColumn; // col.index
|
let col = tree.editingColumn; // col.index
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
|||||||
onLoad: function(win) {
|
onLoad: function(win) {
|
||||||
this.strings = document.getElementById("firetray-strings"); // chrome-specific
|
this.strings = document.getElementById("firetray-strings"); // chrome-specific
|
||||||
|
|
||||||
LOG("Handler initialized: "+firetray.Handler.initialized);
|
firetray.LOG("Handler initialized: "+firetray.Handler.initialized);
|
||||||
let init = firetray.Handler.initialized || firetray.Handler.init();
|
let init = firetray.Handler.initialized || firetray.Handler.init();
|
||||||
|
|
||||||
LOG("ONLOAD"); firetray.Handler.dumpWindows();
|
firetray.LOG("ONLOAD"); firetray.Handler.dumpWindows();
|
||||||
let winId = firetray.Handler.registerWindow(win);
|
let winId = firetray.Handler.registerWindow(win);
|
||||||
|
|
||||||
if (firetray.Handler.inMailApp && firetray.Messaging.initialized)
|
if (firetray.Handler.inMailApp && firetray.Messaging.initialized)
|
||||||
@ -25,11 +25,11 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
|||||||
win.addEventListener('close', firetrayChrome.onClose, true);
|
win.addEventListener('close', firetrayChrome.onClose, true);
|
||||||
|
|
||||||
if (firetray.Handler.windows[winId].startHidden) {
|
if (firetray.Handler.windows[winId].startHidden) {
|
||||||
LOG('start_hidden');
|
firetray.LOG('start_hidden');
|
||||||
firetray.Handler.hideSingleWindow(winId);
|
firetray.Handler.hideSingleWindow(winId);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG('Firetray LOADED: ' + init);
|
firetray.LOG('Firetray LOADED: ' + init);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -39,19 +39,19 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
|||||||
/* NOTE: don't do firetray.Handler.initialized=false here, otherwise after
|
/* NOTE: don't do firetray.Handler.initialized=false here, otherwise after
|
||||||
a window close, a new window will create a new handler (and hence, a new
|
a window close, a new window will create a new handler (and hence, a new
|
||||||
tray icon) */
|
tray icon) */
|
||||||
LOG('Firetray UNLOADED !');
|
firetray.LOG('Firetray UNLOADED !');
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: prevent preceding warning about closing multiple tabs (browser.tabs.warnOnClose)
|
// TODO: prevent preceding warning about closing multiple tabs (browser.tabs.warnOnClose)
|
||||||
onClose: function(event) {
|
onClose: function(event) {
|
||||||
LOG('Firetray CLOSE');
|
firetray.LOG('Firetray CLOSE');
|
||||||
let win = event.originalTarget;
|
let win = event.originalTarget;
|
||||||
if (!win instanceof ChromeWindow)
|
if (!win instanceof ChromeWindow)
|
||||||
throw new TypeError('originalTarget not a ChromeWindow');
|
throw new TypeError('originalTarget not a ChromeWindow');
|
||||||
|
|
||||||
let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
|
let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
|
||||||
let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
|
let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
|
||||||
LOG('hides_on_close: '+hides_on_close+', hides_single_window='+hides_single_window);
|
firetray.LOG('hides_on_close: '+hides_on_close+', hides_single_window='+hides_single_window);
|
||||||
if (hides_on_close) {
|
if (hides_on_close) {
|
||||||
if (hides_single_window) {
|
if (hides_single_window) {
|
||||||
let winId = firetray.Handler.getWindowIdFromChromeWindow(win);
|
let winId = firetray.Handler.getWindowIdFromChromeWindow(win);
|
||||||
|
@ -37,7 +37,7 @@ firetray.Handler = {
|
|||||||
initialized: false,
|
initialized: false,
|
||||||
appNameOriginal: null,
|
appNameOriginal: null,
|
||||||
appStarted: false,
|
appStarted: false,
|
||||||
appId: null,
|
appName: null,
|
||||||
runtimeOS: null,
|
runtimeOS: null,
|
||||||
inMailApp: false,
|
inMailApp: false,
|
||||||
inBrowserApp: false,
|
inBrowserApp: false,
|
||||||
@ -60,29 +60,29 @@ firetray.Handler = {
|
|||||||
this.runtimeOS = Services.appinfo.OS; // "WINNT", "Linux", "Darwin"
|
this.runtimeOS = Services.appinfo.OS; // "WINNT", "Linux", "Darwin"
|
||||||
// version checked during install, so we shouldn't need to care
|
// version checked during install, so we shouldn't need to care
|
||||||
let xulVer = Services.appinfo.platformVersion; // Services.vc.compare(xulVer,"2.0a")>=0
|
let xulVer = Services.appinfo.platformVersion; // Services.vc.compare(xulVer,"2.0a")>=0
|
||||||
LOG("OS=" + this.runtimeOS + ", ABI=" + this.runtimeABI + ", XULrunner=" + xulVer);
|
firetray.LOG("OS=" + this.runtimeOS + ", ABI=" + this.runtimeABI + ", XULrunner=" + xulVer);
|
||||||
switch (this.runtimeOS) {
|
switch (this.runtimeOS) {
|
||||||
case "Linux":
|
case "Linux":
|
||||||
Cu.import("resource://firetray/linux/FiretrayStatusIcon.jsm");
|
Cu.import("resource://firetray/linux/FiretrayStatusIcon.jsm");
|
||||||
LOG('FiretrayStatusIcon imported');
|
firetray.LOG('FiretrayStatusIcon imported');
|
||||||
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
|
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
|
||||||
LOG('FiretrayWindow imported');
|
firetray.LOG('FiretrayWindow imported');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("FIRETRAY: only Linux platform supported at this time. Firetray not loaded");
|
firetray.ERROR("FIRETRAY: only Linux platform supported at this time. Firetray not loaded");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.appId = Services.appinfo.ID;
|
this.appName = Services.appinfo.name;
|
||||||
if (this.appId === THUNDERBIRD_ID || this.appId === SEAMONKEY_ID)
|
if (this.appName === "Thunderbird" || this.appName === "SeaMonkey")
|
||||||
this.inMailApp = true;
|
this.inMailApp = true;
|
||||||
if (this.appId === FIREFOX_ID || this.appId === SEAMONKEY_ID)
|
if (this.appName === "Firefox" || this.appName === "SeaMonkey")
|
||||||
this.inBrowserApp = true;
|
this.inBrowserApp = true;
|
||||||
LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
firetray.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
||||||
|
|
||||||
firetray.StatusIcon.init();
|
firetray.StatusIcon.init();
|
||||||
firetray.Handler.showHideIcon();
|
firetray.Handler.showHideIcon();
|
||||||
LOG('StatusIcon initialized');
|
firetray.LOG('StatusIcon initialized');
|
||||||
|
|
||||||
if (this.inMailApp) {
|
if (this.inMailApp) {
|
||||||
try {
|
try {
|
||||||
@ -92,12 +92,12 @@ firetray.Handler = {
|
|||||||
firetray.Messaging.updateMsgCount();
|
firetray.Messaging.updateMsgCount();
|
||||||
}
|
}
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Services.obs.addObserver(this, this.getAppStartupTopic(this.appId), false);
|
Services.obs.addObserver(this, this.getAppStartupTopic(this.appName), false);
|
||||||
Services.obs.addObserver(this, "xpcom-will-shutdown", false);
|
Services.obs.addObserver(this, "xpcom-will-shutdown", false);
|
||||||
|
|
||||||
let welcome = function(ver) {
|
let welcome = function(ver) {
|
||||||
@ -124,7 +124,7 @@ firetray.Handler = {
|
|||||||
|
|
||||||
firetray.Utils.tryCloseLibs([gobject, glib, gtk]);
|
firetray.Utils.tryCloseLibs([gobject, glib, gtk]);
|
||||||
|
|
||||||
Services.obs.removeObserver(this, this.getAppStartupTopic(this.appId), false);
|
Services.obs.removeObserver(this, this.getAppStartupTopic(this.appName), false);
|
||||||
Services.obs.removeObserver(this, "xpcom-will-shutdown", false);
|
Services.obs.removeObserver(this, "xpcom-will-shutdown", false);
|
||||||
|
|
||||||
this.appStarted = false;
|
this.appStarted = false;
|
||||||
@ -137,16 +137,16 @@ firetray.Handler = {
|
|||||||
case "sessionstore-windows-restored":
|
case "sessionstore-windows-restored":
|
||||||
case "mail-startup-done":
|
case "mail-startup-done":
|
||||||
case "final-ui-startup":
|
case "final-ui-startup":
|
||||||
LOG("RECEIVED: "+topic+", launching timer");
|
firetray.LOG("RECEIVED: "+topic+", launching timer");
|
||||||
// sessionstore-windows-restored does not come after the realization of
|
// sessionstore-windows-restored does not come after the realization of
|
||||||
// all windows... so we wait a little
|
// all windows... so we wait a little
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(function() {
|
||||||
firetray.Handler.appStarted = true;
|
firetray.Handler.appStarted = true;
|
||||||
LOG("*** appStarted ***");
|
firetray.LOG("*** appStarted ***");
|
||||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||||
break;
|
break;
|
||||||
case "xpcom-will-shutdown":
|
case "xpcom-will-shutdown":
|
||||||
LOG("xpcom-will-shutdown");
|
firetray.LOG("xpcom-will-shutdown");
|
||||||
this.shutdown();
|
this.shutdown();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -155,10 +155,10 @@ firetray.Handler = {
|
|||||||
|
|
||||||
getAppStartupTopic: function(id) {
|
getAppStartupTopic: function(id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case FIREFOX_ID:
|
case "Firefox":
|
||||||
case SEAMONKEY_ID:
|
case "SeaMonkey":
|
||||||
return 'sessionstore-windows-restored';
|
return 'sessionstore-windows-restored';
|
||||||
case THUNDERBIRD_ID:
|
case "Thunderbird":
|
||||||
return 'mail-startup-done';
|
return 'mail-startup-done';
|
||||||
default:
|
default:
|
||||||
return 'final-ui-startup';
|
return 'final-ui-startup';
|
||||||
@ -180,14 +180,14 @@ firetray.Handler = {
|
|||||||
showHideAllWindows: function() {},
|
showHideAllWindows: function() {},
|
||||||
|
|
||||||
showAllWindows: function() {
|
showAllWindows: function() {
|
||||||
LOG("showAllWindows");
|
firetray.LOG("showAllWindows");
|
||||||
for (let winId in firetray.Handler.windows) {
|
for (let winId in firetray.Handler.windows) {
|
||||||
if (!firetray.Handler.windows[winId].visibility)
|
if (!firetray.Handler.windows[winId].visibility)
|
||||||
firetray.Handler.showSingleWindow(winId);
|
firetray.Handler.showSingleWindow(winId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideAllWindows: function() {
|
hideAllWindows: function() {
|
||||||
LOG("hideAllWindows");
|
firetray.LOG("hideAllWindows");
|
||||||
for (let winId in firetray.Handler.windows) {
|
for (let winId in firetray.Handler.windows) {
|
||||||
if (firetray.Handler.windows[winId].visibility)
|
if (firetray.Handler.windows[winId].visibility)
|
||||||
firetray.Handler.hideSingleWindow(winId);
|
firetray.Handler.hideSingleWindow(winId);
|
||||||
@ -213,7 +213,7 @@ firetray.Handler = {
|
|||||||
.QueryInterface(Ci.nsIInterfaceRequestor);
|
.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// ignore no-interface exception
|
// ignore no-interface exception
|
||||||
ERROR(ex);
|
firetray.ERROR(ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ firetray.Handler = {
|
|||||||
else if (iface == "nsIXULWindow")
|
else if (iface == "nsIXULWindow")
|
||||||
winOut = winInterface.getInterface(Ci.nsIXULWindow);
|
winOut = winInterface.getInterface(Ci.nsIXULWindow);
|
||||||
else {
|
else {
|
||||||
ERROR("unknown iface '" + iface + "'");
|
firetray.ERROR("unknown iface '" + iface + "'");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,9 +230,9 @@ firetray.Handler = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getBrowserProperties: function() {
|
_getBrowserProperties: function() {
|
||||||
if (firetray.Handler.appId === FIREFOX_ID)
|
if (firetray.Handler.appName === "Firefox")
|
||||||
return "chrome://branding/locale/browserconfig.properties";
|
return "chrome://branding/locale/browserconfig.properties";
|
||||||
else if (firetray.Handler.appId === SEAMONKEY_ID)
|
else if (firetray.Handler.appName === "SeaMonkey")
|
||||||
return "chrome://navigator-region/locale/region.properties";
|
return "chrome://navigator-region/locale/region.properties";
|
||||||
else return null;
|
else return null;
|
||||||
},
|
},
|
||||||
@ -258,7 +258,7 @@ firetray.Handler = {
|
|||||||
openBrowserWindow: function() {
|
openBrowserWindow: function() {
|
||||||
try {
|
try {
|
||||||
var home = firetray.Handler._getHomePage();
|
var home = firetray.Handler._getHomePage();
|
||||||
LOG("home="+home);
|
firetray.LOG("home="+home);
|
||||||
|
|
||||||
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
|
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
|
||||||
// 827 if (t->data.requestDepth) {
|
// 827 if (t->data.requestDepth) {
|
||||||
@ -266,7 +266,7 @@ firetray.Handler = {
|
|||||||
for(var key in firetray.Handler.windows) break;
|
for(var key in firetray.Handler.windows) break;
|
||||||
firetray.Handler.windows[key].chromeWin.open(home);
|
firetray.Handler.windows[key].chromeWin.open(home);
|
||||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||||
} catch (x) { ERROR(x); }
|
} catch (x) { firetray.ERROR(x); }
|
||||||
},
|
},
|
||||||
|
|
||||||
openMailMessage: function() {
|
openMailMessage: function() {
|
||||||
@ -275,17 +275,16 @@ firetray.Handler = {
|
|||||||
var msgComposeService = Cc["@mozilla.org/messengercompose;1"]
|
var msgComposeService = Cc["@mozilla.org/messengercompose;1"]
|
||||||
.getService(Ci.nsIMsgComposeService);
|
.getService(Ci.nsIMsgComposeService);
|
||||||
msgComposeService.OpenComposeWindowWithURI(null, aURI);
|
msgComposeService.OpenComposeWindowWithURI(null, aURI);
|
||||||
} catch (x) { ERROR(x); }
|
} catch (x) { firetray.ERROR(x); }
|
||||||
},
|
},
|
||||||
|
|
||||||
openTab: function(url) {
|
openTab: function(url) {
|
||||||
let appId = Services.appinfo.ID;
|
if (this.appName === "Thunderbird")
|
||||||
if (appId === THUNDERBIRD_ID)
|
|
||||||
this.openMailTab(url);
|
this.openMailTab(url);
|
||||||
else if (appId === FIREFOX_ID || appId === SEAMONKEY_ID)
|
else if (appName === "Firefox" || appName === "SeaMonkey")
|
||||||
this.openBrowserTab(url);
|
this.openBrowserTab(url);
|
||||||
else
|
else
|
||||||
ERROR("unsupported application");
|
firetray.ERROR("unsupported application");
|
||||||
},
|
},
|
||||||
|
|
||||||
openMailTab: function(url) {
|
openMailTab: function(url) {
|
||||||
@ -297,7 +296,7 @@ firetray.Handler = {
|
|||||||
|
|
||||||
if (tabmail) {
|
if (tabmail) {
|
||||||
firetray.Utils.timer(function() {
|
firetray.Utils.timer(function() {
|
||||||
LOG("openMailTab");
|
firetray.LOG("openMailTab");
|
||||||
tabmail.openTab("contentTab", {contentPage: url});
|
tabmail.openTab("contentTab", {contentPage: url});
|
||||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||||
}
|
}
|
||||||
@ -305,7 +304,7 @@ firetray.Handler = {
|
|||||||
|
|
||||||
openBrowserTab: function(url) {
|
openBrowserTab: function(url) {
|
||||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
WARN("WIN="+win);
|
firetray.LOG("WIN="+win);
|
||||||
if (win) {
|
if (win) {
|
||||||
var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||||
@ -315,7 +314,7 @@ firetray.Handler = {
|
|||||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||||
|
|
||||||
mainWindow.setTimeout(function(win){
|
mainWindow.setTimeout(function(win){
|
||||||
LOG("openBrowser");
|
firetray.LOG("openBrowser");
|
||||||
mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(url);
|
mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(url);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@ -355,7 +354,7 @@ firetray.Handler = {
|
|||||||
.getService(Ci.nsIAppStartup);
|
.getService(Ci.nsIAppStartup);
|
||||||
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
||||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||||
} catch (x) { ERROR(x); }
|
} catch (x) { firetray.ERROR(x); }
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // firetray.Handler
|
}; // firetray.Handler
|
||||||
@ -364,7 +363,7 @@ firetray.Handler = {
|
|||||||
firetray.PrefListener = new PrefListener(
|
firetray.PrefListener = new PrefListener(
|
||||||
"extensions.firetray.",
|
"extensions.firetray.",
|
||||||
function(branch, name) {
|
function(branch, name) {
|
||||||
LOG('Pref changed: '+name);
|
firetray.LOG('Pref changed: '+name);
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'hides_single_window':
|
case 'hides_single_window':
|
||||||
firetray.Handler.showHidePopupMenuItems();
|
firetray.Handler.showHidePopupMenuItems();
|
||||||
|
@ -26,10 +26,10 @@ firetray.Messaging = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
if (this.initialized) {
|
if (this.initialized) {
|
||||||
WARN("Messaging already initialized");
|
firetray.WARN("Messaging already initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG("Enabling Messaging");
|
firetray.LOG("Enabling Messaging");
|
||||||
|
|
||||||
let that = this;
|
let that = this;
|
||||||
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
|
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
|
||||||
@ -41,7 +41,7 @@ firetray.Messaging = {
|
|||||||
shutdown: function() {
|
shutdown: function() {
|
||||||
if (!this.initialized)
|
if (!this.initialized)
|
||||||
return;
|
return;
|
||||||
LOG("Disabling Messaging");
|
firetray.LOG("Disabling Messaging");
|
||||||
|
|
||||||
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
||||||
firetray.Handler.setIconImageDefault();
|
firetray.Handler.setIconImageDefault();
|
||||||
@ -61,25 +61,25 @@ firetray.Messaging = {
|
|||||||
Ci.nsIFolderListener.intPropertyChanged,
|
Ci.nsIFolderListener.intPropertyChanged,
|
||||||
|
|
||||||
OnItemPropertyChanged: function(item, property, oldValue, newValue) { // NumNewBiffMessages
|
OnItemPropertyChanged: function(item, property, oldValue, newValue) { // NumNewBiffMessages
|
||||||
LOG("OnItemPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
firetray.LOG("OnItemPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) { // TotalUnreadMessages, BiffState (per server)
|
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) { // TotalUnreadMessages, BiffState (per server)
|
||||||
LOG("OnItemIntPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
firetray.LOG("OnItemIntPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
||||||
this.updateMsgCount(item, property, oldValue, newValue);
|
this.updateMsgCount(item, property, oldValue, newValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) { // NewMessages (per folder)
|
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) { // NewMessages (per folder)
|
||||||
LOG("OnItemBoolPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
firetray.LOG("OnItemBoolPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
|
||||||
this.updateMsgCount(item, property, oldValue, newValue);
|
this.updateMsgCount(item, property, oldValue, newValue);
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {
|
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {
|
||||||
LOG("OnItemPropertyFlagChanged"+property+" for "+item+" was "+oldFlag+" became "+newFlag);
|
firetray.LOG("OnItemPropertyFlagChanged"+property+" for "+item+" was "+oldFlag+" became "+newFlag);
|
||||||
},
|
},
|
||||||
|
|
||||||
OnItemEvent: function(item, event) {
|
OnItemEvent: function(item, event) {
|
||||||
LOG("OnItemEvent"+event+" for folder "+item.prettyName);
|
firetray.LOG("OnItemEvent"+event+" for folder "+item.prettyName);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMsgCount: function(item, property, oldValue, newValue) {
|
updateMsgCount: function(item, property, oldValue, newValue) {
|
||||||
@ -105,12 +105,12 @@ firetray.Messaging = {
|
|||||||
* computes and display new msg count
|
* computes and display new msg count
|
||||||
*/
|
*/
|
||||||
updateMsgCount: function() {
|
updateMsgCount: function() {
|
||||||
LOG("updateMsgCount");
|
firetray.LOG("updateMsgCount");
|
||||||
if (!this.initialized)
|
if (!this.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
|
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
|
||||||
LOG("msgCountType="+msgCountType);
|
firetray.LOG("msgCountType="+msgCountType);
|
||||||
let folderCountFunction, localizedTooltip;
|
let folderCountFunction, localizedTooltip;
|
||||||
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
||||||
folderCountFunction = this.unreadMsgCountIterate;
|
folderCountFunction = this.unreadMsgCountIterate;
|
||||||
@ -122,7 +122,7 @@ firetray.Messaging = {
|
|||||||
folderCountFunction = this.newMsgCountIterate;
|
folderCountFunction = this.newMsgCountIterate;
|
||||||
localizedTooltip = firetray.Utils.strings.GetStringFromName("tooltip.new_messages");
|
localizedTooltip = firetray.Utils.strings.GetStringFromName("tooltip.new_messages");
|
||||||
} else
|
} else
|
||||||
ERROR('unknown message count type');
|
firetray.ERROR('unknown message count type');
|
||||||
|
|
||||||
let newMsgCount = this.countMessages(folderCountFunction);
|
let newMsgCount = this.countMessages(folderCountFunction);
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ firetray.Messaging = {
|
|||||||
firetray.Handler.setIconImage(prefCustomIconPath);
|
firetray.Handler.setIconImage(prefCustomIconPath);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("Unknown notification mode: "+prefMailNotification);
|
firetray.ERROR("Unknown notification mode: "+prefMailNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
||||||
@ -154,7 +154,7 @@ firetray.Messaging = {
|
|||||||
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
|
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
|
||||||
folderCountFunction = this.newMsgCountIterate;
|
folderCountFunction = this.newMsgCountIterate;
|
||||||
} else
|
} else
|
||||||
ERROR('unknown message count type');
|
firetray.ERROR('unknown message count type');
|
||||||
|
|
||||||
firetray.Handler.setIconTooltip(localizedTooltip);
|
firetray.Handler.setIconTooltip(localizedTooltip);
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ firetray.Messaging = {
|
|||||||
*/
|
*/
|
||||||
countMessages: function(folderCountFunction) {
|
countMessages: function(folderCountFunction) {
|
||||||
let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
|
let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
|
||||||
LOG("mail accounts from pref: "+JSON.stringify(mailAccounts));
|
firetray.LOG("mail accounts from pref: "+JSON.stringify(mailAccounts));
|
||||||
let serverTypes = mailAccounts["serverTypes"];
|
let serverTypes = mailAccounts["serverTypes"];
|
||||||
let excludedAccounts = mailAccounts["excludedAccounts"];
|
let excludedAccounts = mailAccounts["excludedAccounts"];
|
||||||
let excludedFoldersFlags = firetray.Utils.prefService
|
let excludedFoldersFlags = firetray.Utils.prefService
|
||||||
@ -179,7 +179,7 @@ firetray.Messaging = {
|
|||||||
try {
|
try {
|
||||||
let accounts = new this.Accounts();
|
let accounts = new this.Accounts();
|
||||||
for (let accountServer in accounts) {
|
for (let accountServer in accounts) {
|
||||||
LOG("is servertype excluded: "+serverTypes[accountServer.type].excluded+", account exclusion index: "+excludedAccounts.indexOf(accountServer.key));
|
firetray.LOG("is servertype excluded: "+serverTypes[accountServer.type].excluded+", account exclusion index: "+excludedAccounts.indexOf(accountServer.key));
|
||||||
if ( (serverTypes[accountServer.type].excluded)
|
if ( (serverTypes[accountServer.type].excluded)
|
||||||
|| (excludedAccounts.indexOf(accountServer.key) >= 0) )
|
|| (excludedAccounts.indexOf(accountServer.key) >= 0) )
|
||||||
continue;
|
continue;
|
||||||
@ -196,9 +196,9 @@ firetray.Messaging = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
LOG("Total New="+newMsgCount);
|
firetray.LOG("Total New="+newMsgCount);
|
||||||
return newMsgCount;
|
return newMsgCount;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -206,13 +206,13 @@ firetray.Messaging = {
|
|||||||
let folderCountFunctionName = 'getNumUnread';
|
let folderCountFunctionName = 'getNumUnread';
|
||||||
let folderUnreadMsgCount = folder[folderCountFunctionName](
|
let folderUnreadMsgCount = folder[folderCountFunctionName](
|
||||||
firetray.Utils.prefService.getBoolPref("folder_count_recursive"));
|
firetray.Utils.prefService.getBoolPref("folder_count_recursive"));
|
||||||
LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
|
firetray.LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
|
||||||
return accumulator + folderUnreadMsgCount;
|
return accumulator + folderUnreadMsgCount;
|
||||||
},
|
},
|
||||||
|
|
||||||
newMsgCountIterate: function(folder, accumulator) {
|
newMsgCountIterate: function(folder, accumulator) {
|
||||||
if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
|
if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
|
||||||
LOG("hasSubFolders");
|
firetray.LOG("hasSubFolders");
|
||||||
let subFolders = folder.subFolders;
|
let subFolders = folder.subFolders;
|
||||||
while(subFolders.hasMoreElements()) {
|
while(subFolders.hasMoreElements()) {
|
||||||
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
||||||
@ -225,7 +225,7 @@ firetray.Messaging = {
|
|||||||
|
|
||||||
addHasNewMessages: function(folder, accumulator) {
|
addHasNewMessages: function(folder, accumulator) {
|
||||||
let folderNewMsgCount = folder.hasNewMessages;
|
let folderNewMsgCount = folder.hasNewMessages;
|
||||||
LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
|
firetray.LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
|
||||||
return accumulator || folderNewMsgCount;
|
return accumulator || folderNewMsgCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ firetray.Messaging.Accounts = function(sortByTypeAndName) {
|
|||||||
};
|
};
|
||||||
firetray.Messaging.Accounts.prototype.__iterator__ = function() {
|
firetray.Messaging.Accounts.prototype.__iterator__ = function() {
|
||||||
let accounts = MailServices.accounts.accounts;
|
let accounts = MailServices.accounts.accounts;
|
||||||
LOG("sortByTypeAndName="+this.sortByTypeAndName);
|
firetray.LOG("sortByTypeAndName="+this.sortByTypeAndName);
|
||||||
|
|
||||||
/* NOTE: sort() not provided by nsIMsgAccountManager.accounts
|
/* NOTE: sort() not provided by nsIMsgAccountManager.accounts
|
||||||
(nsISupportsArray, nsICollection). Should be OK to re-build a JS-Array for
|
(nsISupportsArray, nsICollection). Should be OK to re-build a JS-Array for
|
||||||
@ -279,7 +279,7 @@ firetray.Messaging.Accounts.prototype.__iterator__ = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i=0, len=accountServers.length; i<len; ++i) {
|
for (let i=0, len=accountServers.length; i<len; ++i) {
|
||||||
LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
|
firetray.LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
|
||||||
yield accountServers[i];
|
yield accountServers[i];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ var VersionChange = {
|
|||||||
watch: function() {
|
watch: function() {
|
||||||
AddonManager.addAddonListener(this.uninstallListener);
|
AddonManager.addAddonListener(this.uninstallListener);
|
||||||
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
|
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
|
||||||
LOG("version change watching enabled");
|
firetray.LOG("version change watching enabled");
|
||||||
},
|
},
|
||||||
|
|
||||||
// we need to remove pref 'installedVersion' on uninstalling to be able to
|
// we need to remove pref 'installedVersion' on uninstalling to be able to
|
||||||
@ -42,13 +42,13 @@ var VersionChange = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onVersionChange: function(addon) {
|
onVersionChange: function(addon) {
|
||||||
LOG("VERSION: "+addon.version);
|
firetray.LOG("VERSION: "+addon.version);
|
||||||
|
|
||||||
this.curVersion = addon.version;
|
this.curVersion = addon.version;
|
||||||
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
|
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
|
||||||
|
|
||||||
if (firstrun) {
|
if (firstrun) {
|
||||||
WARN("FIRST RUN");
|
firetray.WARN("FIRST RUN");
|
||||||
this.initPrefs();
|
this.initPrefs();
|
||||||
this.installHook(this.curVersion);
|
this.installHook(this.curVersion);
|
||||||
|
|
||||||
@ -58,12 +58,12 @@ var VersionChange = {
|
|||||||
var versionDelta = this.versionComparator.compare(this.curVersion, installedVersion);
|
var versionDelta = this.versionComparator.compare(this.curVersion, installedVersion);
|
||||||
if (versionDelta > 0) {
|
if (versionDelta > 0) {
|
||||||
firetray.Utils.prefService.setCharPref("installedVersion", this.curVersion);
|
firetray.Utils.prefService.setCharPref("installedVersion", this.curVersion);
|
||||||
WARN("UPGRADE");
|
firetray.WARN("UPGRADE");
|
||||||
this.upgradeHook(this.curVersion);
|
this.upgradeHook(this.curVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
WARN("REINSTALL");
|
firetray.WARN("REINSTALL");
|
||||||
this.initPrefs();
|
this.initPrefs();
|
||||||
this.reinstallHook(this.curVersion);
|
this.reinstallHook(this.curVersion);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
/* for now, logging facilities (imported from logging.jsm) are automatically
|
/* for now, logging facilities (imported from logging.jsm) are automatically
|
||||||
provided by this module */
|
provided by this module */
|
||||||
var EXPORTED_SYMBOLS =
|
var EXPORTED_SYMBOLS =
|
||||||
[ "firetray", "LOG", "WARN", "ERROR", "FIREFOX_ID", "THUNDERBIRD_ID",
|
[ "firetray", "LOG", "WARN", "ERROR", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
|
||||||
"SEAMONKEY_ID", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE", "getType",
|
|
||||||
"isArray", "isEmpty", "strEquals",
|
|
||||||
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
||||||
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
||||||
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
|
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
|
||||||
@ -19,13 +17,6 @@ const Cu = Components.utils;
|
|||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://firetray/logging.jsm");
|
Cu.import("resource://firetray/logging.jsm");
|
||||||
|
|
||||||
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
|
|
||||||
const THUNDERBIRD_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
|
|
||||||
const SONGBIRD_ID = "songbird@songbirdnest.com";
|
|
||||||
const SUNBIRD_ID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
|
|
||||||
const SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
|
|
||||||
const CHATZILLA_ID = "{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}";
|
|
||||||
|
|
||||||
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
|
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
|
||||||
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
|
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
|
||||||
|
|
||||||
@ -43,6 +34,7 @@ const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
|
|||||||
* firetray namespace.
|
* firetray namespace.
|
||||||
*/
|
*/
|
||||||
if ("undefined" == typeof(firetray)) {
|
if ("undefined" == typeof(firetray)) {
|
||||||
|
firetray.firetray.ERROR("### HI ###");
|
||||||
var firetray = {};
|
var firetray = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,26 +48,26 @@ firetray.Utils = {
|
|||||||
var objPref = JSON.parse(
|
var objPref = JSON.parse(
|
||||||
firetray.Utils.prefService.getCharPref(prefStr));
|
firetray.Utils.prefService.getCharPref(prefStr));
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
return objPref;
|
return objPref;
|
||||||
},
|
},
|
||||||
setObjPref: function(prefStr, obj) {
|
setObjPref: function(prefStr, obj) {
|
||||||
LOG(obj);
|
firetray.LOG(obj);
|
||||||
try {
|
try {
|
||||||
firetray.Utils.prefService.setCharPref(prefStr, JSON.stringify(obj));
|
firetray.Utils.prefService.setCharPref(prefStr, JSON.stringify(obj));
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getArrayPref: function(prefStr) {
|
getArrayPref: function(prefStr) {
|
||||||
let arrayPref = this.getObjPref(prefStr);
|
let arrayPref = this.getObjPref(prefStr);
|
||||||
if (!isArray(arrayPref)) throw new TypeError();
|
if (!firetray.js.isArray(arrayPref)) throw new TypeError();
|
||||||
return arrayPref;
|
return arrayPref;
|
||||||
},
|
},
|
||||||
setArrayPref: function(prefStr, aArray) {
|
setArrayPref: function(prefStr, aArray) {
|
||||||
if (!isArray(aArray)) throw new TypeError();
|
if (!firetray.js.isArray(aArray)) throw new TypeError();
|
||||||
this.setObjPref(prefStr, aArray);
|
this.setObjPref(prefStr, aArray);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -95,7 +87,7 @@ firetray.Utils = {
|
|||||||
let registeryValue = Cc['@mozilla.org/chrome/chrome-registry;1']
|
let registeryValue = Cc['@mozilla.org/chrome/chrome-registry;1']
|
||||||
.getService(Ci.nsIChromeRegistry)
|
.getService(Ci.nsIChromeRegistry)
|
||||||
.convertChromeURL(uri).spec;
|
.convertChromeURL(uri).spec;
|
||||||
LOG(registeryValue);
|
firetray.LOG(registeryValue);
|
||||||
|
|
||||||
if (/^file:/.test(registeryValue))
|
if (/^file:/.test(registeryValue))
|
||||||
registeryValue = this._urlToPath(registeryValue);
|
registeryValue = this._urlToPath(registeryValue);
|
||||||
@ -123,7 +115,7 @@ firetray.Utils = {
|
|||||||
str += "obj["+i+"]: Unavailable\n";
|
str += "obj["+i+"]: Unavailable\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG(str);
|
firetray.LOG(str);
|
||||||
},
|
},
|
||||||
|
|
||||||
_nsResolver: function(prefix) {
|
_nsResolver: function(prefix) {
|
||||||
@ -143,9 +135,9 @@ firetray.Utils = {
|
|||||||
var result = doc.evaluate(xpath, ref, that._nsResolver,
|
var result = doc.evaluate(xpath, ref, that._nsResolver,
|
||||||
XPathResult.ANY_TYPE, null);
|
XPathResult.ANY_TYPE, null);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
LOG("XPathResult="+result.resultType);
|
firetray.LOG("XPathResult="+result.resultType);
|
||||||
|
|
||||||
switch (result.resultType) {
|
switch (result.resultType) {
|
||||||
case XPathResult.NUMBER_TYPE:
|
case XPathResult.NUMBER_TYPE:
|
||||||
@ -159,7 +151,7 @@ firetray.Utils = {
|
|||||||
var list = [];
|
var list = [];
|
||||||
try {
|
try {
|
||||||
for (let node = result.iterateNext(); node; node = result.iterateNext()) {
|
for (let node = result.iterateNext(); node; node = result.iterateNext()) {
|
||||||
LOG("node="+node.nodeName);
|
firetray.LOG("node="+node.nodeName);
|
||||||
switch (node.nodeType) {
|
switch (node.nodeType) {
|
||||||
case node.ATTRIBUTE_NODE:
|
case node.ATTRIBUTE_NODE:
|
||||||
list.push(node.value);
|
list.push(node.value);
|
||||||
@ -172,7 +164,7 @@ firetray.Utils = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@ -190,21 +182,38 @@ firetray.Utils = {
|
|||||||
if (lib.available())
|
if (lib.available())
|
||||||
lib.close();
|
lib.close();
|
||||||
});
|
});
|
||||||
} catch(x) { ERROR(x); }
|
} catch(x) { firetray.ERROR(x); }
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////// more fundamental helpers //////////////////////////
|
////////////////////////// more fundamental helpers //////////////////////////
|
||||||
|
|
||||||
|
firetray.js = {
|
||||||
// http://stackoverflow.com/questions/767486/how-do-you-check-if-a-variable-is-an-array-in-javascript
|
// http://stackoverflow.com/questions/767486/how-do-you-check-if-a-variable-is-an-array-in-javascript
|
||||||
function isArray(o) {
|
isArray: function(o) {
|
||||||
return getType(o) === '[object Array]';
|
return this.getType(o) === '[object Array]';
|
||||||
}
|
},
|
||||||
function getType(thing){
|
getType: function(thing) {
|
||||||
if(thing === null) return "[object Null]"; // special case
|
if(thing === null) return "[object Null]"; // special case
|
||||||
return Object.prototype.toString.call(thing);
|
return Object.prototype.toString.call(thing);
|
||||||
|
},
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json
|
||||||
|
isEmpty: function(obj) {
|
||||||
|
for(var prop in obj) {
|
||||||
|
if(obj.hasOwnProperty(prop))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// values of different ctypes objects can never be compared. See:
|
||||||
|
// https://developer.mozilla.org/en/js-ctypes/Using_js-ctypes/Working_with_data#Quirks_in_equality
|
||||||
|
strEquals: function(obj1, obj2) {
|
||||||
|
return obj1.toString() === obj2.toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/18912/how-to-find-keys-of-a-hash
|
// http://stackoverflow.com/questions/18912/how-to-find-keys-of-a-hash
|
||||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys
|
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys
|
||||||
@ -215,26 +224,3 @@ if(!Object.keys) Object.keys = function(o){
|
|||||||
for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
|
for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object-from-json
|
|
||||||
function isEmpty(obj) {
|
|
||||||
for(var prop in obj) {
|
|
||||||
if(obj.hasOwnProperty(prop))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// values of different ctypes objects can never be compared. See:
|
|
||||||
// https://developer.mozilla.org/en/js-ctypes/Using_js-ctypes/Working_with_data#Quirks_in_equality
|
|
||||||
function strEquals(obj1, obj2) {
|
|
||||||
return obj1.toString() === obj2.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
|
|
||||||
function DeleteError(message) {
|
|
||||||
this.name = "DeleteError";
|
|
||||||
this.message = message || "Could not delete object memeber";
|
|
||||||
}
|
|
||||||
DeleteError.prototype = new Error();
|
|
||||||
DeleteError.prototype.constructor = DeleteError;
|
|
||||||
|
@ -80,7 +80,7 @@ var EXPORTED_SYMBOLS = [ "ctypes_library" ];
|
|||||||
*/
|
*/
|
||||||
function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||||
try {
|
try {
|
||||||
LOG("Trying to load library: " + aName);
|
firetray.LOG("Trying to load library: " + aName);
|
||||||
|
|
||||||
if (typeof(aName) != "string") {
|
if (typeof(aName) != "string") {
|
||||||
throw Error("Invalid library name");
|
throw Error("Invalid library name");
|
||||||
@ -110,19 +110,19 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
|||||||
var library;
|
var library;
|
||||||
for each (let abi in aABIs) {
|
for each (let abi in aABIs) {
|
||||||
let soname = "lib" + aName + ".so." + abi.toString();
|
let soname = "lib" + aName + ".so." + abi.toString();
|
||||||
LOG("Trying " + soname);
|
firetray.LOG("Trying " + soname);
|
||||||
try {
|
try {
|
||||||
library = ctypes.open(soname);
|
library = ctypes.open(soname);
|
||||||
this.ABI = abi;
|
this.ABI = abi;
|
||||||
LOG("Successfully loaded " + soname);
|
firetray.LOG("Successfully loaded " + soname);
|
||||||
break;
|
break;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
ERROR(soname+" unfound.");
|
firetray.ERROR(soname+" unfound.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function() {
|
||||||
LOG("Closing library " + aName);
|
firetray.LOG("Closing library " + aName);
|
||||||
library.close();
|
library.close();
|
||||||
this.ABI = -1;
|
this.ABI = -1;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Unloading JS module " + aGlobal.__URI__);
|
firetray.LOG("Unloading JS module " + aGlobal.__URI__);
|
||||||
Cu.unload(aGlobal.__URI__);
|
Cu.unload(aGlobal.__URI__);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!library) {
|
if (!library) {
|
||||||
LOG("Failed to load library: " + aName);
|
firetray.LOG("Failed to load library: " + aName);
|
||||||
this.ABI = -1;
|
this.ABI = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
|||||||
return library.declare.apply(library, args);
|
return library.declare.apply(library, args);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
Cu.reportError(ex);
|
Cu.reportError(ex);
|
||||||
ERROR("Missing symbol " + arguments[0] + " in library " + aName);
|
firetray.ERROR("Missing symbol " + arguments[0] + " in library " + aName);
|
||||||
self.ABI = -1;
|
self.ABI = -1;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
|||||||
aGlobal[aGlobal.EXPORTED_SYMBOLS[0]] = this;
|
aGlobal[aGlobal.EXPORTED_SYMBOLS[0]] = this;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Cu.reportError(e);
|
Cu.reportError(e);
|
||||||
ERROR(aName+" definition error: "+e);
|
firetray.ERROR(aName+" definition error: "+e);
|
||||||
this.ABI = -1;
|
this.ABI = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [ "ctypesMap", "FIRETRAY_WINDOW_COUNT_MAX" ];
|
var EXPORTED_SYMBOLS = [ "ctypesMap", "FIRETRAY_WINDOW_COUNT_MAX", "DeleteError" ];
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
@ -32,11 +32,11 @@ ctypesMap.prototype.get = function(key) {
|
|||||||
|
|
||||||
ctypesMap.prototype.insert = function(key, item) {
|
ctypesMap.prototype.insert = function(key, item) {
|
||||||
if (this.map.hasOwnProperty(key)) {
|
if (this.map.hasOwnProperty(key)) {
|
||||||
LOG("REPLACE");
|
firetray.LOG("REPLACE");
|
||||||
this.array[this.map[key]] = item;
|
this.array[this.map[key]] = item;
|
||||||
|
|
||||||
} else if (this.freedCells.length) {
|
} else if (this.freedCells.length) {
|
||||||
LOG("USE FREE CELL");
|
firetray.LOG("USE FREE CELL");
|
||||||
let idx = this.freedCells.shift();
|
let idx = this.freedCells.shift();
|
||||||
this.array[idx] = item;
|
this.array[idx] = item;
|
||||||
this.map[key] = idx;
|
this.map[key] = idx;
|
||||||
@ -57,7 +57,7 @@ ctypesMap.prototype.insert = function(key, item) {
|
|||||||
ctypesMap.prototype.remove = function(key) {
|
ctypesMap.prototype.remove = function(key) {
|
||||||
if (!this.map.hasOwnProperty(key))
|
if (!this.map.hasOwnProperty(key))
|
||||||
throw new RangeError('Unknown key: '+key);
|
throw new RangeError('Unknown key: '+key);
|
||||||
LOG("FREE CELL");
|
firetray.LOG("FREE CELL");
|
||||||
|
|
||||||
let idx = this.map[key];
|
let idx = this.map[key];
|
||||||
if (!delete this.map[key])
|
if (!delete this.map[key])
|
||||||
@ -66,3 +66,11 @@ ctypesMap.prototype.remove = function(key) {
|
|||||||
this.count -= 1;
|
this.count -= 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
|
||||||
|
function DeleteError(message) {
|
||||||
|
this.name = "DeleteError";
|
||||||
|
this.message = message || "Could not delete object memeber";
|
||||||
|
}
|
||||||
|
DeleteError.prototype = new Error();
|
||||||
|
DeleteError.prototype.constructor = DeleteError;
|
||||||
|
@ -14,7 +14,7 @@ Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
|
|
||||||
if ("undefined" == typeof(firetray.StatusIcon))
|
if ("undefined" == typeof(firetray.StatusIcon))
|
||||||
ERROR("This module MUST be imported from/after StatusIcon !");
|
firetray.ERROR("This module MUST be imported from/after StatusIcon !");
|
||||||
|
|
||||||
|
|
||||||
firetray.PopupMenu = {
|
firetray.PopupMenu = {
|
||||||
@ -99,8 +99,8 @@ firetray.PopupMenu = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
popup: function(icon, button, activateTime, menu) {
|
popup: function(icon, button, activateTime, menu) {
|
||||||
LOG("menu-popup");
|
firetray.LOG("menu-popup");
|
||||||
LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
|
firetray.LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var gtkMenuPtr = ctypes.cast(menu, gtk.GtkMenu.ptr);
|
var gtkMenuPtr = ctypes.cast(menu, gtk.GtkMenu.ptr);
|
||||||
@ -108,7 +108,7 @@ firetray.PopupMenu = {
|
|||||||
gtk.gtk_menu_popup(
|
gtk.gtk_menu_popup(
|
||||||
gtkMenuPtr, null, null, gtk.gtk_status_icon_position_menu,
|
gtkMenuPtr, null, null, gtk.gtk_status_icon_position_menu,
|
||||||
iconGpointer, button, activateTime);
|
iconGpointer, button, activateTime);
|
||||||
} catch (x) { ERROR(x); }
|
} catch (x) { firetray.ERROR(x); }
|
||||||
},
|
},
|
||||||
|
|
||||||
// we'll be creating menuItems for windows (and not showing them) even if
|
// we'll be creating menuItems for windows (and not showing them) even if
|
||||||
@ -124,7 +124,7 @@ firetray.PopupMenu = {
|
|||||||
firetray.PopupMenu.callbacks.menuItemWindowActivate[xid], null);
|
firetray.PopupMenu.callbacks.menuItemWindowActivate[xid], null);
|
||||||
this.setWindowItemLabel(menuItemWindow, xid); // default to xid
|
this.setWindowItemLabel(menuItemWindow, xid); // default to xid
|
||||||
|
|
||||||
LOG("add gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
firetray.LOG("add gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||||
},
|
},
|
||||||
|
|
||||||
addItem: function() {
|
addItem: function() {
|
||||||
@ -138,7 +138,7 @@ firetray.PopupMenu = {
|
|||||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||||
firetray.Handler.gtkPopupMenuWindowItems.remove(xid);
|
firetray.Handler.gtkPopupMenuWindowItems.remove(xid);
|
||||||
this.removeItem(menuItemWindow);
|
this.removeItem(menuItemWindow);
|
||||||
LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
firetray.LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||||
},
|
},
|
||||||
removeItem: function(item) {
|
removeItem: function(item) {
|
||||||
gtk.gtk_widget_destroy(ctypes.cast(item, gtk.GtkWidget.ptr));
|
gtk.gtk_widget_destroy(ctypes.cast(item, gtk.GtkWidget.ptr));
|
||||||
@ -154,7 +154,7 @@ firetray.PopupMenu = {
|
|||||||
if (!this.windowItemsHandled())
|
if (!this.windowItemsHandled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG("showSingleWindowItem");
|
firetray.LOG("showSingleWindowItem");
|
||||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||||
this.showItem(menuItemWindow);
|
this.showItem(menuItemWindow);
|
||||||
this.setWindowItemLabel(menuItemWindow, firetray.Window.getWindowTitle(xid));
|
this.setWindowItemLabel(menuItemWindow, firetray.Window.getWindowTitle(xid));
|
||||||
@ -166,7 +166,7 @@ firetray.PopupMenu = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setWindowItemLabel: function(menuItem, label) {
|
setWindowItemLabel: function(menuItem, label) {
|
||||||
LOG("about to set title: "+label);
|
firetray.LOG("about to set title: "+label);
|
||||||
if (label)
|
if (label)
|
||||||
gtk.gtk_menu_item_set_label(ctypes.cast(menuItem, gtk.GtkMenuItem.ptr), label);
|
gtk.gtk_menu_item_set_label(ctypes.cast(menuItem, gtk.GtkMenuItem.ptr), label);
|
||||||
},
|
},
|
||||||
@ -191,7 +191,7 @@ firetray.PopupMenu = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
hideSingleWindowItem: function(xid) {
|
hideSingleWindowItem: function(xid) {
|
||||||
LOG("hideSingleWindowItem");
|
firetray.LOG("hideSingleWindowItem");
|
||||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||||
this.hideItem(menuItemWindow);
|
this.hideItem(menuItemWindow);
|
||||||
},
|
},
|
||||||
@ -201,11 +201,11 @@ firetray.PopupMenu = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
showWindowSeparator: function() {
|
showWindowSeparator: function() {
|
||||||
LOG("showing menuSeparatorWindows");
|
firetray.LOG("showing menuSeparatorWindows");
|
||||||
gtk.gtk_widget_show(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
gtk.gtk_widget_show(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
||||||
},
|
},
|
||||||
hideWindowSeparator: function() {
|
hideWindowSeparator: function() {
|
||||||
LOG("hiding menuSeparatorWindows");
|
firetray.LOG("hiding menuSeparatorWindows");
|
||||||
gtk.gtk_widget_hide(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
gtk.gtk_widget_hide(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ Cu.import("resource://firetray/ctypes/linux/pangocairo.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
|
|
||||||
if ("undefined" == typeof(firetray.Handler))
|
if ("undefined" == typeof(firetray.Handler))
|
||||||
ERROR("This module MUST be imported from/after FiretrayHandler !");
|
firetray.ERROR("This module MUST be imported from/after FiretrayHandler !");
|
||||||
|
|
||||||
|
|
||||||
firetray.StatusIcon = {
|
firetray.StatusIcon = {
|
||||||
@ -32,7 +32,7 @@ firetray.StatusIcon = {
|
|||||||
// init tray icon, some variables
|
// init tray icon, some variables
|
||||||
this.trayIcon = gtk.gtk_status_icon_new();
|
this.trayIcon = gtk.gtk_status_icon_new();
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,12 +66,12 @@ firetray.StatusIcon = {
|
|||||||
gobject.g_signal_connect(this.trayIcon, "scroll-event",
|
gobject.g_signal_connect(this.trayIcon, "scroll-event",
|
||||||
firetray.StatusIcon.callbacks.onScroll, null);
|
firetray.StatusIcon.callbacks.onScroll, null);
|
||||||
|
|
||||||
LOG("showHideAllWindows: "+firetray.Handler.hasOwnProperty("showHideAllWindows"));
|
firetray.LOG("showHideAllWindows: "+firetray.Handler.hasOwnProperty("showHideAllWindows"));
|
||||||
this.callbacks.iconActivate = gtk.GCallbackStatusIconActivate_t(
|
this.callbacks.iconActivate = gtk.GCallbackStatusIconActivate_t(
|
||||||
firetray.Handler.showHideAllWindows);
|
firetray.Handler.showHideAllWindows);
|
||||||
let handlerId = gobject.g_signal_connect(firetray.StatusIcon.trayIcon,
|
let handlerId = gobject.g_signal_connect(firetray.StatusIcon.trayIcon,
|
||||||
"activate", firetray.StatusIcon.callbacks.iconActivate, null);
|
"activate", firetray.StatusIcon.callbacks.iconActivate, null);
|
||||||
LOG("g_connect activate="+handlerId);
|
firetray.LOG("g_connect activate="+handlerId);
|
||||||
},
|
},
|
||||||
|
|
||||||
onScroll: function(icon, event, data) {
|
onScroll: function(icon, event, data) {
|
||||||
@ -85,21 +85,21 @@ firetray.StatusIcon = {
|
|||||||
let direction = gdkEventScroll.contents.direction;
|
let direction = gdkEventScroll.contents.direction;
|
||||||
switch(direction) {
|
switch(direction) {
|
||||||
case gdk.GDK_SCROLL_UP:
|
case gdk.GDK_SCROLL_UP:
|
||||||
LOG("SCROLL UP");
|
firetray.LOG("SCROLL UP");
|
||||||
if (scroll_mode === "down_hides")
|
if (scroll_mode === "down_hides")
|
||||||
firetray.Handler.showAllWindows();
|
firetray.Handler.showAllWindows();
|
||||||
else if (scroll_mode === "up_hides")
|
else if (scroll_mode === "up_hides")
|
||||||
firetray.Handler.hideAllWindows();
|
firetray.Handler.hideAllWindows();
|
||||||
break;
|
break;
|
||||||
case gdk.GDK_SCROLL_DOWN:
|
case gdk.GDK_SCROLL_DOWN:
|
||||||
LOG("SCROLL DOWN");
|
firetray.LOG("SCROLL DOWN");
|
||||||
if (scroll_mode === "down_hides")
|
if (scroll_mode === "down_hides")
|
||||||
firetray.Handler.hideAllWindows();
|
firetray.Handler.hideAllWindows();
|
||||||
else if (scroll_mode === "up_hides")
|
else if (scroll_mode === "up_hides")
|
||||||
firetray.Handler.showAllWindows();
|
firetray.Handler.showAllWindows();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("SCROLL UNKNOWN");
|
firetray.ERROR("SCROLL UNKNOWN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +109,13 @@ firetray.StatusIcon = {
|
|||||||
firetray.Handler.setIconImage = function(filename) {
|
firetray.Handler.setIconImage = function(filename) {
|
||||||
if (!firetray.StatusIcon.trayIcon)
|
if (!firetray.StatusIcon.trayIcon)
|
||||||
return false;
|
return false;
|
||||||
LOG(filename);
|
firetray.LOG(filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
|
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
|
||||||
filename);
|
filename);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -136,7 +136,7 @@ firetray.Handler.setIconTooltip = function(toolTipStr) {
|
|||||||
gtk.gtk_status_icon_set_tooltip_text(firetray.StatusIcon.trayIcon,
|
gtk.gtk_status_icon_set_tooltip_text(firetray.StatusIcon.trayIcon,
|
||||||
toolTipStr);
|
toolTipStr);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -149,7 +149,7 @@ firetray.Handler.setIconTooltipDefault = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.setIconText = function(text, color) { // FIXME: function too long
|
firetray.Handler.setIconText = function(text, color) { // FIXME: function too long
|
||||||
LOG("setIconText, color="+color);
|
firetray.LOG("setIconText, color="+color);
|
||||||
if (typeof(text) != "string")
|
if (typeof(text) != "string")
|
||||||
throw new TypeError();
|
throw new TypeError();
|
||||||
|
|
||||||
@ -164,13 +164,13 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
|
|||||||
let colorMap = gdk.gdk_screen_get_system_colormap(gdk.gdk_screen_get_default());
|
let colorMap = gdk.gdk_screen_get_system_colormap(gdk.gdk_screen_get_default());
|
||||||
let visual = gdk.gdk_colormap_get_visual(colorMap);
|
let visual = gdk.gdk_colormap_get_visual(colorMap);
|
||||||
let visualDepth = visual.contents.depth;
|
let visualDepth = visual.contents.depth;
|
||||||
LOG("colorMap="+colorMap+" visual="+visual+" visualDepth="+visualDepth);
|
firetray.LOG("colorMap="+colorMap+" visual="+visual+" visualDepth="+visualDepth);
|
||||||
let fore = new gdk.GdkColor;
|
let fore = new gdk.GdkColor;
|
||||||
fore.pixel = fore.red = fore.green = fore.blue = 0;
|
fore.pixel = fore.red = fore.green = fore.blue = 0;
|
||||||
let alpha = new gdk.GdkColor;
|
let alpha = new gdk.GdkColor;
|
||||||
alpha.pixel = alpha.red = alpha.green = alpha.blue = 0xFFFF;
|
alpha.pixel = alpha.red = alpha.green = alpha.blue = 0xFFFF;
|
||||||
if (!fore || !alpha)
|
if (!fore || !alpha)
|
||||||
WARN("Undefined GdkColor fore or alpha");
|
firetray.WARN("Undefined GdkColor fore or alpha");
|
||||||
gdk.gdk_color_parse(color, fore.address());
|
gdk.gdk_color_parse(color, fore.address());
|
||||||
if(fore.red == alpha.red && fore.green == alpha.green && fore.blue == alpha.blue) {
|
if(fore.red == alpha.red && fore.green == alpha.green && fore.blue == alpha.blue) {
|
||||||
alpha.red=0; // make sure alpha is different from fore
|
alpha.red=0; // make sure alpha is different from fore
|
||||||
@ -195,15 +195,15 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
|
|||||||
pango.pango_font_description_set_weight(fnt,pango.PANGO_WEIGHT_SEMIBOLD);
|
pango.pango_font_description_set_weight(fnt,pango.PANGO_WEIGHT_SEMIBOLD);
|
||||||
pango.pango_layout_set_spacing(layout,0);
|
pango.pango_layout_set_spacing(layout,0);
|
||||||
pango.pango_layout_set_font_description(layout, fnt);
|
pango.pango_layout_set_font_description(layout, fnt);
|
||||||
LOG("layout="+layout);
|
firetray.LOG("layout="+layout);
|
||||||
LOG("text="+text);
|
firetray.LOG("text="+text);
|
||||||
pango.pango_layout_set_text(layout, text,-1);
|
pango.pango_layout_set_text(layout, text,-1);
|
||||||
let tw = new ctypes.int;
|
let tw = new ctypes.int;
|
||||||
let th = new ctypes.int;
|
let th = new ctypes.int;
|
||||||
let sz;
|
let sz;
|
||||||
let border = 4;
|
let border = 4;
|
||||||
pango.pango_layout_get_pixel_size(layout, tw.address(), th.address());
|
pango.pango_layout_get_pixel_size(layout, tw.address(), th.address());
|
||||||
LOG("tw="+tw.value+" th="+th.value);
|
firetray.LOG("tw="+tw.value+" th="+th.value);
|
||||||
// fit text to the icon by decreasing font size
|
// fit text to the icon by decreasing font size
|
||||||
while ( tw.value > (w - border) || th.value > (h - border) ) {
|
while ( tw.value > (w - border) || th.value > (h - border) ) {
|
||||||
sz = pango.pango_font_description_get_size(fnt);
|
sz = pango.pango_font_description_get_size(fnt);
|
||||||
@ -216,7 +216,7 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
|
|||||||
pango.pango_layout_set_font_description(layout, fnt);
|
pango.pango_layout_set_font_description(layout, fnt);
|
||||||
pango.pango_layout_get_pixel_size(layout, tw.address(), th.address());
|
pango.pango_layout_get_pixel_size(layout, tw.address(), th.address());
|
||||||
}
|
}
|
||||||
LOG("tw="+tw.value+" th="+th.value);
|
firetray.LOG("tw="+tw.value+" th="+th.value);
|
||||||
pango.pango_font_description_free(fnt);
|
pango.pango_font_description_free(fnt);
|
||||||
// center text
|
// center text
|
||||||
let px = (w-tw.value)/2;
|
let px = (w-tw.value)/2;
|
||||||
@ -231,7 +231,7 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
|
|||||||
|
|
||||||
let buf = gdk.gdk_pixbuf_get_from_drawable(null, pmDrawable, null, 0, 0, 0, 0, w, h);
|
let buf = gdk.gdk_pixbuf_get_from_drawable(null, pmDrawable, null, 0, 0, 0, 0, w, h);
|
||||||
gobject.g_object_unref(pm);
|
gobject.g_object_unref(pm);
|
||||||
LOG("alpha="+alpha);
|
firetray.LOG("alpha="+alpha);
|
||||||
let alphaRed = gobject.guint16(alpha.red);
|
let alphaRed = gobject.guint16(alpha.red);
|
||||||
let alphaRed_guchar = ctypes.cast(alphaRed, gobject.guchar);
|
let alphaRed_guchar = ctypes.cast(alphaRed, gobject.guchar);
|
||||||
let alphaGreen = gobject.guint16(alpha.green);
|
let alphaGreen = gobject.guint16(alpha.green);
|
||||||
@ -247,7 +247,7 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
|
|||||||
|
|
||||||
gtk.gtk_status_icon_set_from_pixbuf(firetray.StatusIcon.trayIcon, dest);
|
gtk.gtk_status_icon_set_from_pixbuf(firetray.StatusIcon.trayIcon, dest);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ Cu.import("resource://firetray/ctypes/linux/x11.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
|
|
||||||
if ("undefined" == typeof(firetray.Handler))
|
if ("undefined" == typeof(firetray.Handler))
|
||||||
ERROR("This module MUST be imported from/after FiretrayHandler !");
|
firetray.ERROR("This module MUST be imported from/after FiretrayHandler !");
|
||||||
|
|
||||||
const Services2 = {};
|
const Services2 = {};
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
@ -81,7 +81,7 @@ firetray.Window = {
|
|||||||
|
|
||||||
// Tag the base window
|
// Tag the base window
|
||||||
let oldTitle = baseWindow.title;
|
let oldTitle = baseWindow.title;
|
||||||
LOG("oldTitle="+oldTitle);
|
firetray.LOG("oldTitle="+oldTitle);
|
||||||
baseWindow.title = Services2.uuid.generateUUID().toString();
|
baseWindow.title = Services2.uuid.generateUUID().toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -93,16 +93,16 @@ firetray.Window = {
|
|||||||
ctypes.char.array()(baseWindow.title),
|
ctypes.char.array()(baseWindow.title),
|
||||||
null
|
null
|
||||||
).address();
|
).address();
|
||||||
LOG("userData="+userData);
|
firetray.LOG("userData="+userData);
|
||||||
gobject.g_list_foreach(widgets, findGtkWindowByTitleCb, userData);
|
gobject.g_list_foreach(widgets, findGtkWindowByTitleCb, userData);
|
||||||
gobject.g_list_free(widgets);
|
gobject.g_list_free(widgets);
|
||||||
|
|
||||||
if (userData.contents.outWindow.isNull()) {
|
if (userData.contents.outWindow.isNull()) {
|
||||||
throw new Error("Window not found!");
|
throw new Error("Window not found!");
|
||||||
}
|
}
|
||||||
LOG("found window: "+userData.contents.outWindow);
|
firetray.LOG("found window: "+userData.contents.outWindow);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
} finally {
|
} finally {
|
||||||
// Restore
|
// Restore
|
||||||
baseWindow.title = oldTitle;
|
baseWindow.title = oldTitle;
|
||||||
@ -124,7 +124,7 @@ firetray.Window = {
|
|||||||
let winTitle = gtk.gtk_window_get_title(gtkWin);
|
let winTitle = gtk.gtk_window_get_title(gtkWin);
|
||||||
|
|
||||||
if (!winTitle.isNull()) {
|
if (!winTitle.isNull()) {
|
||||||
LOG(inTitle+" = "+winTitle);
|
firetray.LOG(inTitle+" = "+winTitle);
|
||||||
if (libc.strcmp(inTitle, winTitle) == 0)
|
if (libc.strcmp(inTitle, winTitle) == 0)
|
||||||
data.contents.outWindow = gtkWin;
|
data.contents.outWindow = gtkWin;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ firetray.Window = {
|
|||||||
let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
|
let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
|
||||||
return gtk.gtk_widget_get_window(gtkWid);
|
return gtk.gtk_widget_get_window(gtkWid);
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -149,7 +149,7 @@ firetray.Window = {
|
|||||||
let gdkWin = gtk.gtk_widget_get_window(gtkWid);
|
let gdkWin = gtk.gtk_widget_get_window(gtkWid);
|
||||||
return gdk.gdk_x11_drawable_get_xid(ctypes.cast(gdkWin, gdk.GdkDrawable.ptr));
|
return gdk.gdk_x11_drawable_get_xid(ctypes.cast(gdkWin, gdk.GdkDrawable.ptr));
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -159,7 +159,7 @@ firetray.Window = {
|
|||||||
let gtkWin = firetray.Window.getGtkWindowHandle(win);
|
let gtkWin = firetray.Window.getGtkWindowHandle(win);
|
||||||
let gdkWin = firetray.Window.getGdkWindowFromGtkWindow(gtkWin);
|
let gdkWin = firetray.Window.getGdkWindowFromGtkWindow(gtkWin);
|
||||||
let xid = firetray.Window.getXIDFromGdkWindow(gdkWin);
|
let xid = firetray.Window.getXIDFromGdkWindow(gdkWin);
|
||||||
LOG("XID="+xid);
|
firetray.LOG("XID="+xid);
|
||||||
return [gtkWin, gdkWin, xid];
|
return [gtkWin, gdkWin, xid];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ firetray.Window = {
|
|||||||
for (let xid in firetray.Handler.windows)
|
for (let xid in firetray.Handler.windows)
|
||||||
if (firetray.Handler.windows[xid].chromeWin === win)
|
if (firetray.Handler.windows[xid].chromeWin === win)
|
||||||
return xid;
|
return xid;
|
||||||
ERROR("unknown window while lookup");
|
firetray.ERROR("unknown window while lookup");
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -181,15 +181,15 @@ firetray.Window = {
|
|||||||
firetray.Handler.gdkWindows.remove(xid);
|
firetray.Handler.gdkWindows.remove(xid);
|
||||||
firetray.PopupMenu.removeWindowItem(xid);
|
firetray.PopupMenu.removeWindowItem(xid);
|
||||||
} else {
|
} else {
|
||||||
ERROR("can't unregister unknown window "+xid);
|
firetray.ERROR("can't unregister unknown window "+xid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG("window "+xid+" unregistered");
|
firetray.LOG("window "+xid+" unregistered");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
showSingleStateful: function(xid) {
|
showSingleStateful: function(xid) {
|
||||||
LOG("showSingleStateful xid="+xid);
|
firetray.LOG("showSingleStateful xid="+xid);
|
||||||
|
|
||||||
// try to restore previous state. TODO: z-order respected ?
|
// try to restore previous state. TODO: z-order respected ?
|
||||||
firetray.Window.restorePositionAndSize(xid);
|
firetray.Window.restorePositionAndSize(xid);
|
||||||
@ -206,7 +206,7 @@ firetray.Window = {
|
|||||||
firetray.Handler.showHideIcon();
|
firetray.Handler.showHideIcon();
|
||||||
},
|
},
|
||||||
showSingleStatelessOnce: function(xid) {
|
showSingleStatelessOnce: function(xid) {
|
||||||
LOG("showSingleStateless");
|
firetray.LOG("showSingleStateless");
|
||||||
|
|
||||||
firetray.Window.setVisibility(xid, true);
|
firetray.Window.setVisibility(xid, true);
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ firetray.Window = {
|
|||||||
// gdk_window_show_unraised)
|
// gdk_window_show_unraised)
|
||||||
/* FIXME: hiding windows should also hide child windows */
|
/* FIXME: hiding windows should also hide child windows */
|
||||||
hideSingleStateful: function(xid) {
|
hideSingleStateful: function(xid) {
|
||||||
LOG("hideSingleStateful");
|
firetray.LOG("hideSingleStateful");
|
||||||
|
|
||||||
firetray.Window.savePositionAndSize(xid);
|
firetray.Window.savePositionAndSize(xid);
|
||||||
firetray.Window.saveStates(xid);
|
firetray.Window.saveStates(xid);
|
||||||
@ -237,7 +237,7 @@ firetray.Window = {
|
|||||||
* is not accurate.
|
* is not accurate.
|
||||||
*/
|
*/
|
||||||
hideSingleStatelessOnce: function(xid) {
|
hideSingleStatelessOnce: function(xid) {
|
||||||
LOG("hideSingleStateless");
|
firetray.LOG("hideSingleStateless");
|
||||||
|
|
||||||
firetray.Window.setVisibility(xid, false);
|
firetray.Window.setVisibility(xid, false);
|
||||||
|
|
||||||
@ -254,14 +254,14 @@ firetray.Window = {
|
|||||||
firetray.Handler.windows[xid].savedY = gy.value;
|
firetray.Handler.windows[xid].savedY = gy.value;
|
||||||
firetray.Handler.windows[xid].savedWidth = gwidth.value;
|
firetray.Handler.windows[xid].savedWidth = gwidth.value;
|
||||||
firetray.Handler.windows[xid].savedHeight = gheight.value;
|
firetray.Handler.windows[xid].savedHeight = gheight.value;
|
||||||
LOG("save: gx="+gx.value+", gy="+gy.value+", gwidth="+gwidth.value+", gheight="+gheight.value);
|
firetray.LOG("save: gx="+gx.value+", gy="+gy.value+", gwidth="+gwidth.value+", gheight="+gheight.value);
|
||||||
},
|
},
|
||||||
|
|
||||||
restorePositionAndSize: function(xid) {
|
restorePositionAndSize: function(xid) {
|
||||||
if ("undefined" === typeof(firetray.Handler.windows[xid].savedX))
|
if ("undefined" === typeof(firetray.Handler.windows[xid].savedX))
|
||||||
return; // windows[xid].saved* may not be initialized
|
return; // windows[xid].saved* may not be initialized
|
||||||
|
|
||||||
LOG("restore: x="+firetray.Handler.windows[xid].savedX+", y="+firetray.Handler.windows[xid].savedY+", w="+firetray.Handler.windows[xid].savedWidth+", h="+firetray.Handler.windows[xid].savedHeight);
|
firetray.LOG("restore: x="+firetray.Handler.windows[xid].savedX+", y="+firetray.Handler.windows[xid].savedY+", w="+firetray.Handler.windows[xid].savedWidth+", h="+firetray.Handler.windows[xid].savedHeight);
|
||||||
firetray.Handler.windows[xid].baseWin.setPositionAndSize(
|
firetray.Handler.windows[xid].baseWin.setPositionAndSize(
|
||||||
firetray.Handler.windows[xid].savedX,
|
firetray.Handler.windows[xid].savedX,
|
||||||
firetray.Handler.windows[xid].savedY,
|
firetray.Handler.windows[xid].savedY,
|
||||||
@ -277,12 +277,12 @@ firetray.Window = {
|
|||||||
saveStates: function(xid) {
|
saveStates: function(xid) {
|
||||||
let winStates = firetray.Window.getXWindowStates(x11.Window(xid));
|
let winStates = firetray.Window.getXWindowStates(x11.Window(xid));
|
||||||
firetray.Handler.windows[xid].savedStates = winStates;
|
firetray.Handler.windows[xid].savedStates = winStates;
|
||||||
LOG("save: windowStates="+winStates);
|
firetray.LOG("save: windowStates="+winStates);
|
||||||
},
|
},
|
||||||
|
|
||||||
restoreStates: function(xid) {
|
restoreStates: function(xid) {
|
||||||
let winStates = firetray.Handler.windows[xid].savedStates;
|
let winStates = firetray.Handler.windows[xid].savedStates;
|
||||||
LOG("restored WindowStates: " + winStates);
|
firetray.LOG("restored WindowStates: " + winStates);
|
||||||
if (winStates & FIRETRAY_XWINDOW_MAXIMIZED) {
|
if (winStates & FIRETRAY_XWINDOW_MAXIMIZED) {
|
||||||
firetray.Handler.windows[xid].chromeWin.maximize();
|
firetray.Handler.windows[xid].chromeWin.maximize();
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ firetray.Window = {
|
|||||||
|
|
||||||
let winDesktop = firetray.Window.getXWindowDesktop(x11.Window(xid));
|
let winDesktop = firetray.Window.getXWindowDesktop(x11.Window(xid));
|
||||||
firetray.Handler.windows[xid].savedDesktop = winDesktop;
|
firetray.Handler.windows[xid].savedDesktop = winDesktop;
|
||||||
LOG("save: windowDesktop="+winDesktop);
|
firetray.LOG("save: windowDesktop="+winDesktop);
|
||||||
},
|
},
|
||||||
|
|
||||||
restoreDesktop: function(xid) {
|
restoreDesktop: function(xid) {
|
||||||
@ -315,7 +315,7 @@ firetray.Window = {
|
|||||||
data[0] = desktopDest;
|
data[0] = desktopDest;
|
||||||
this.xSendClientMessgeEvent(xid, x11.current.Atoms._NET_WM_DESKTOP, data, dataSize);
|
this.xSendClientMessgeEvent(xid, x11.current.Atoms._NET_WM_DESKTOP, data, dataSize);
|
||||||
|
|
||||||
LOG("restored to desktop: "+desktopDest);
|
firetray.LOG("restored to desktop: "+desktopDest);
|
||||||
delete firetray.Handler.windows[xid].savedDesktop;
|
delete firetray.Handler.windows[xid].savedDesktop;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ firetray.Window = {
|
|||||||
if (!firetray.Utils.prefService.getBoolPref('show_activates'))
|
if (!firetray.Utils.prefService.getBoolPref('show_activates'))
|
||||||
return;
|
return;
|
||||||
gtk.gtk_window_present(firetray.Handler.gtkWindows.get(xid));
|
gtk.gtk_window_present(firetray.Handler.gtkWindows.get(xid));
|
||||||
LOG("window raised");
|
firetray.LOG("window raised");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -373,27 +373,27 @@ firetray.Window = {
|
|||||||
x11.current.Display, xwin, prop, offset, bufSize, 0, x11.AnyPropertyType,
|
x11.current.Display, xwin, prop, offset, bufSize, 0, x11.AnyPropertyType,
|
||||||
actual_type.address(), actual_format.address(), nitems.address(),
|
actual_type.address(), actual_format.address(), nitems.address(),
|
||||||
bytes_after.address(), prop_value.address());
|
bytes_after.address(), prop_value.address());
|
||||||
LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
|
firetray.LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
|
||||||
|
|
||||||
if (!strEquals(res, x11.Success)) {
|
if (!firetray.js.strEquals(res, x11.Success)) {
|
||||||
ERROR("XGetWindowProperty failed");
|
firetray.ERROR("XGetWindowProperty failed");
|
||||||
return [null, null];
|
return [null, null];
|
||||||
}
|
}
|
||||||
if (strEquals(actual_type.value, x11.None)) {
|
if (firetray.js.strEquals(actual_type.value, x11.None)) {
|
||||||
LOG("property not found");
|
firetray.LOG("property not found");
|
||||||
return [null, null];
|
return [null, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("prop_value="+prop_value+", size="+prop_value.constructor.size);
|
firetray.LOG("prop_value="+prop_value+", size="+prop_value.constructor.size);
|
||||||
/* If the returned format is 32, the property data will be stored as an
|
/* If the returned format is 32, the property data will be stored as an
|
||||||
array of longs (which in a 64-bit application will be 64-bit values
|
array of longs (which in a 64-bit application will be 64-bit values
|
||||||
that are padded in the upper 4 bytes). [man XGetWindowProperty] */
|
that are padded in the upper 4 bytes). [man XGetWindowProperty] */
|
||||||
if (actual_format.value !== 32) {
|
if (actual_format.value !== 32) {
|
||||||
ERROR("unsupported format: "+actual_format.value);
|
firetray.ERROR("unsupported format: "+actual_format.value);
|
||||||
}
|
}
|
||||||
LOG("format OK");
|
firetray.LOG("format OK");
|
||||||
var props = ctypes.cast(prop_value, ctypes.unsigned_long.array(nitems.value).ptr);
|
var props = ctypes.cast(prop_value, ctypes.unsigned_long.array(nitems.value).ptr);
|
||||||
LOG("props="+props+", size="+props.constructor.size);
|
firetray.LOG("props="+props+", size="+props.constructor.size);
|
||||||
|
|
||||||
return [props, nitems];
|
return [props, nitems];
|
||||||
},
|
},
|
||||||
@ -409,18 +409,18 @@ firetray.Window = {
|
|||||||
|
|
||||||
let [propsFound, nitems] =
|
let [propsFound, nitems] =
|
||||||
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_STATE);
|
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_STATE);
|
||||||
LOG("propsFound, nitems="+propsFound+", "+nitems);
|
firetray.LOG("propsFound, nitems="+propsFound+", "+nitems);
|
||||||
if (!propsFound) return 0;
|
if (!propsFound) return 0;
|
||||||
|
|
||||||
let maximizedHorz = maximizedVert = false;
|
let maximizedHorz = maximizedVert = false;
|
||||||
for (let i=0, len=nitems.value; i<len; ++i) {
|
for (let i=0, len=nitems.value; i<len; ++i) {
|
||||||
LOG("i: "+propsFound.contents[i]);
|
firetray.LOG("i: "+propsFound.contents[i]);
|
||||||
let currentProp = propsFound.contents[i];
|
let currentProp = propsFound.contents[i];
|
||||||
if (strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_HIDDEN']))
|
if (firetray.js.strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_HIDDEN']))
|
||||||
winStates |= FIRETRAY_XWINDOW_HIDDEN;
|
winStates |= FIRETRAY_XWINDOW_HIDDEN;
|
||||||
else if (strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_MAXIMIZED_HORZ']))
|
else if (firetray.js.strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_MAXIMIZED_HORZ']))
|
||||||
maximizedHorz = true;
|
maximizedHorz = true;
|
||||||
else if (strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_MAXIMIZED_VERT']))
|
else if (firetray.js.strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_MAXIMIZED_VERT']))
|
||||||
maximizedVert = true;
|
maximizedVert = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,12 +437,12 @@ firetray.Window = {
|
|||||||
|
|
||||||
let [propsFound, nitems] =
|
let [propsFound, nitems] =
|
||||||
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_DESKTOP);
|
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_DESKTOP);
|
||||||
LOG("DESKTOP propsFound, nitems="+propsFound+", "+nitems);
|
firetray.LOG("DESKTOP propsFound, nitems="+propsFound+", "+nitems);
|
||||||
if (!propsFound) return null;
|
if (!propsFound) return null;
|
||||||
|
|
||||||
if (strEquals(nitems.value, 0))
|
if (firetray.js.strEquals(nitems.value, 0))
|
||||||
WARN("desktop number not found");
|
firetray.WARN("desktop number not found");
|
||||||
else if (strEquals(nitems.value, 1))
|
else if (firetray.js.strEquals(nitems.value, 1))
|
||||||
desktop = propsFound.contents[0];
|
desktop = propsFound.contents[0];
|
||||||
else
|
else
|
||||||
throw new RangeError("more than one desktop found");
|
throw new RangeError("more than one desktop found");
|
||||||
@ -454,7 +454,7 @@ firetray.Window = {
|
|||||||
|
|
||||||
getWindowTitle: function(xid) {
|
getWindowTitle: function(xid) {
|
||||||
let title = firetray.Handler.windows[xid].baseWin.title;
|
let title = firetray.Handler.windows[xid].baseWin.title;
|
||||||
LOG("baseWin.title="+title);
|
firetray.LOG("baseWin.title="+title);
|
||||||
let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appNameOriginal);
|
let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appNameOriginal);
|
||||||
if (tailIndex !== -1)
|
if (tailIndex !== -1)
|
||||||
return title.substring(0, tailIndex);
|
return title.substring(0, tailIndex);
|
||||||
@ -475,10 +475,10 @@ firetray.Window = {
|
|||||||
switch (xany.contents.type) {
|
switch (xany.contents.type) {
|
||||||
|
|
||||||
case x11.UnmapNotify:
|
case x11.UnmapNotify:
|
||||||
LOG("UnmapNotify");
|
firetray.LOG("UnmapNotify");
|
||||||
let winStates = firetray.Window.getXWindowStates(xwin);
|
let winStates = firetray.Window.getXWindowStates(xwin);
|
||||||
let isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
|
let isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
|
||||||
LOG("winStates="+winStates+", isHidden="+isHidden);
|
firetray.LOG("winStates="+winStates+", isHidden="+isHidden);
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
|
let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
|
||||||
let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
|
let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
|
||||||
@ -492,11 +492,11 @@ firetray.Window = {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// LOG("xany.type="+xany.contents.type);
|
// firetray.LOG("xany.type="+xany.contents.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch(x) {
|
} catch(x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return gdk.GDK_FILTER_CONTINUE;
|
return gdk.GDK_FILTER_CONTINUE;
|
||||||
@ -509,14 +509,14 @@ firetray.Window = {
|
|||||||
|
|
||||||
/** debug facility */
|
/** debug facility */
|
||||||
firetray.Handler.dumpWindows = function() {
|
firetray.Handler.dumpWindows = function() {
|
||||||
LOG(firetray.Handler.windowsCount);
|
firetray.LOG(firetray.Handler.windowsCount);
|
||||||
for (let winId in firetray.Handler.windows) LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
|
for (let winId in firetray.Handler.windows) firetray.LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
|
||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
|
firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
|
||||||
|
|
||||||
firetray.Handler.registerWindow = function(win) {
|
firetray.Handler.registerWindow = function(win) {
|
||||||
LOG("register window");
|
firetray.LOG("register window");
|
||||||
|
|
||||||
// register
|
// register
|
||||||
let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
|
let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
|
||||||
@ -538,7 +538,7 @@ firetray.Handler.registerWindow = function(win) {
|
|||||||
// windows *are* shown at startup
|
// windows *are* shown at startup
|
||||||
this.windows[xid].visibility = true; // this.windows[xid].baseWin.visibility always true :-(
|
this.windows[xid].visibility = true; // this.windows[xid].baseWin.visibility always true :-(
|
||||||
this.visibleWindowsCount += 1;
|
this.visibleWindowsCount += 1;
|
||||||
LOG("window "+xid+" registered");
|
firetray.LOG("window "+xid+" registered");
|
||||||
// NOTE: shouldn't be necessary to gtk_widget_add_events(gtkWin, gdk.GDK_ALL_EVENTS_MASK);
|
// NOTE: shouldn't be necessary to gtk_widget_add_events(gtkWin, gdk.GDK_ALL_EVENTS_MASK);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -551,7 +551,7 @@ firetray.Handler.registerWindow = function(win) {
|
|||||||
|
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
firetray.Window.unregisterWindowByXID(xid);
|
firetray.Window.unregisterWindowByXID(xid);
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,35 +566,35 @@ firetray.Handler.registerWindow = function(win) {
|
|||||||
this.windows[xid].show = firetray.Window.showSingleStateful;
|
this.windows[xid].show = firetray.Window.showSingleStateful;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("AFTER"); firetray.Handler.dumpWindows();
|
firetray.LOG("AFTER"); firetray.Handler.dumpWindows();
|
||||||
return xid;
|
return xid;
|
||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.unregisterWindow = function(win) {
|
firetray.Handler.unregisterWindow = function(win) {
|
||||||
LOG("unregister window");
|
firetray.LOG("unregister window");
|
||||||
let xid = firetray.Window.getXIDFromChromeWindow(win);
|
let xid = firetray.Window.getXIDFromChromeWindow(win);
|
||||||
return firetray.Window.unregisterWindowByXID(xid);
|
return firetray.Window.unregisterWindowByXID(xid);
|
||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.showSingleWindow = function(xid) {
|
firetray.Handler.showSingleWindow = function(xid) {
|
||||||
LOG("showSingleWindow xid="+xid);
|
firetray.LOG("showSingleWindow xid="+xid);
|
||||||
this.windows[xid].show(xid);
|
this.windows[xid].show(xid);
|
||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.hideSingleWindow = function(xid) {
|
firetray.Handler.hideSingleWindow = function(xid) {
|
||||||
LOG("hideSingleWindow xid="+xid);
|
firetray.LOG("hideSingleWindow xid="+xid);
|
||||||
this.windows[xid].hide(xid);
|
this.windows[xid].hide(xid);
|
||||||
};
|
};
|
||||||
|
|
||||||
firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
||||||
LOG("showHideAllWindows: "+userData);
|
firetray.LOG("showHideAllWindows: "+userData);
|
||||||
// NOTE: showHideAllWindows being a callback, we need to use
|
// NOTE: showHideAllWindows being a callback, we need to use
|
||||||
// 'firetray.Handler' explicitely instead of 'this'
|
// 'firetray.Handler' explicitely instead of 'this'
|
||||||
|
|
||||||
LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
|
firetray.LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
|
||||||
LOG("windowsCount="+firetray.Handler.windowsCount);
|
firetray.LOG("windowsCount="+firetray.Handler.windowsCount);
|
||||||
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
|
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
|
||||||
LOG("visibilityRate="+visibilityRate);
|
firetray.LOG("visibilityRate="+visibilityRate);
|
||||||
if ((0.5 < visibilityRate) && (visibilityRate < 1)
|
if ((0.5 < visibilityRate) && (visibilityRate < 1)
|
||||||
|| visibilityRate === 0) // TODO: should be configurable
|
|| visibilityRate === 0) // TODO: should be configurable
|
||||||
firetray.Handler.showAllWindows();
|
firetray.Handler.showAllWindows();
|
||||||
@ -613,7 +613,7 @@ firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
|||||||
* Xlib without opening one... :-(
|
* Xlib without opening one... :-(
|
||||||
*/
|
*/
|
||||||
x11.init = function() {
|
x11.init = function() {
|
||||||
if (!isEmpty(this.current))
|
if (!firetray.js.isEmpty(this.current))
|
||||||
return true; // init only once
|
return true; // init only once
|
||||||
|
|
||||||
this.current = {};
|
this.current = {};
|
||||||
@ -623,11 +623,11 @@ x11.init = function() {
|
|||||||
this.current.Atoms = {};
|
this.current.Atoms = {};
|
||||||
XATOMS.forEach(function(atomName, index, array) {
|
XATOMS.forEach(function(atomName, index, array) {
|
||||||
this.current.Atoms[atomName] = x11.XInternAtom(this.current.Display, atomName, 0);
|
this.current.Atoms[atomName] = x11.XInternAtom(this.current.Display, atomName, 0);
|
||||||
LOG("x11.current.Atoms."+atomName+"="+this.current.Atoms[atomName]);
|
firetray.LOG("x11.current.Atoms."+atomName+"="+this.current.Atoms[atomName]);
|
||||||
}, this);
|
}, this);
|
||||||
return true;
|
return true;
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
ERROR(x);
|
firetray.ERROR(x);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["LOG", "WARN", "ERROR"];
|
var EXPORTED_SYMBOLS = [ "firetray" ];
|
||||||
|
|
||||||
|
if ("undefined" == typeof(firetray)) {
|
||||||
|
var firetray = {};
|
||||||
|
};
|
||||||
|
|
||||||
// about:config extensions.logging.enabled
|
// about:config extensions.logging.enabled
|
||||||
["LOG", "WARN", "ERROR"].forEach(function(aName) {
|
["LOG", "WARN", "ERROR"].forEach(function(aName) {
|
||||||
@ -9,4 +13,4 @@ var EXPORTED_SYMBOLS = ["LOG", "WARN", "ERROR"];
|
|||||||
LogManager.getLogger("firetray", this);
|
LogManager.getLogger("firetray", this);
|
||||||
return this[aName];
|
return this[aName];
|
||||||
});
|
});
|
||||||
}, this);
|
}, firetray);
|
||||||
|
Loading…
Reference in New Issue
Block a user