From a7516e379ec2ece1db4f222363c39cbb596821ec Mon Sep 17 00:00:00 2001 From: foudfou Date: Thu, 8 Mar 2012 22:04:16 +0100 Subject: [PATCH] wrap "loose" variables and functions within a JavaScript object --- src/Makefile | 4 +- src/chrome/content/options.js | 40 ++++---- src/chrome/content/overlay.js | 14 +-- src/modules/FiretrayHandler.jsm | 73 +++++++------ src/modules/FiretrayMessaging.jsm | 44 ++++---- src/modules/VersionChange.jsm | 10 +- src/modules/commons.js | 88 +++++++--------- src/modules/ctypes/ctypes-utils.jsm | 18 ++-- src/modules/ctypes/ctypesMap.jsm | 16 ++- src/modules/linux/FiretrayPopupMenu.jsm | 22 ++-- src/modules/linux/FiretrayStatusIcon.jsm | 38 +++---- src/modules/linux/FiretrayWindow.jsm | 124 +++++++++++------------ src/modules/logging.jsm | 8 +- 13 files changed, 248 insertions(+), 251 deletions(-) diff --git a/src/Makefile b/src/Makefile index 54a09df..64305e3 100755 --- a/src/Makefile +++ b/src/Makefile @@ -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): diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index fc195cd..0c1633a 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -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=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(); diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index f470f72..23a1a73 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -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 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); } diff --git a/src/modules/commons.js b/src/modules/commons.js index 6b64292..69c1529 100644 --- a/src/modules/commons.js +++ b/src/modules/commons.js @@ -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 ////////////////////////// -// 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){ +firetray.js = { + // http://stackoverflow.com/questions/767486/how-do-you-check-if-a-variable-is-an-array-in-javascript + 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; diff --git a/src/modules/ctypes/ctypes-utils.jsm b/src/modules/ctypes/ctypes-utils.jsm index b8ab0b8..e82d6e2 100644 --- a/src/modules/ctypes/ctypes-utils.jsm +++ b/src/modules/ctypes/ctypes-utils.jsm @@ -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; } } diff --git a/src/modules/ctypes/ctypesMap.jsm b/src/modules/ctypes/ctypesMap.jsm index dff95b9..d46a9dc 100644 --- a/src/modules/ctypes/ctypesMap.jsm +++ b/src/modules/ctypes/ctypesMap.jsm @@ -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; diff --git a/src/modules/linux/FiretrayPopupMenu.jsm b/src/modules/linux/FiretrayPopupMenu.jsm index 4b958db..581b1c3 100644 --- a/src/modules/linux/FiretrayPopupMenu.jsm +++ b/src/modules/linux/FiretrayPopupMenu.jsm @@ -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)); }, diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm index d3a7a1a..6a603a9 100644 --- a/src/modules/linux/FiretrayStatusIcon.jsm +++ b/src/modules/linux/FiretrayStatusIcon.jsm @@ -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; } diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 9f4b581..bc7ade1 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -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