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 $< $@; \
|
||||
else \
|
||||
echo "Stripping debug calls from JS file $<"; \
|
||||
sed '/LOG(/d' $< > $@; \
|
||||
sed '/firetray.LOG(/d' $< > $@; \
|
||||
fi
|
||||
|
||||
$(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
||||
@ -147,7 +147,7 @@ $(build_dir)/$(modules_dir)/%: $(modules_dir)/%
|
||||
cp -f $< $@; \
|
||||
else \
|
||||
echo "Stripping debug calls from module $<"; \
|
||||
sed '/LOG(/d' $< > $@; \
|
||||
sed '/firetray.LOG(/d' $< > $@; \
|
||||
fi
|
||||
|
||||
$(build_dir):
|
||||
|
@ -74,7 +74,7 @@ var firetrayUIOptions = {
|
||||
updateWindowAndIconOptions: function() {
|
||||
let hides_on_close = document.getElementById("ui_hides_on_close").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 =
|
||||
!(hides_on_close || hides_on_minimize);
|
||||
},
|
||||
@ -129,7 +129,7 @@ var firetrayUIOptions = {
|
||||
},
|
||||
|
||||
updateNotificationSettings: function() {
|
||||
LOG("updateNotificationSettings");
|
||||
firetray.LOG("updateNotificationSettings");
|
||||
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
||||
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
||||
firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
|
||||
@ -155,7 +155,7 @@ var firetrayUIOptions = {
|
||||
},
|
||||
|
||||
disableMessageCountMaybe: function(msgCountType) {
|
||||
LOG("disableMessageCountMaybe: "+msgCountType);
|
||||
firetray.LOG("disableMessageCountMaybe: "+msgCountType);
|
||||
let msgCountTypeIsNewMessages = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
|
||||
|
||||
let notificationUnreadCount = document.getElementById("ui_mail_notification_unread_count");
|
||||
@ -219,7 +219,7 @@ var firetrayUIOptions = {
|
||||
let localizedFolderType = this.strings.getString(folderType);
|
||||
let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
|
||||
item.setAttribute("observes", "broadcaster-notification-disabled");
|
||||
LOG("folder: "+folderType);
|
||||
firetray.LOG("folder: "+folderType);
|
||||
if (!(FLDRS_UNINTERESTING[folderType] & prefExcludedFoldersFlags))
|
||||
excludedFoldersList.addItemToSelection(item); // doesn't trigger onselect
|
||||
}
|
||||
@ -228,7 +228,7 @@ var firetrayUIOptions = {
|
||||
updateExcludedFoldersPref: function() {
|
||||
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
||||
|
||||
LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
|
||||
firetray.LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
|
||||
let excludedFoldersFlags = null;
|
||||
for (let i = 0, len=excludedFoldersList.itemCount; i<len; ++i) {
|
||||
let folder = excludedFoldersList.getItemAtIndex(i);
|
||||
@ -237,7 +237,7 @@ var firetrayUIOptions = {
|
||||
else
|
||||
excludedFoldersFlags |= FLDRS_UNINTERESTING[folder.value];
|
||||
}
|
||||
LOG("excluded folders flags: "+excludedFoldersFlags);
|
||||
firetray.LOG("excluded folders flags: "+excludedFoldersFlags);
|
||||
|
||||
firetray.Utils.prefService.setIntPref("excluded_folders_flags",
|
||||
excludedFoldersFlags);
|
||||
@ -252,9 +252,9 @@ var firetrayUIOptions = {
|
||||
let that = this;
|
||||
try {
|
||||
let cells = row.childNodes; // .getElementsByTagName('treecell');
|
||||
LOG("CELLS: "+cells);
|
||||
firetray.LOG("CELLS: "+cells);
|
||||
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) {
|
||||
cells[i].setAttribute('properties', "disabled");
|
||||
if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
|
||||
@ -272,7 +272,7 @@ var firetrayUIOptions = {
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
ERROR(e);
|
||||
firetray.ERROR(e);
|
||||
}
|
||||
},
|
||||
|
||||
@ -280,8 +280,8 @@ var firetrayUIOptions = {
|
||||
* needed for triggering actual preference change and saving
|
||||
*/
|
||||
_userChangeValueTree: function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
if (event.attrName == "label") firetray.LOG("label changed!");
|
||||
if (event.attrName == "value") firetray.LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("ui_tree_mail_accounts"));
|
||||
|
||||
@ -296,14 +296,14 @@ var firetrayUIOptions = {
|
||||
let subRows = firetray.Utils.XPath(
|
||||
checkboxCell,
|
||||
'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) {
|
||||
firetrayUIOptions._disableTreeRow(
|
||||
subRows[i], (checkboxCell.getAttribute("value") === "false"));
|
||||
}
|
||||
|
||||
} 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);
|
||||
@ -322,7 +322,7 @@ var firetrayUIOptions = {
|
||||
let serverTypes = mailAccounts["serverTypes"];
|
||||
let accountsExcluded = mailAccounts["excludedAccounts"];
|
||||
let accountsByServerType = firetray.Messaging.accountsByServerType();
|
||||
LOG(JSON.stringify(accountsByServerType));
|
||||
firetray.LOG(JSON.stringify(accountsByServerType));
|
||||
|
||||
// sort serverTypes according to order
|
||||
let serverTypesSorted = Object.keys(serverTypes);
|
||||
@ -335,7 +335,7 @@ var firetrayUIOptions = {
|
||||
return 1;
|
||||
return 0; // no sorting
|
||||
});
|
||||
LOG("serverTypesSorted: "+serverTypesSorted);
|
||||
firetray.LOG("serverTypesSorted: "+serverTypesSorted);
|
||||
|
||||
let target = document.getElementById("ui_mail_accounts");
|
||||
for (let i=0, len=serverTypesSorted.length; i<len; ++i) {
|
||||
@ -373,7 +373,7 @@ var firetrayUIOptions = {
|
||||
// add actual accounts as children
|
||||
let subChildren = document.createElement('treechildren');
|
||||
let typeAccounts = accountsByServerType[serverTypeName];
|
||||
LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
|
||||
firetray.LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
|
||||
if (typeof(typeAccounts) == "undefined")
|
||||
continue;
|
||||
|
||||
@ -432,7 +432,7 @@ var firetrayUIOptions = {
|
||||
saveTreeAccountsOrServerTypes: function() {
|
||||
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":[]};
|
||||
for (let i=0, len=tree.view.rowCount; i<len; ++i) {
|
||||
let accountOrServerTypeName = tree.view.getCellText(
|
||||
@ -444,7 +444,7 @@ var firetrayUIOptions = {
|
||||
let accountOrServerTypeOrder = parseInt(
|
||||
tree.view.getCellText(
|
||||
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) {
|
||||
prefObj["serverTypes"][accountOrServerTypeName] =
|
||||
@ -464,14 +464,14 @@ var firetrayUIOptions = {
|
||||
}
|
||||
|
||||
let prefStr = JSON.stringify(prefObj);
|
||||
LOG("prefStr"+prefStr);
|
||||
firetray.LOG("prefStr"+prefStr);
|
||||
|
||||
/* return the new prefString to be stored by pref system */
|
||||
return prefStr;
|
||||
},
|
||||
|
||||
onKeyPressTreeAccountsOrServerTypes: function(event) {
|
||||
LOG("TREE KEYPRESS: "+event.originalTarget);
|
||||
firetray.LOG("TREE KEYPRESS: "+event.originalTarget);
|
||||
let tree = document.getElementById("ui_tree_mail_accounts");
|
||||
let col = tree.editingColumn; // col.index
|
||||
|
||||
|
@ -13,10 +13,10 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
||||
onLoad: function(win) {
|
||||
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();
|
||||
|
||||
LOG("ONLOAD"); firetray.Handler.dumpWindows();
|
||||
firetray.LOG("ONLOAD"); firetray.Handler.dumpWindows();
|
||||
let winId = firetray.Handler.registerWindow(win);
|
||||
|
||||
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);
|
||||
|
||||
if (firetray.Handler.windows[winId].startHidden) {
|
||||
LOG('start_hidden');
|
||||
firetray.LOG('start_hidden');
|
||||
firetray.Handler.hideSingleWindow(winId);
|
||||
}
|
||||
|
||||
LOG('Firetray LOADED: ' + init);
|
||||
firetray.LOG('Firetray LOADED: ' + init);
|
||||
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
|
||||
a window close, a new window will create a new handler (and hence, a new
|
||||
tray icon) */
|
||||
LOG('Firetray UNLOADED !');
|
||||
firetray.LOG('Firetray UNLOADED !');
|
||||
},
|
||||
|
||||
// TODO: prevent preceding warning about closing multiple tabs (browser.tabs.warnOnClose)
|
||||
onClose: function(event) {
|
||||
LOG('Firetray CLOSE');
|
||||
firetray.LOG('Firetray CLOSE');
|
||||
let win = event.originalTarget;
|
||||
if (!win instanceof ChromeWindow)
|
||||
throw new TypeError('originalTarget not a ChromeWindow');
|
||||
|
||||
let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
|
||||
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_single_window) {
|
||||
let winId = firetray.Handler.getWindowIdFromChromeWindow(win);
|
||||
|
@ -37,7 +37,7 @@ firetray.Handler = {
|
||||
initialized: false,
|
||||
appNameOriginal: null,
|
||||
appStarted: false,
|
||||
appId: null,
|
||||
appName: null,
|
||||
runtimeOS: null,
|
||||
inMailApp: false,
|
||||
inBrowserApp: false,
|
||||
@ -60,29 +60,29 @@ firetray.Handler = {
|
||||
this.runtimeOS = Services.appinfo.OS; // "WINNT", "Linux", "Darwin"
|
||||
// version checked during install, so we shouldn't need to care
|
||||
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) {
|
||||
case "Linux":
|
||||
Cu.import("resource://firetray/linux/FiretrayStatusIcon.jsm");
|
||||
LOG('FiretrayStatusIcon imported');
|
||||
firetray.LOG('FiretrayStatusIcon imported');
|
||||
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
|
||||
LOG('FiretrayWindow imported');
|
||||
firetray.LOG('FiretrayWindow imported');
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
this.appId = Services.appinfo.ID;
|
||||
if (this.appId === THUNDERBIRD_ID || this.appId === SEAMONKEY_ID)
|
||||
this.appName = Services.appinfo.name;
|
||||
if (this.appName === "Thunderbird" || this.appName === "SeaMonkey")
|
||||
this.inMailApp = true;
|
||||
if (this.appId === FIREFOX_ID || this.appId === SEAMONKEY_ID)
|
||||
if (this.appName === "Firefox" || this.appName === "SeaMonkey")
|
||||
this.inBrowserApp = true;
|
||||
LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
||||
firetray.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
|
||||
|
||||
firetray.StatusIcon.init();
|
||||
firetray.Handler.showHideIcon();
|
||||
LOG('StatusIcon initialized');
|
||||
firetray.LOG('StatusIcon initialized');
|
||||
|
||||
if (this.inMailApp) {
|
||||
try {
|
||||
@ -92,12 +92,12 @@ firetray.Handler = {
|
||||
firetray.Messaging.updateMsgCount();
|
||||
}
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
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);
|
||||
|
||||
let welcome = function(ver) {
|
||||
@ -124,7 +124,7 @@ firetray.Handler = {
|
||||
|
||||
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);
|
||||
|
||||
this.appStarted = false;
|
||||
@ -137,16 +137,16 @@ firetray.Handler = {
|
||||
case "sessionstore-windows-restored":
|
||||
case "mail-startup-done":
|
||||
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
|
||||
// all windows... so we wait a little
|
||||
firetray.Utils.timer(function() {
|
||||
firetray.Handler.appStarted = true;
|
||||
LOG("*** appStarted ***");
|
||||
firetray.LOG("*** appStarted ***");
|
||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
break;
|
||||
case "xpcom-will-shutdown":
|
||||
LOG("xpcom-will-shutdown");
|
||||
firetray.LOG("xpcom-will-shutdown");
|
||||
this.shutdown();
|
||||
break;
|
||||
default:
|
||||
@ -155,10 +155,10 @@ firetray.Handler = {
|
||||
|
||||
getAppStartupTopic: function(id) {
|
||||
switch (id) {
|
||||
case FIREFOX_ID:
|
||||
case SEAMONKEY_ID:
|
||||
case "Firefox":
|
||||
case "SeaMonkey":
|
||||
return 'sessionstore-windows-restored';
|
||||
case THUNDERBIRD_ID:
|
||||
case "Thunderbird":
|
||||
return 'mail-startup-done';
|
||||
default:
|
||||
return 'final-ui-startup';
|
||||
@ -180,14 +180,14 @@ firetray.Handler = {
|
||||
showHideAllWindows: function() {},
|
||||
|
||||
showAllWindows: function() {
|
||||
LOG("showAllWindows");
|
||||
firetray.LOG("showAllWindows");
|
||||
for (let winId in firetray.Handler.windows) {
|
||||
if (!firetray.Handler.windows[winId].visibility)
|
||||
firetray.Handler.showSingleWindow(winId);
|
||||
}
|
||||
},
|
||||
hideAllWindows: function() {
|
||||
LOG("hideAllWindows");
|
||||
firetray.LOG("hideAllWindows");
|
||||
for (let winId in firetray.Handler.windows) {
|
||||
if (firetray.Handler.windows[winId].visibility)
|
||||
firetray.Handler.hideSingleWindow(winId);
|
||||
@ -213,7 +213,7 @@ firetray.Handler = {
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
} catch (ex) {
|
||||
// ignore no-interface exception
|
||||
ERROR(ex);
|
||||
firetray.ERROR(ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ firetray.Handler = {
|
||||
else if (iface == "nsIXULWindow")
|
||||
winOut = winInterface.getInterface(Ci.nsIXULWindow);
|
||||
else {
|
||||
ERROR("unknown iface '" + iface + "'");
|
||||
firetray.ERROR("unknown iface '" + iface + "'");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -230,9 +230,9 @@ firetray.Handler = {
|
||||
},
|
||||
|
||||
_getBrowserProperties: function() {
|
||||
if (firetray.Handler.appId === FIREFOX_ID)
|
||||
if (firetray.Handler.appName === "Firefox")
|
||||
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";
|
||||
else return null;
|
||||
},
|
||||
@ -258,7 +258,7 @@ firetray.Handler = {
|
||||
openBrowserWindow: function() {
|
||||
try {
|
||||
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
|
||||
// 827 if (t->data.requestDepth) {
|
||||
@ -266,7 +266,7 @@ firetray.Handler = {
|
||||
for(var key in firetray.Handler.windows) break;
|
||||
firetray.Handler.windows[key].chromeWin.open(home);
|
||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
} catch (x) { ERROR(x); }
|
||||
} catch (x) { firetray.ERROR(x); }
|
||||
},
|
||||
|
||||
openMailMessage: function() {
|
||||
@ -275,17 +275,16 @@ firetray.Handler = {
|
||||
var msgComposeService = Cc["@mozilla.org/messengercompose;1"]
|
||||
.getService(Ci.nsIMsgComposeService);
|
||||
msgComposeService.OpenComposeWindowWithURI(null, aURI);
|
||||
} catch (x) { ERROR(x); }
|
||||
} catch (x) { firetray.ERROR(x); }
|
||||
},
|
||||
|
||||
openTab: function(url) {
|
||||
let appId = Services.appinfo.ID;
|
||||
if (appId === THUNDERBIRD_ID)
|
||||
if (this.appName === "Thunderbird")
|
||||
this.openMailTab(url);
|
||||
else if (appId === FIREFOX_ID || appId === SEAMONKEY_ID)
|
||||
else if (appName === "Firefox" || appName === "SeaMonkey")
|
||||
this.openBrowserTab(url);
|
||||
else
|
||||
ERROR("unsupported application");
|
||||
firetray.ERROR("unsupported application");
|
||||
},
|
||||
|
||||
openMailTab: function(url) {
|
||||
@ -297,7 +296,7 @@ firetray.Handler = {
|
||||
|
||||
if (tabmail) {
|
||||
firetray.Utils.timer(function() {
|
||||
LOG("openMailTab");
|
||||
firetray.LOG("openMailTab");
|
||||
tabmail.openTab("contentTab", {contentPage: url});
|
||||
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
@ -305,7 +304,7 @@ firetray.Handler = {
|
||||
|
||||
openBrowserTab: function(url) {
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
WARN("WIN="+win);
|
||||
firetray.LOG("WIN="+win);
|
||||
if (win) {
|
||||
var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
@ -315,7 +314,7 @@ firetray.Handler = {
|
||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||
|
||||
mainWindow.setTimeout(function(win){
|
||||
LOG("openBrowser");
|
||||
firetray.LOG("openBrowser");
|
||||
mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(url);
|
||||
}, 1000);
|
||||
}
|
||||
@ -355,7 +354,7 @@ firetray.Handler = {
|
||||
.getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
||||
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
} catch (x) { ERROR(x); }
|
||||
} catch (x) { firetray.ERROR(x); }
|
||||
}
|
||||
|
||||
}; // firetray.Handler
|
||||
@ -364,7 +363,7 @@ firetray.Handler = {
|
||||
firetray.PrefListener = new PrefListener(
|
||||
"extensions.firetray.",
|
||||
function(branch, name) {
|
||||
LOG('Pref changed: '+name);
|
||||
firetray.LOG('Pref changed: '+name);
|
||||
switch (name) {
|
||||
case 'hides_single_window':
|
||||
firetray.Handler.showHidePopupMenuItems();
|
||||
|
@ -26,10 +26,10 @@ firetray.Messaging = {
|
||||
|
||||
init: function() {
|
||||
if (this.initialized) {
|
||||
WARN("Messaging already initialized");
|
||||
firetray.WARN("Messaging already initialized");
|
||||
return;
|
||||
}
|
||||
LOG("Enabling Messaging");
|
||||
firetray.LOG("Enabling Messaging");
|
||||
|
||||
let that = this;
|
||||
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
|
||||
@ -41,7 +41,7 @@ firetray.Messaging = {
|
||||
shutdown: function() {
|
||||
if (!this.initialized)
|
||||
return;
|
||||
LOG("Disabling Messaging");
|
||||
firetray.LOG("Disabling Messaging");
|
||||
|
||||
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
|
||||
firetray.Handler.setIconImageDefault();
|
||||
@ -61,25 +61,25 @@ firetray.Messaging = {
|
||||
Ci.nsIFolderListener.intPropertyChanged,
|
||||
|
||||
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)
|
||||
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);
|
||||
},
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
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) {
|
||||
LOG("OnItemEvent"+event+" for folder "+item.prettyName);
|
||||
firetray.LOG("OnItemEvent"+event+" for folder "+item.prettyName);
|
||||
},
|
||||
|
||||
updateMsgCount: function(item, property, oldValue, newValue) {
|
||||
@ -105,12 +105,12 @@ firetray.Messaging = {
|
||||
* computes and display new msg count
|
||||
*/
|
||||
updateMsgCount: function() {
|
||||
LOG("updateMsgCount");
|
||||
firetray.LOG("updateMsgCount");
|
||||
if (!this.initialized)
|
||||
return;
|
||||
|
||||
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
|
||||
LOG("msgCountType="+msgCountType);
|
||||
firetray.LOG("msgCountType="+msgCountType);
|
||||
let folderCountFunction, localizedTooltip;
|
||||
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
||||
folderCountFunction = this.unreadMsgCountIterate;
|
||||
@ -122,7 +122,7 @@ firetray.Messaging = {
|
||||
folderCountFunction = this.newMsgCountIterate;
|
||||
localizedTooltip = firetray.Utils.strings.GetStringFromName("tooltip.new_messages");
|
||||
} else
|
||||
ERROR('unknown message count type');
|
||||
firetray.ERROR('unknown message count type');
|
||||
|
||||
let newMsgCount = this.countMessages(folderCountFunction);
|
||||
|
||||
@ -146,7 +146,7 @@ firetray.Messaging = {
|
||||
firetray.Handler.setIconImage(prefCustomIconPath);
|
||||
break;
|
||||
default:
|
||||
ERROR("Unknown notification mode: "+prefMailNotification);
|
||||
firetray.ERROR("Unknown notification mode: "+prefMailNotification);
|
||||
}
|
||||
|
||||
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
|
||||
@ -154,7 +154,7 @@ firetray.Messaging = {
|
||||
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
|
||||
folderCountFunction = this.newMsgCountIterate;
|
||||
} else
|
||||
ERROR('unknown message count type');
|
||||
firetray.ERROR('unknown message count type');
|
||||
|
||||
firetray.Handler.setIconTooltip(localizedTooltip);
|
||||
|
||||
@ -169,7 +169,7 @@ firetray.Messaging = {
|
||||
*/
|
||||
countMessages: function(folderCountFunction) {
|
||||
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 excludedAccounts = mailAccounts["excludedAccounts"];
|
||||
let excludedFoldersFlags = firetray.Utils.prefService
|
||||
@ -179,7 +179,7 @@ firetray.Messaging = {
|
||||
try {
|
||||
let accounts = new this.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)
|
||||
|| (excludedAccounts.indexOf(accountServer.key) >= 0) )
|
||||
continue;
|
||||
@ -196,9 +196,9 @@ firetray.Messaging = {
|
||||
}
|
||||
}
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
LOG("Total New="+newMsgCount);
|
||||
firetray.LOG("Total New="+newMsgCount);
|
||||
return newMsgCount;
|
||||
},
|
||||
|
||||
@ -206,13 +206,13 @@ firetray.Messaging = {
|
||||
let folderCountFunctionName = 'getNumUnread';
|
||||
let folderUnreadMsgCount = folder[folderCountFunctionName](
|
||||
firetray.Utils.prefService.getBoolPref("folder_count_recursive"));
|
||||
LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
|
||||
firetray.LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
|
||||
return accumulator + folderUnreadMsgCount;
|
||||
},
|
||||
|
||||
newMsgCountIterate: function(folder, accumulator) {
|
||||
if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
|
||||
LOG("hasSubFolders");
|
||||
firetray.LOG("hasSubFolders");
|
||||
let subFolders = folder.subFolders;
|
||||
while(subFolders.hasMoreElements()) {
|
||||
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
||||
@ -225,7 +225,7 @@ firetray.Messaging = {
|
||||
|
||||
addHasNewMessages: function(folder, accumulator) {
|
||||
let folderNewMsgCount = folder.hasNewMessages;
|
||||
LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
|
||||
firetray.LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
|
||||
return accumulator || folderNewMsgCount;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ firetray.Messaging.Accounts = function(sortByTypeAndName) {
|
||||
};
|
||||
firetray.Messaging.Accounts.prototype.__iterator__ = function() {
|
||||
let accounts = MailServices.accounts.accounts;
|
||||
LOG("sortByTypeAndName="+this.sortByTypeAndName);
|
||||
firetray.LOG("sortByTypeAndName="+this.sortByTypeAndName);
|
||||
|
||||
/* NOTE: sort() not provided by nsIMsgAccountManager.accounts
|
||||
(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) {
|
||||
LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
|
||||
firetray.LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
|
||||
yield accountServers[i];
|
||||
}
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ var VersionChange = {
|
||||
watch: function() {
|
||||
AddonManager.addAddonListener(this.uninstallListener);
|
||||
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
|
||||
@ -42,13 +42,13 @@ var VersionChange = {
|
||||
},
|
||||
|
||||
onVersionChange: function(addon) {
|
||||
LOG("VERSION: "+addon.version);
|
||||
firetray.LOG("VERSION: "+addon.version);
|
||||
|
||||
this.curVersion = addon.version;
|
||||
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
|
||||
|
||||
if (firstrun) {
|
||||
WARN("FIRST RUN");
|
||||
firetray.WARN("FIRST RUN");
|
||||
this.initPrefs();
|
||||
this.installHook(this.curVersion);
|
||||
|
||||
@ -58,12 +58,12 @@ var VersionChange = {
|
||||
var versionDelta = this.versionComparator.compare(this.curVersion, installedVersion);
|
||||
if (versionDelta > 0) {
|
||||
firetray.Utils.prefService.setCharPref("installedVersion", this.curVersion);
|
||||
WARN("UPGRADE");
|
||||
firetray.WARN("UPGRADE");
|
||||
this.upgradeHook(this.curVersion);
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
WARN("REINSTALL");
|
||||
firetray.WARN("REINSTALL");
|
||||
this.initPrefs();
|
||||
this.reinstallHook(this.curVersion);
|
||||
}
|
||||
|
@ -3,9 +3,7 @@
|
||||
/* for now, logging facilities (imported from logging.jsm) are automatically
|
||||
provided by this module */
|
||||
var EXPORTED_SYMBOLS =
|
||||
[ "firetray", "LOG", "WARN", "ERROR", "FIREFOX_ID", "THUNDERBIRD_ID",
|
||||
"SEAMONKEY_ID", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE", "getType",
|
||||
"isArray", "isEmpty", "strEquals",
|
||||
[ "firetray", "LOG", "WARN", "ERROR", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
|
||||
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
||||
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
||||
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
|
||||
@ -19,13 +17,6 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.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_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
|
||||
|
||||
@ -43,6 +34,7 @@ const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
|
||||
* firetray namespace.
|
||||
*/
|
||||
if ("undefined" == typeof(firetray)) {
|
||||
firetray.firetray.ERROR("### HI ###");
|
||||
var firetray = {};
|
||||
};
|
||||
|
||||
@ -56,26 +48,26 @@ firetray.Utils = {
|
||||
var objPref = JSON.parse(
|
||||
firetray.Utils.prefService.getCharPref(prefStr));
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
return objPref;
|
||||
},
|
||||
setObjPref: function(prefStr, obj) {
|
||||
LOG(obj);
|
||||
firetray.LOG(obj);
|
||||
try {
|
||||
firetray.Utils.prefService.setCharPref(prefStr, JSON.stringify(obj));
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
},
|
||||
|
||||
getArrayPref: function(prefStr) {
|
||||
let arrayPref = this.getObjPref(prefStr);
|
||||
if (!isArray(arrayPref)) throw new TypeError();
|
||||
if (!firetray.js.isArray(arrayPref)) throw new TypeError();
|
||||
return arrayPref;
|
||||
},
|
||||
setArrayPref: function(prefStr, aArray) {
|
||||
if (!isArray(aArray)) throw new TypeError();
|
||||
if (!firetray.js.isArray(aArray)) throw new TypeError();
|
||||
this.setObjPref(prefStr, aArray);
|
||||
},
|
||||
|
||||
@ -95,7 +87,7 @@ firetray.Utils = {
|
||||
let registeryValue = Cc['@mozilla.org/chrome/chrome-registry;1']
|
||||
.getService(Ci.nsIChromeRegistry)
|
||||
.convertChromeURL(uri).spec;
|
||||
LOG(registeryValue);
|
||||
firetray.LOG(registeryValue);
|
||||
|
||||
if (/^file:/.test(registeryValue))
|
||||
registeryValue = this._urlToPath(registeryValue);
|
||||
@ -123,7 +115,7 @@ firetray.Utils = {
|
||||
str += "obj["+i+"]: Unavailable\n";
|
||||
}
|
||||
}
|
||||
LOG(str);
|
||||
firetray.LOG(str);
|
||||
},
|
||||
|
||||
_nsResolver: function(prefix) {
|
||||
@ -143,9 +135,9 @@ firetray.Utils = {
|
||||
var result = doc.evaluate(xpath, ref, that._nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
LOG("XPathResult="+result.resultType);
|
||||
firetray.LOG("XPathResult="+result.resultType);
|
||||
|
||||
switch (result.resultType) {
|
||||
case XPathResult.NUMBER_TYPE:
|
||||
@ -159,7 +151,7 @@ firetray.Utils = {
|
||||
var list = [];
|
||||
try {
|
||||
for (let node = result.iterateNext(); node; node = result.iterateNext()) {
|
||||
LOG("node="+node.nodeName);
|
||||
firetray.LOG("node="+node.nodeName);
|
||||
switch (node.nodeType) {
|
||||
case node.ATTRIBUTE_NODE:
|
||||
list.push(node.value);
|
||||
@ -172,7 +164,7 @@ firetray.Utils = {
|
||||
}
|
||||
}
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
|
||||
return list;
|
||||
@ -190,21 +182,38 @@ firetray.Utils = {
|
||||
if (lib.available())
|
||||
lib.close();
|
||||
});
|
||||
} catch(x) { ERROR(x); }
|
||||
} catch(x) { firetray.ERROR(x); }
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
////////////////////////// more fundamental helpers //////////////////////////
|
||||
|
||||
firetray.js = {
|
||||
// http://stackoverflow.com/questions/767486/how-do-you-check-if-a-variable-is-an-array-in-javascript
|
||||
function isArray(o) {
|
||||
return getType(o) === '[object Array]';
|
||||
}
|
||||
function getType(thing){
|
||||
isArray: function(o) {
|
||||
return this.getType(o) === '[object Array]';
|
||||
},
|
||||
getType: function(thing) {
|
||||
if(thing === null) return "[object Null]"; // special case
|
||||
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
|
||||
// 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);
|
||||
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) {
|
||||
try {
|
||||
LOG("Trying to load library: " + aName);
|
||||
firetray.LOG("Trying to load library: " + aName);
|
||||
|
||||
if (typeof(aName) != "string") {
|
||||
throw Error("Invalid library name");
|
||||
@ -110,19 +110,19 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||
var library;
|
||||
for each (let abi in aABIs) {
|
||||
let soname = "lib" + aName + ".so." + abi.toString();
|
||||
LOG("Trying " + soname);
|
||||
firetray.LOG("Trying " + soname);
|
||||
try {
|
||||
library = ctypes.open(soname);
|
||||
this.ABI = abi;
|
||||
LOG("Successfully loaded " + soname);
|
||||
firetray.LOG("Successfully loaded " + soname);
|
||||
break;
|
||||
} catch(e) {
|
||||
ERROR(soname+" unfound.");
|
||||
firetray.ERROR(soname+" unfound.");
|
||||
}
|
||||
}
|
||||
|
||||
this.close = function() {
|
||||
LOG("Closing library " + aName);
|
||||
firetray.LOG("Closing library " + aName);
|
||||
library.close();
|
||||
this.ABI = -1;
|
||||
|
||||
@ -131,7 +131,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Unloading JS module " + aGlobal.__URI__);
|
||||
firetray.LOG("Unloading JS module " + aGlobal.__URI__);
|
||||
Cu.unload(aGlobal.__URI__);
|
||||
};
|
||||
|
||||
@ -140,7 +140,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||
};
|
||||
|
||||
if (!library) {
|
||||
LOG("Failed to load library: " + aName);
|
||||
firetray.LOG("Failed to load library: " + aName);
|
||||
this.ABI = -1;
|
||||
return;
|
||||
}
|
||||
@ -159,7 +159,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||
return library.declare.apply(library, args);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
ERROR("Missing symbol " + arguments[0] + " in library " + aName);
|
||||
firetray.ERROR("Missing symbol " + arguments[0] + " in library " + aName);
|
||||
self.ABI = -1;
|
||||
return null;
|
||||
}
|
||||
@ -182,7 +182,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
|
||||
aGlobal[aGlobal.EXPORTED_SYMBOLS[0]] = this;
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
ERROR(aName+" definition error: "+e);
|
||||
firetray.ERROR(aName+" definition error: "+e);
|
||||
this.ABI = -1;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- 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 Ci = Components.interfaces;
|
||||
@ -32,11 +32,11 @@ ctypesMap.prototype.get = function(key) {
|
||||
|
||||
ctypesMap.prototype.insert = function(key, item) {
|
||||
if (this.map.hasOwnProperty(key)) {
|
||||
LOG("REPLACE");
|
||||
firetray.LOG("REPLACE");
|
||||
this.array[this.map[key]] = item;
|
||||
|
||||
} else if (this.freedCells.length) {
|
||||
LOG("USE FREE CELL");
|
||||
firetray.LOG("USE FREE CELL");
|
||||
let idx = this.freedCells.shift();
|
||||
this.array[idx] = item;
|
||||
this.map[key] = idx;
|
||||
@ -57,7 +57,7 @@ ctypesMap.prototype.insert = function(key, item) {
|
||||
ctypesMap.prototype.remove = function(key) {
|
||||
if (!this.map.hasOwnProperty(key))
|
||||
throw new RangeError('Unknown key: '+key);
|
||||
LOG("FREE CELL");
|
||||
firetray.LOG("FREE CELL");
|
||||
|
||||
let idx = this.map[key];
|
||||
if (!delete this.map[key])
|
||||
@ -66,3 +66,11 @@ ctypesMap.prototype.remove = function(key) {
|
||||
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");
|
||||
|
||||
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 = {
|
||||
@ -99,8 +99,8 @@ firetray.PopupMenu = {
|
||||
},
|
||||
|
||||
popup: function(icon, button, activateTime, menu) {
|
||||
LOG("menu-popup");
|
||||
LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
|
||||
firetray.LOG("menu-popup");
|
||||
firetray.LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
|
||||
|
||||
try {
|
||||
var gtkMenuPtr = ctypes.cast(menu, gtk.GtkMenu.ptr);
|
||||
@ -108,7 +108,7 @@ firetray.PopupMenu = {
|
||||
gtk.gtk_menu_popup(
|
||||
gtkMenuPtr, null, null, gtk.gtk_status_icon_position_menu,
|
||||
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
|
||||
@ -124,7 +124,7 @@ firetray.PopupMenu = {
|
||||
firetray.PopupMenu.callbacks.menuItemWindowActivate[xid], null);
|
||||
this.setWindowItemLabel(menuItemWindow, xid); // default to xid
|
||||
|
||||
LOG("add gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||
firetray.LOG("add gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||
},
|
||||
|
||||
addItem: function() {
|
||||
@ -138,7 +138,7 @@ firetray.PopupMenu = {
|
||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||
firetray.Handler.gtkPopupMenuWindowItems.remove(xid);
|
||||
this.removeItem(menuItemWindow);
|
||||
LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||
firetray.LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
|
||||
},
|
||||
removeItem: function(item) {
|
||||
gtk.gtk_widget_destroy(ctypes.cast(item, gtk.GtkWidget.ptr));
|
||||
@ -154,7 +154,7 @@ firetray.PopupMenu = {
|
||||
if (!this.windowItemsHandled())
|
||||
return;
|
||||
|
||||
LOG("showSingleWindowItem");
|
||||
firetray.LOG("showSingleWindowItem");
|
||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||
this.showItem(menuItemWindow);
|
||||
this.setWindowItemLabel(menuItemWindow, firetray.Window.getWindowTitle(xid));
|
||||
@ -166,7 +166,7 @@ firetray.PopupMenu = {
|
||||
},
|
||||
|
||||
setWindowItemLabel: function(menuItem, label) {
|
||||
LOG("about to set title: "+label);
|
||||
firetray.LOG("about to set title: "+label);
|
||||
if (label)
|
||||
gtk.gtk_menu_item_set_label(ctypes.cast(menuItem, gtk.GtkMenuItem.ptr), label);
|
||||
},
|
||||
@ -191,7 +191,7 @@ firetray.PopupMenu = {
|
||||
},
|
||||
|
||||
hideSingleWindowItem: function(xid) {
|
||||
LOG("hideSingleWindowItem");
|
||||
firetray.LOG("hideSingleWindowItem");
|
||||
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
|
||||
this.hideItem(menuItemWindow);
|
||||
},
|
||||
@ -201,11 +201,11 @@ firetray.PopupMenu = {
|
||||
},
|
||||
|
||||
showWindowSeparator: function() {
|
||||
LOG("showing menuSeparatorWindows");
|
||||
firetray.LOG("showing menuSeparatorWindows");
|
||||
gtk.gtk_widget_show(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
|
||||
},
|
||||
hideWindowSeparator: function() {
|
||||
LOG("hiding menuSeparatorWindows");
|
||||
firetray.LOG("hiding menuSeparatorWindows");
|
||||
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");
|
||||
|
||||
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 = {
|
||||
@ -32,7 +32,7 @@ firetray.StatusIcon = {
|
||||
// init tray icon, some variables
|
||||
this.trayIcon = gtk.gtk_status_icon_new();
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,12 +66,12 @@ firetray.StatusIcon = {
|
||||
gobject.g_signal_connect(this.trayIcon, "scroll-event",
|
||||
firetray.StatusIcon.callbacks.onScroll, null);
|
||||
|
||||
LOG("showHideAllWindows: "+firetray.Handler.hasOwnProperty("showHideAllWindows"));
|
||||
firetray.LOG("showHideAllWindows: "+firetray.Handler.hasOwnProperty("showHideAllWindows"));
|
||||
this.callbacks.iconActivate = gtk.GCallbackStatusIconActivate_t(
|
||||
firetray.Handler.showHideAllWindows);
|
||||
let handlerId = gobject.g_signal_connect(firetray.StatusIcon.trayIcon,
|
||||
"activate", firetray.StatusIcon.callbacks.iconActivate, null);
|
||||
LOG("g_connect activate="+handlerId);
|
||||
firetray.LOG("g_connect activate="+handlerId);
|
||||
},
|
||||
|
||||
onScroll: function(icon, event, data) {
|
||||
@ -85,21 +85,21 @@ firetray.StatusIcon = {
|
||||
let direction = gdkEventScroll.contents.direction;
|
||||
switch(direction) {
|
||||
case gdk.GDK_SCROLL_UP:
|
||||
LOG("SCROLL UP");
|
||||
firetray.LOG("SCROLL UP");
|
||||
if (scroll_mode === "down_hides")
|
||||
firetray.Handler.showAllWindows();
|
||||
else if (scroll_mode === "up_hides")
|
||||
firetray.Handler.hideAllWindows();
|
||||
break;
|
||||
case gdk.GDK_SCROLL_DOWN:
|
||||
LOG("SCROLL DOWN");
|
||||
firetray.LOG("SCROLL DOWN");
|
||||
if (scroll_mode === "down_hides")
|
||||
firetray.Handler.hideAllWindows();
|
||||
else if (scroll_mode === "up_hides")
|
||||
firetray.Handler.showAllWindows();
|
||||
break;
|
||||
default:
|
||||
ERROR("SCROLL UNKNOWN");
|
||||
firetray.ERROR("SCROLL UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,13 +109,13 @@ firetray.StatusIcon = {
|
||||
firetray.Handler.setIconImage = function(filename) {
|
||||
if (!firetray.StatusIcon.trayIcon)
|
||||
return false;
|
||||
LOG(filename);
|
||||
firetray.LOG(filename);
|
||||
|
||||
try {
|
||||
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
|
||||
filename);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -136,7 +136,7 @@ firetray.Handler.setIconTooltip = function(toolTipStr) {
|
||||
gtk.gtk_status_icon_set_tooltip_text(firetray.StatusIcon.trayIcon,
|
||||
toolTipStr);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -149,7 +149,7 @@ firetray.Handler.setIconTooltipDefault = function() {
|
||||
};
|
||||
|
||||
firetray.Handler.setIconText = function(text, color) { // FIXME: function too long
|
||||
LOG("setIconText, color="+color);
|
||||
firetray.LOG("setIconText, color="+color);
|
||||
if (typeof(text) != "string")
|
||||
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 visual = gdk.gdk_colormap_get_visual(colorMap);
|
||||
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;
|
||||
fore.pixel = fore.red = fore.green = fore.blue = 0;
|
||||
let alpha = new gdk.GdkColor;
|
||||
alpha.pixel = alpha.red = alpha.green = alpha.blue = 0xFFFF;
|
||||
if (!fore || !alpha)
|
||||
WARN("Undefined GdkColor fore or alpha");
|
||||
firetray.WARN("Undefined GdkColor fore or alpha");
|
||||
gdk.gdk_color_parse(color, fore.address());
|
||||
if(fore.red == alpha.red && fore.green == alpha.green && fore.blue == alpha.blue) {
|
||||
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_layout_set_spacing(layout,0);
|
||||
pango.pango_layout_set_font_description(layout, fnt);
|
||||
LOG("layout="+layout);
|
||||
LOG("text="+text);
|
||||
firetray.LOG("layout="+layout);
|
||||
firetray.LOG("text="+text);
|
||||
pango.pango_layout_set_text(layout, text,-1);
|
||||
let tw = new ctypes.int;
|
||||
let th = new ctypes.int;
|
||||
let sz;
|
||||
let border = 4;
|
||||
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
|
||||
while ( tw.value > (w - border) || th.value > (h - border) ) {
|
||||
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_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);
|
||||
// center text
|
||||
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);
|
||||
gobject.g_object_unref(pm);
|
||||
LOG("alpha="+alpha);
|
||||
firetray.LOG("alpha="+alpha);
|
||||
let alphaRed = gobject.guint16(alpha.red);
|
||||
let alphaRed_guchar = ctypes.cast(alphaRed, gobject.guchar);
|
||||
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);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ Cu.import("resource://firetray/ctypes/linux/x11.jsm");
|
||||
Cu.import("resource://firetray/commons.js");
|
||||
|
||||
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 = {};
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
@ -81,7 +81,7 @@ firetray.Window = {
|
||||
|
||||
// Tag the base window
|
||||
let oldTitle = baseWindow.title;
|
||||
LOG("oldTitle="+oldTitle);
|
||||
firetray.LOG("oldTitle="+oldTitle);
|
||||
baseWindow.title = Services2.uuid.generateUUID().toString();
|
||||
|
||||
try {
|
||||
@ -93,16 +93,16 @@ firetray.Window = {
|
||||
ctypes.char.array()(baseWindow.title),
|
||||
null
|
||||
).address();
|
||||
LOG("userData="+userData);
|
||||
firetray.LOG("userData="+userData);
|
||||
gobject.g_list_foreach(widgets, findGtkWindowByTitleCb, userData);
|
||||
gobject.g_list_free(widgets);
|
||||
|
||||
if (userData.contents.outWindow.isNull()) {
|
||||
throw new Error("Window not found!");
|
||||
}
|
||||
LOG("found window: "+userData.contents.outWindow);
|
||||
firetray.LOG("found window: "+userData.contents.outWindow);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
} finally {
|
||||
// Restore
|
||||
baseWindow.title = oldTitle;
|
||||
@ -124,7 +124,7 @@ firetray.Window = {
|
||||
let winTitle = gtk.gtk_window_get_title(gtkWin);
|
||||
|
||||
if (!winTitle.isNull()) {
|
||||
LOG(inTitle+" = "+winTitle);
|
||||
firetray.LOG(inTitle+" = "+winTitle);
|
||||
if (libc.strcmp(inTitle, winTitle) == 0)
|
||||
data.contents.outWindow = gtkWin;
|
||||
}
|
||||
@ -135,7 +135,7 @@ firetray.Window = {
|
||||
let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
|
||||
return gtk.gtk_widget_get_window(gtkWid);
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@ -149,7 +149,7 @@ firetray.Window = {
|
||||
let gdkWin = gtk.gtk_widget_get_window(gtkWid);
|
||||
return gdk.gdk_x11_drawable_get_xid(ctypes.cast(gdkWin, gdk.GdkDrawable.ptr));
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@ -159,7 +159,7 @@ firetray.Window = {
|
||||
let gtkWin = firetray.Window.getGtkWindowHandle(win);
|
||||
let gdkWin = firetray.Window.getGdkWindowFromGtkWindow(gtkWin);
|
||||
let xid = firetray.Window.getXIDFromGdkWindow(gdkWin);
|
||||
LOG("XID="+xid);
|
||||
firetray.LOG("XID="+xid);
|
||||
return [gtkWin, gdkWin, xid];
|
||||
},
|
||||
|
||||
@ -167,7 +167,7 @@ firetray.Window = {
|
||||
for (let xid in firetray.Handler.windows)
|
||||
if (firetray.Handler.windows[xid].chromeWin === win)
|
||||
return xid;
|
||||
ERROR("unknown window while lookup");
|
||||
firetray.ERROR("unknown window while lookup");
|
||||
return null;
|
||||
},
|
||||
|
||||
@ -181,15 +181,15 @@ firetray.Window = {
|
||||
firetray.Handler.gdkWindows.remove(xid);
|
||||
firetray.PopupMenu.removeWindowItem(xid);
|
||||
} else {
|
||||
ERROR("can't unregister unknown window "+xid);
|
||||
firetray.ERROR("can't unregister unknown window "+xid);
|
||||
return false;
|
||||
}
|
||||
LOG("window "+xid+" unregistered");
|
||||
firetray.LOG("window "+xid+" unregistered");
|
||||
return true;
|
||||
},
|
||||
|
||||
showSingleStateful: function(xid) {
|
||||
LOG("showSingleStateful xid="+xid);
|
||||
firetray.LOG("showSingleStateful xid="+xid);
|
||||
|
||||
// try to restore previous state. TODO: z-order respected ?
|
||||
firetray.Window.restorePositionAndSize(xid);
|
||||
@ -206,7 +206,7 @@ firetray.Window = {
|
||||
firetray.Handler.showHideIcon();
|
||||
},
|
||||
showSingleStatelessOnce: function(xid) {
|
||||
LOG("showSingleStateless");
|
||||
firetray.LOG("showSingleStateless");
|
||||
|
||||
firetray.Window.setVisibility(xid, true);
|
||||
|
||||
@ -220,7 +220,7 @@ firetray.Window = {
|
||||
// gdk_window_show_unraised)
|
||||
/* FIXME: hiding windows should also hide child windows */
|
||||
hideSingleStateful: function(xid) {
|
||||
LOG("hideSingleStateful");
|
||||
firetray.LOG("hideSingleStateful");
|
||||
|
||||
firetray.Window.savePositionAndSize(xid);
|
||||
firetray.Window.saveStates(xid);
|
||||
@ -237,7 +237,7 @@ firetray.Window = {
|
||||
* is not accurate.
|
||||
*/
|
||||
hideSingleStatelessOnce: function(xid) {
|
||||
LOG("hideSingleStateless");
|
||||
firetray.LOG("hideSingleStateless");
|
||||
|
||||
firetray.Window.setVisibility(xid, false);
|
||||
|
||||
@ -254,14 +254,14 @@ firetray.Window = {
|
||||
firetray.Handler.windows[xid].savedY = gy.value;
|
||||
firetray.Handler.windows[xid].savedWidth = gwidth.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) {
|
||||
if ("undefined" === typeof(firetray.Handler.windows[xid].savedX))
|
||||
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].savedX,
|
||||
firetray.Handler.windows[xid].savedY,
|
||||
@ -277,12 +277,12 @@ firetray.Window = {
|
||||
saveStates: function(xid) {
|
||||
let winStates = firetray.Window.getXWindowStates(x11.Window(xid));
|
||||
firetray.Handler.windows[xid].savedStates = winStates;
|
||||
LOG("save: windowStates="+winStates);
|
||||
firetray.LOG("save: windowStates="+winStates);
|
||||
},
|
||||
|
||||
restoreStates: function(xid) {
|
||||
let winStates = firetray.Handler.windows[xid].savedStates;
|
||||
LOG("restored WindowStates: " + winStates);
|
||||
firetray.LOG("restored WindowStates: " + winStates);
|
||||
if (winStates & FIRETRAY_XWINDOW_MAXIMIZED) {
|
||||
firetray.Handler.windows[xid].chromeWin.maximize();
|
||||
}
|
||||
@ -300,7 +300,7 @@ firetray.Window = {
|
||||
|
||||
let winDesktop = firetray.Window.getXWindowDesktop(x11.Window(xid));
|
||||
firetray.Handler.windows[xid].savedDesktop = winDesktop;
|
||||
LOG("save: windowDesktop="+winDesktop);
|
||||
firetray.LOG("save: windowDesktop="+winDesktop);
|
||||
},
|
||||
|
||||
restoreDesktop: function(xid) {
|
||||
@ -315,7 +315,7 @@ firetray.Window = {
|
||||
data[0] = desktopDest;
|
||||
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;
|
||||
},
|
||||
|
||||
@ -351,7 +351,7 @@ firetray.Window = {
|
||||
if (!firetray.Utils.prefService.getBoolPref('show_activates'))
|
||||
return;
|
||||
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,
|
||||
actual_type.address(), actual_format.address(), nitems.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)) {
|
||||
ERROR("XGetWindowProperty failed");
|
||||
if (!firetray.js.strEquals(res, x11.Success)) {
|
||||
firetray.ERROR("XGetWindowProperty failed");
|
||||
return [null, null];
|
||||
}
|
||||
if (strEquals(actual_type.value, x11.None)) {
|
||||
LOG("property not found");
|
||||
if (firetray.js.strEquals(actual_type.value, x11.None)) {
|
||||
firetray.LOG("property not found");
|
||||
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
|
||||
array of longs (which in a 64-bit application will be 64-bit values
|
||||
that are padded in the upper 4 bytes). [man XGetWindowProperty] */
|
||||
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);
|
||||
LOG("props="+props+", size="+props.constructor.size);
|
||||
firetray.LOG("props="+props+", size="+props.constructor.size);
|
||||
|
||||
return [props, nitems];
|
||||
},
|
||||
@ -409,18 +409,18 @@ firetray.Window = {
|
||||
|
||||
let [propsFound, nitems] =
|
||||
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;
|
||||
|
||||
let maximizedHorz = maximizedVert = false;
|
||||
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];
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -437,12 +437,12 @@ firetray.Window = {
|
||||
|
||||
let [propsFound, nitems] =
|
||||
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 (strEquals(nitems.value, 0))
|
||||
WARN("desktop number not found");
|
||||
else if (strEquals(nitems.value, 1))
|
||||
if (firetray.js.strEquals(nitems.value, 0))
|
||||
firetray.WARN("desktop number not found");
|
||||
else if (firetray.js.strEquals(nitems.value, 1))
|
||||
desktop = propsFound.contents[0];
|
||||
else
|
||||
throw new RangeError("more than one desktop found");
|
||||
@ -454,7 +454,7 @@ firetray.Window = {
|
||||
|
||||
getWindowTitle: function(xid) {
|
||||
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);
|
||||
if (tailIndex !== -1)
|
||||
return title.substring(0, tailIndex);
|
||||
@ -475,10 +475,10 @@ firetray.Window = {
|
||||
switch (xany.contents.type) {
|
||||
|
||||
case x11.UnmapNotify:
|
||||
LOG("UnmapNotify");
|
||||
firetray.LOG("UnmapNotify");
|
||||
let winStates = firetray.Window.getXWindowStates(xwin);
|
||||
let isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
|
||||
LOG("winStates="+winStates+", isHidden="+isHidden);
|
||||
firetray.LOG("winStates="+winStates+", isHidden="+isHidden);
|
||||
if (isHidden) {
|
||||
let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
|
||||
let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
|
||||
@ -492,11 +492,11 @@ firetray.Window = {
|
||||
break;
|
||||
|
||||
default:
|
||||
// LOG("xany.type="+xany.contents.type);
|
||||
// firetray.LOG("xany.type="+xany.contents.type);
|
||||
break;
|
||||
}
|
||||
} catch(x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
}
|
||||
|
||||
return gdk.GDK_FILTER_CONTINUE;
|
||||
@ -509,14 +509,14 @@ firetray.Window = {
|
||||
|
||||
/** debug facility */
|
||||
firetray.Handler.dumpWindows = function() {
|
||||
LOG(firetray.Handler.windowsCount);
|
||||
for (let winId in firetray.Handler.windows) LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
|
||||
firetray.LOG(firetray.Handler.windowsCount);
|
||||
for (let winId in firetray.Handler.windows) firetray.LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
|
||||
};
|
||||
|
||||
firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
|
||||
|
||||
firetray.Handler.registerWindow = function(win) {
|
||||
LOG("register window");
|
||||
firetray.LOG("register window");
|
||||
|
||||
// register
|
||||
let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
|
||||
@ -538,7 +538,7 @@ firetray.Handler.registerWindow = function(win) {
|
||||
// windows *are* shown at startup
|
||||
this.windows[xid].visibility = true; // this.windows[xid].baseWin.visibility always true :-(
|
||||
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);
|
||||
|
||||
try {
|
||||
@ -551,7 +551,7 @@ firetray.Handler.registerWindow = function(win) {
|
||||
|
||||
} catch (x) {
|
||||
firetray.Window.unregisterWindowByXID(xid);
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -566,35 +566,35 @@ firetray.Handler.registerWindow = function(win) {
|
||||
this.windows[xid].show = firetray.Window.showSingleStateful;
|
||||
}
|
||||
|
||||
LOG("AFTER"); firetray.Handler.dumpWindows();
|
||||
firetray.LOG("AFTER"); firetray.Handler.dumpWindows();
|
||||
return xid;
|
||||
};
|
||||
|
||||
firetray.Handler.unregisterWindow = function(win) {
|
||||
LOG("unregister window");
|
||||
firetray.LOG("unregister window");
|
||||
let xid = firetray.Window.getXIDFromChromeWindow(win);
|
||||
return firetray.Window.unregisterWindowByXID(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.showSingleWindow = function(xid) {
|
||||
LOG("showSingleWindow xid="+xid);
|
||||
firetray.LOG("showSingleWindow xid="+xid);
|
||||
this.windows[xid].show(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.hideSingleWindow = function(xid) {
|
||||
LOG("hideSingleWindow xid="+xid);
|
||||
firetray.LOG("hideSingleWindow xid="+xid);
|
||||
this.windows[xid].hide(xid);
|
||||
};
|
||||
|
||||
firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
||||
LOG("showHideAllWindows: "+userData);
|
||||
firetray.LOG("showHideAllWindows: "+userData);
|
||||
// NOTE: showHideAllWindows being a callback, we need to use
|
||||
// 'firetray.Handler' explicitely instead of 'this'
|
||||
|
||||
LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
|
||||
LOG("windowsCount="+firetray.Handler.windowsCount);
|
||||
firetray.LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
|
||||
firetray.LOG("windowsCount="+firetray.Handler.windowsCount);
|
||||
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
|
||||
LOG("visibilityRate="+visibilityRate);
|
||||
firetray.LOG("visibilityRate="+visibilityRate);
|
||||
if ((0.5 < visibilityRate) && (visibilityRate < 1)
|
||||
|| visibilityRate === 0) // TODO: should be configurable
|
||||
firetray.Handler.showAllWindows();
|
||||
@ -613,7 +613,7 @@ firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
|
||||
* Xlib without opening one... :-(
|
||||
*/
|
||||
x11.init = function() {
|
||||
if (!isEmpty(this.current))
|
||||
if (!firetray.js.isEmpty(this.current))
|
||||
return true; // init only once
|
||||
|
||||
this.current = {};
|
||||
@ -623,11 +623,11 @@ x11.init = function() {
|
||||
this.current.Atoms = {};
|
||||
XATOMS.forEach(function(atomName, index, array) {
|
||||
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);
|
||||
return true;
|
||||
} catch (x) {
|
||||
ERROR(x);
|
||||
firetray.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,10 @@
|
||||
/* -*- 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
|
||||
["LOG", "WARN", "ERROR"].forEach(function(aName) {
|
||||
@ -9,4 +13,4 @@ var EXPORTED_SYMBOLS = ["LOG", "WARN", "ERROR"];
|
||||
LogManager.getLogger("firetray", this);
|
||||
return this[aName];
|
||||
});
|
||||
}, this);
|
||||
}, firetray);
|
||||
|
Loading…
Reference in New Issue
Block a user