* revert a7516e partly:

* support icedove/iceweasel/iceape (appId's are equivalent with FF, TB, SM)
  * have a nice "F" mandatory wrapper object (instead of the long "firetray")
* fix version anchor on the firetray splash page when opening a tab
This commit is contained in:
foudfou 2012-03-30 23:20:47 +02:00
parent 746ab759f7
commit f5e56dab81
13 changed files with 222 additions and 211 deletions

View File

@ -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 '/firetray.LOG(/d' $< > $@; \
sed '/F.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 '/firetray.LOG(/d' $< > $@; \
sed '/F.LOG(/d' $< > $@; \
fi
$(build_dir):

View File

@ -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;
firetray.LOG("hides_on_close="+hides_on_close+", hides_on_minimize="+hides_on_minimize);
F.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() {
firetray.LOG("updateNotificationSettings");
F.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) {
firetray.LOG("disableMessageCountMaybe: "+msgCountType);
F.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");
firetray.LOG("folder: "+folderType);
F.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');
firetray.LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
F.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];
}
firetray.LOG("excluded folders flags: "+excludedFoldersFlags);
F.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');
firetray.LOG("CELLS: "+cells);
F.LOG("CELLS: "+cells);
for (let i=0, len=cells.length; i<len; ++i) {
firetray.LOG("i: "+i+", cell:"+cells[i]);
F.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) {
firetray.ERROR(e);
F.ERROR(e);
}
},
@ -280,8 +280,8 @@ var firetrayUIOptions = {
* needed for triggering actual preference change and saving
*/
_userChangeValueTree: function(event) {
if (event.attrName == "label") firetray.LOG("label changed!");
if (event.attrName == "value") firetray.LOG("value changed!");
if (event.attrName == "label") F.LOG("label changed!");
if (event.attrName == "value") F.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');
firetray.LOG("subRows="+subRows);
F.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
firetray.WARN("NOT IMPLEMENTED YET: move row to new rank"); // TODO
F.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();
firetray.LOG(JSON.stringify(accountsByServerType));
F.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
});
firetray.LOG("serverTypesSorted: "+serverTypesSorted);
F.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];
firetray.LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
F.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");
firetray.LOG("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
F.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")));
firetray.LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
F.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);
firetray.LOG("prefStr"+prefStr);
F.LOG("prefStr"+prefStr);
/* return the new prefString to be stored by pref system */
return prefStr;
},
onKeyPressTreeAccountsOrServerTypes: function(event) {
firetray.LOG("TREE KEYPRESS: "+event.originalTarget);
F.LOG("TREE KEYPRESS: "+event.originalTarget);
let tree = document.getElementById("ui_tree_mail_accounts");
let col = tree.editingColumn; // col.index

View File

@ -13,10 +13,10 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
onLoad: function(win) {
this.strings = document.getElementById("firetray-strings"); // chrome-specific
firetray.LOG("Handler initialized: "+firetray.Handler.initialized);
F.LOG("Handler initialized: "+firetray.Handler.initialized);
let init = firetray.Handler.initialized || firetray.Handler.init();
firetray.LOG("ONLOAD"); firetray.Handler.dumpWindows();
F.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) {
firetray.LOG('start_hidden');
F.LOG('start_hidden');
firetray.Handler.hideSingleWindow(winId);
}
firetray.LOG('Firetray LOADED: ' + init);
F.LOG('Firetray LOADED: ' + init);
return true;
},
@ -39,7 +39,7 @@ 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) */
firetray.LOG('Firetray UNLOADED !');
F.LOG('Firetray UNLOADED !');
},
/* until we find a fix (TODO), we need to set browser.tabs.warnOnClose=false
@ -48,14 +48,14 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
use trying to set warnOnClose=false temporarily in onClose, since onClose is
called *after* the popup */
onClose: function(event) {
firetray.LOG('Firetray CLOSE');
F.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');
firetray.LOG('hides_on_close: '+hides_on_close+', hides_single_window='+hides_single_window);
F.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);

View File

@ -35,6 +35,7 @@ firetray.Handler = {
FILENAME_NEWMAIL: null,
initialized: false,
appId: (function(){return Services.appinfo.ID;})(),
appName: (function(){return Services.appinfo.name;})(),
runtimeABI: (function(){return Services.appinfo.XPCOMABI;})(),
runtimeOS: (function(){return Services.appinfo.OS;})(), // "WINNT", "Linux", "Darwin"
@ -50,24 +51,24 @@ firetray.Handler = {
// version checked during install, so we shouldn't need to care
let xulVer = Services.appinfo.platformVersion; // Services.vc.compare(xulVer,"2.0a")>=0
firetray.LOG("OS=" + this.runtimeOS + ", ABI=" + this.runtimeABI + ", XULrunner=" + xulVer);
F.LOG("OS=" + this.runtimeOS + ", ABI=" + this.runtimeABI + ", XULrunner=" + xulVer);
switch (this.runtimeOS) {
case "Linux":
Cu.import("resource://firetray/linux/FiretrayStatusIcon.jsm");
firetray.LOG('FiretrayStatusIcon imported');
F.LOG('FiretrayStatusIcon imported');
Cu.import("resource://firetray/linux/FiretrayWindow.jsm");
firetray.LOG('FiretrayWindow imported');
F.LOG('FiretrayWindow imported');
break;
default:
firetray.ERROR("FIRETRAY: only Linux platform supported at this time. Firetray not loaded");
F.ERROR("FIRETRAY: only Linux platform supported at this time. Firetray not loaded");
return false;
}
if (this.appName === "Thunderbird" || this.appName === "SeaMonkey")
if (this.appId === F.THUNDERBIRD_ID || this.appId === F.SEAMONKEY_ID)
this.inMailApp = true;
if (this.appName === "Firefox" || this.appName === "SeaMonkey")
if (this.appId === F.FIREFOX_ID || this.appId === F.SEAMONKEY_ID)
this.inBrowserApp = true;
firetray.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
F.LOG('inMailApp: '+this.inMailApp+', inBrowserApp: '+this.inBrowserApp);
this.FILENAME_DEFAULT = firetray.Utils.chromeToPath(
"chrome://firetray/skin/" + this.appName.toLowerCase() + this.FILENAME_SUFFIX);
@ -78,7 +79,7 @@ firetray.Handler = {
firetray.StatusIcon.init();
firetray.Handler.showHideIcon();
firetray.LOG('StatusIcon initialized');
F.LOG('StatusIcon initialized');
if (this.inMailApp) {
try {
@ -88,17 +89,17 @@ firetray.Handler = {
firetray.Messaging.updateMsgCount();
}
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
return false;
}
}
Services.obs.addObserver(this, this.getAppStartupTopic(this.appName), false);
Services.obs.addObserver(this, this.getAppStartupTopic(this.appId), false);
Services.obs.addObserver(this, "xpcom-will-shutdown", false);
Services.obs.addObserver(this, "profile-change-teardown", false);
let welcome = function(ver) {
firetray.Handler.openTab(FIRETRAY_SPLASH_PAGE+"#"+ver);
firetray.Handler.openTab(FIRETRAY_SPLASH_PAGE+"#v"+ver);
firetray.Handler.tryEraseOldOptions();
firetray.Handler.correctMailNotificationType();
};
@ -123,7 +124,7 @@ firetray.Handler = {
firetray.Utils.tryCloseLibs([gobject, glib, gtk]);
Services.obs.removeObserver(this, this.getAppStartupTopic(this.appName), false);
Services.obs.removeObserver(this, this.getAppStartupTopic(this.appId), false);
Services.obs.removeObserver(this, "xpcom-will-shutdown", false);
Services.obs.removeObserver(this, "profile-change-teardown", false);
@ -137,16 +138,16 @@ firetray.Handler = {
case "sessionstore-windows-restored":
case "mail-startup-done":
case "final-ui-startup":
firetray.LOG("RECEIVED: "+topic+", launching timer");
F.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;
firetray.LOG("*** appStarted ***");
F.LOG("*** appStarted ***");
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
break;
case "xpcom-will-shutdown":
firetray.LOG("xpcom-will-shutdown");
F.LOG("xpcom-will-shutdown");
this.shutdown();
break;
case "profile-change-teardown":
@ -159,10 +160,10 @@ firetray.Handler = {
getAppStartupTopic: function(id) {
switch (id) {
case "Firefox":
case "SeaMonkey":
case F.FIREFOX_ID:
case F.SEAMONKEY_ID:
return 'sessionstore-windows-restored';
case "Thunderbird":
case F.THUNDERBIRD_ID:
return 'mail-startup-done';
default:
return 'final-ui-startup';
@ -184,14 +185,14 @@ firetray.Handler = {
showHideAllWindows: function() {},
showAllWindows: function() {
firetray.LOG("showAllWindows");
F.LOG("showAllWindows");
for (let winId in firetray.Handler.windows) {
if (!firetray.Handler.windows[winId].visibility)
firetray.Handler.showSingleWindow(winId);
}
},
hideAllWindows: function() {
firetray.LOG("hideAllWindows");
F.LOG("hideAllWindows");
for (let winId in firetray.Handler.windows) {
if (firetray.Handler.windows[winId].visibility)
firetray.Handler.hideSingleWindow(winId);
@ -217,7 +218,7 @@ firetray.Handler = {
.QueryInterface(Ci.nsIInterfaceRequestor);
} catch (ex) {
// ignore no-interface exception
firetray.ERROR(ex);
F.ERROR(ex);
return null;
}
@ -226,7 +227,7 @@ firetray.Handler = {
else if (iface == "nsIXULWindow")
winOut = winInterface.getInterface(Ci.nsIXULWindow);
else {
firetray.ERROR("unknown iface '" + iface + "'");
F.ERROR("unknown iface '" + iface + "'");
return null;
}
@ -234,9 +235,9 @@ firetray.Handler = {
},
_getBrowserProperties: function() {
if (firetray.Handler.appName === "Firefox")
if (firetray.Handler.appId === F.FIREFOX_ID)
return "chrome://branding/locale/browserconfig.properties";
else if (firetray.Handler.appName === "SeaMonkey")
else if (firetray.Handler.appId === F.SEAMONKEY_ID)
return "chrome://navigator-region/locale/region.properties";
else return null;
},
@ -262,7 +263,7 @@ firetray.Handler = {
openBrowserWindow: function() {
try {
var home = firetray.Handler._getHomePage();
firetray.LOG("home="+home);
F.LOG("home="+home);
// FIXME: obviously we need to wait to avoid seg fault on jsapi.cpp:827
// 827 if (t->data.requestDepth) {
@ -270,7 +271,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) { firetray.ERROR(x); }
} catch (x) { F.ERROR(x); }
},
openMailMessage: function() {
@ -279,16 +280,16 @@ firetray.Handler = {
var msgComposeService = Cc["@mozilla.org/messengercompose;1"]
.getService(Ci.nsIMsgComposeService);
msgComposeService.OpenComposeWindowWithURI(null, aURI);
} catch (x) { firetray.ERROR(x); }
} catch (x) { F.ERROR(x); }
},
openTab: function(url) {
if (this.appName === "Thunderbird")
if (this.appId === F.THUNDERBIRD_ID)
this.openMailTab(url);
else if (this.appName === "Firefox" || this.appName === "SeaMonkey")
else if (this.appId === F.FIREFOX_ID || this.appId === F.SEAMONKEY_ID)
this.openBrowserTab(url);
else
firetray.ERROR("unsupported application");
F.ERROR("unsupported application");
},
openMailTab: function(url) {
@ -300,7 +301,7 @@ firetray.Handler = {
if (tabmail) {
firetray.Utils.timer(function() {
firetray.LOG("openMailTab");
F.LOG("openMailTab");
tabmail.openTab("contentTab", {contentPage: url});
}, FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
}
@ -308,7 +309,7 @@ firetray.Handler = {
openBrowserTab: function(url) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
firetray.LOG("WIN="+win);
F.LOG("WIN="+win);
if (win) {
var mainWindow = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
@ -318,7 +319,7 @@ firetray.Handler = {
.getInterface(Components.interfaces.nsIDOMWindow);
mainWindow.setTimeout(function(win){
firetray.LOG("openBrowser");
F.LOG("openBrowser");
mainWindow.gBrowser.selectedTab = mainWindow.gBrowser.addTab(url);
}, 1000);
}
@ -358,21 +359,21 @@ firetray.Handler = {
.getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eAttemptQuit);
}, FIRETRAY_DELAY_NOWAIT_MILLISECONDS, Ci.nsITimer.TYPE_ONE_SHOT);
} catch (x) { firetray.ERROR(x); }
} catch (x) { F.ERROR(x); }
},
preventWarnOnClose: function() {
if (!this.inBrowserApp) return;
let generalTabsPrefs = Services.prefs.getBranch("browser.tabs.");
this.warnOnCloseTmp = generalTabsPrefs.getBoolPref('warnOnClose');
firetray.LOG("warnOnClose saved. was: "+this.warnOnCloseTmp);
F.LOG("warnOnClose saved. was: "+this.warnOnCloseTmp);
generalTabsPrefs.setBoolPref('warnOnClose', false);
},
restoreWarnOnClose: function() {
if (!this.inBrowserApp && !this.warnOnCloseTmp) return;
let generalTabsPrefs = Services.prefs.getBranch("browser.tabs.");
generalTabsPrefs.setBoolPref('warnOnClose', this.warnOnCloseTmp);
firetray.LOG("warnOnClose restored to: "+this.warnOnCloseTmp);
F.LOG("warnOnClose restored to: "+this.warnOnCloseTmp);
}
}; // firetray.Handler
@ -381,7 +382,7 @@ firetray.Handler = {
firetray.PrefListener = new PrefListener(
"extensions.firetray.",
function(branch, name) {
firetray.LOG('Pref changed: '+name);
F.LOG('Pref changed: '+name);
switch (name) {
case 'hides_single_window':
firetray.Handler.showHidePopupMenuItems();

View File

@ -27,15 +27,15 @@ firetray.Messaging = {
init: function() {
if (this.initialized) {
firetray.LOG("Messaging already initialized");
F.LOG("Messaging already initialized");
return;
}
firetray.LOG("Enabling Messaging");
F.LOG("Enabling Messaging");
// there is no means to detect account-removed event
this.cleaningTimer = firetray.Utils.timer(firetray.Messaging.cleanExcludedAccounts,
FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS, Ci.nsITimer.TYPE_REPEATING_SLACK);
firetray.WARN(this.cleaningTimer+"="+FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS);
F.WARN(this.cleaningTimer+"="+FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS);
let that = this;
MailServices.mailSession.AddFolderListener(that.mailSessionListener,
@ -47,7 +47,7 @@ firetray.Messaging = {
shutdown: function() {
if (!this.initialized)
return;
firetray.LOG("Disabling Messaging");
F.LOG("Disabling Messaging");
this.cleaningTimer.cancel();
@ -61,7 +61,7 @@ firetray.Messaging = {
at shutdown because MailServices.accounts no longer available */
cleanExcludedAccounts: function() {
try {
firetray.LOG("* cleaning *");
F.LOG("* cleaning *");
let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
let excludedAccounts = mailAccounts["excludedAccounts"];
@ -83,11 +83,11 @@ firetray.Messaging = {
}
if (cleaningNeeded) {
firetray.LOG("cleaning excluded accounts");
F.LOG("cleaning excluded accounts");
let prefObj = {"serverTypes":mailAccounts["serverTypes"], "excludedAccounts":newExcludedAccounts};
firetray.Utils.setObjPref('mail_accounts', prefObj);
}
} catch(x) { firetray.ERROR(x); }
} catch(x) { F.ERROR(x); }
},
/* http://mxr.mozilla.org/comm-central/source/mailnews/base/public/nsIFolderListener.idl */
@ -100,25 +100,25 @@ firetray.Messaging = {
Ci.nsIFolderListener.intPropertyChanged,
OnItemPropertyChanged: function(item, property, oldValue, newValue) { // NumNewBiffMessages
firetray.LOG("OnItemPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
F.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)
firetray.LOG("OnItemIntPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
F.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)
firetray.LOG("OnItemBoolPropertyChanged "+property+" for folder "+item.prettyName+" was "+oldValue+" became "+newValue+" NEW MESSAGES="+item.getNumNewMessages(true));
F.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) {
firetray.LOG("OnItemPropertyFlagChanged"+property+" for "+item+" was "+oldFlag+" became "+newFlag);
F.LOG("OnItemPropertyFlagChanged"+property+" for "+item+" was "+oldFlag+" became "+newFlag);
},
OnItemEvent: function(item, event) {
firetray.LOG("OnItemEvent"+event+" for folder "+item.prettyName);
F.LOG("OnItemEvent"+event+" for folder "+item.prettyName);
},
updateMsgCount: function(item, property, oldValue, newValue) {
@ -144,26 +144,26 @@ firetray.Messaging = {
* computes and display new msg count
*/
updateMsgCount: function() {
firetray.LOG("updateMsgCount");
F.LOG("updateMsgCount");
if (!this.initialized)
return;
// initialize
let newMsgCount, localizedTooltip;
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
firetray.LOG("msgCountType="+msgCountType);
F.LOG("msgCountType="+msgCountType);
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD) {
newMsgCount = this.countMessages(this.unreadMsgCountIterate);
localizedTooltip = PluralForm.get(
newMsgCount,
firetray.Utils.strings.GetStringFromName("tooltip.unread_messages"))
.replace("#1", newMsgCount);
firetray.LOG(localizedTooltip);
F.LOG(localizedTooltip);
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
newMsgCount = this.countMessages(this.newMsgCountIterate);
localizedTooltip = firetray.Utils.strings.GetStringFromName("tooltip.new_messages");
} else
firetray.ERROR('unknown message count type');
F.ERROR('unknown message count type');
// update icon
if (newMsgCount == 0) {
@ -185,7 +185,7 @@ firetray.Messaging = {
firetray.Handler.setIconImage(prefCustomIconPath);
break;
default:
firetray.ERROR("Unknown notification mode: "+prefMailNotification);
F.ERROR("Unknown notification mode: "+prefMailNotification);
}
firetray.Handler.setIconTooltip(localizedTooltip);
@ -201,7 +201,7 @@ firetray.Messaging = {
*/
countMessages: function(folderCountFunction) {
let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
firetray.LOG("mail accounts from pref: "+JSON.stringify(mailAccounts));
F.LOG("mail accounts from pref: "+JSON.stringify(mailAccounts));
let serverTypes = mailAccounts["serverTypes"];
let excludedAccounts = mailAccounts["excludedAccounts"];
let excludedFoldersFlags = firetray.Utils.prefService
@ -211,7 +211,7 @@ firetray.Messaging = {
try {
let accounts = new this.Accounts();
for (let accountServer in accounts) {
firetray.LOG("is servertype excluded: "+serverTypes[accountServer.type].excluded+", account exclusion index: "+excludedAccounts.indexOf(accountServer.key));
F.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;
@ -228,9 +228,9 @@ firetray.Messaging = {
}
}
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
}
firetray.LOG("Total New="+newMsgCount);
F.LOG("Total New="+newMsgCount);
return newMsgCount;
},
@ -238,13 +238,13 @@ firetray.Messaging = {
let folderCountFunctionName = 'getNumUnread';
let folderUnreadMsgCount = folder[folderCountFunctionName](
firetray.Utils.prefService.getBoolPref("folder_count_recursive"));
firetray.LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
F.LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
return accumulator + folderUnreadMsgCount;
},
newMsgCountIterate: function(folder, accumulator) {
if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
firetray.LOG("hasSubFolders");
F.LOG("hasSubFolders");
let subFolders = folder.subFolders;
while(subFolders.hasMoreElements()) {
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
@ -257,7 +257,7 @@ firetray.Messaging = {
addHasNewMessages: function(folder, accumulator) {
let folderNewMsgCount = folder.hasNewMessages;
firetray.LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
F.LOG(folder.prettyName+" hasNewMessages="+folderNewMsgCount);
return accumulator || folderNewMsgCount;
}
@ -280,7 +280,7 @@ firetray.Messaging.Accounts = function(sortByTypeAndName) {
};
firetray.Messaging.Accounts.prototype.__iterator__ = function() {
let accounts = MailServices.accounts.accounts;
firetray.LOG("sortByTypeAndName="+this.sortByTypeAndName);
F.LOG("sortByTypeAndName="+this.sortByTypeAndName);
/* NOTE: sort() not provided by nsIMsgAccountManager.accounts
(nsISupportsArray, nsICollection). Should be OK to re-build a JS-Array for
@ -311,7 +311,7 @@ firetray.Messaging.Accounts.prototype.__iterator__ = function() {
}
for (let i=0, len=accountServers.length; i<len; ++i) {
firetray.LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
F.LOG("ACCOUNT: "+accountServers[i].prettyName+" type: "+accountServers[i].type);
yield accountServers[i];
}
};

View File

@ -23,7 +23,7 @@ var VersionChange = {
watch: function() {
AddonManager.addAddonListener(this.uninstallListener);
AddonManager.getAddonByID(FIRETRAY_ID, this.onVersionChange.bind(this));
firetray.LOG("version change watching enabled");
F.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) {
firetray.LOG("VERSION: "+addon.version);
F.LOG("VERSION: "+addon.version);
this.curVersion = addon.version;
var firstrun = firetray.Utils.prefService.getBoolPref("firstrun");
if (firstrun) {
firetray.LOG("FIRST RUN");
F.LOG("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);
firetray.LOG("UPGRADE");
F.LOG("UPGRADE");
this.upgradeHook(this.curVersion);
}
} catch (ex) {
firetray.LOG("REINSTALL");
F.LOG("REINSTALL");
this.initPrefs();
this.reinstallHook(this.curVersion);
}

View File

@ -3,7 +3,7 @@
/* for now, logging facilities (imported from logging.jsm) are automatically
provided by this module */
var EXPORTED_SYMBOLS =
[ "firetray", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
[ "firetray", "F", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
@ -32,15 +32,25 @@ const FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS = 15*60*1000;
const FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD = 0;
const FIRETRAY_MESSAGE_COUNT_TYPE_NEW = 1;
if ("undefined" == typeof(F)) {
var F = {}; // helper wrapper
};
F.FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
F.THUNDERBIRD_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
F.SONGBIRD_ID = "songbird@songbirdnest.com";
F.SUNBIRD_ID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
F.SEAMONKEY_ID = "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}";
F.CHATZILLA_ID = "{59c81df5-4b7a-477b-912d-4e0fdf64e5f2}";
/**
* firetray namespace.
*/
if ("undefined" == typeof(firetray)) {
firetray.firetray.ERROR("### HI ###");
var firetray = {};
};
firetray.Utils = {
prefService: Services.prefs.getBranch("extensions.firetray."),
strings: Services.strings.createBundle("chrome://firetray/locale/overlay.properties"),
@ -50,16 +60,16 @@ firetray.Utils = {
var objPref = JSON.parse(
firetray.Utils.prefService.getCharPref(prefStr));
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
}
return objPref;
},
setObjPref: function(prefStr, obj) {
firetray.LOG(obj);
F.LOG(obj);
try {
firetray.Utils.prefService.setCharPref(prefStr, JSON.stringify(obj));
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
}
},
@ -76,7 +86,7 @@ firetray.Utils = {
QueryInterfaces: function(obj) {
for each (i in Components.interfaces)
try {
if (obj instanceof i) firetray.LOG (i);
if (obj instanceof i) F.LOG (i);
} catch(x) {}
},
@ -89,7 +99,7 @@ firetray.Utils = {
let registeryValue = Cc['@mozilla.org/chrome/chrome-registry;1']
.getService(Ci.nsIChromeRegistry)
.convertChromeURL(uri).spec;
firetray.LOG(registeryValue);
F.LOG(registeryValue);
if (/^file:/.test(registeryValue))
registeryValue = this._urlToPath(registeryValue);
@ -117,7 +127,7 @@ firetray.Utils = {
str += "obj["+i+"]: Unavailable\n";
}
}
firetray.LOG(str);
F.LOG(str);
},
_nsResolver: function(prefix) {
@ -137,9 +147,9 @@ firetray.Utils = {
var result = doc.evaluate(xpath, ref, that._nsResolver,
XPathResult.ANY_TYPE, null);
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
}
firetray.LOG("XPathResult="+result.resultType);
F.LOG("XPathResult="+result.resultType);
switch (result.resultType) {
case XPathResult.NUMBER_TYPE:
@ -153,7 +163,7 @@ firetray.Utils = {
var list = [];
try {
for (let node = result.iterateNext(); node; node = result.iterateNext()) {
firetray.LOG("node="+node.nodeName);
F.LOG("node="+node.nodeName);
switch (node.nodeType) {
case node.ATTRIBUTE_NODE:
list.push(node.value);
@ -166,7 +176,7 @@ firetray.Utils = {
}
}
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
}
return list;
@ -185,7 +195,7 @@ firetray.Utils = {
if (lib.available())
lib.close();
});
} catch(x) { firetray.ERROR(x); }
} catch(x) { F.ERROR(x); }
}
};

View File

@ -80,7 +80,7 @@ var EXPORTED_SYMBOLS = [ "ctypes_library" ];
*/
function ctypes_library(aName, aABIs, aDefines, aGlobal) {
try {
firetray.LOG("Trying to load library: " + aName);
F.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();
firetray.LOG("Trying " + soname);
F.LOG("Trying " + soname);
try {
library = ctypes.open(soname);
this.ABI = abi;
firetray.LOG("Successfully loaded " + soname);
F.LOG("Successfully loaded " + soname);
break;
} catch(e) {
firetray.ERROR(soname+" unfound.");
F.ERROR(soname+" unfound.");
}
}
this.close = function() {
firetray.LOG("Closing library " + aName);
F.LOG("Closing library " + aName);
library.close();
this.ABI = -1;
@ -131,7 +131,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
return;
}
firetray.LOG("Unloading JS module " + aGlobal.__URI__);
F.LOG("Unloading JS module " + aGlobal.__URI__);
Cu.unload(aGlobal.__URI__);
};
@ -140,7 +140,7 @@ function ctypes_library(aName, aABIs, aDefines, aGlobal) {
};
if (!library) {
firetray.LOG("Failed to load library: " + aName);
F.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);
firetray.ERROR("Missing symbol " + arguments[0] + " in library " + aName);
F.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);
firetray.ERROR(aName+" definition error: "+e);
F.ERROR(aName+" definition error: "+e);
this.ABI = -1;
}
}

View File

@ -32,11 +32,11 @@ ctypesMap.prototype.get = function(key) {
ctypesMap.prototype.insert = function(key, item) {
if (this.map.hasOwnProperty(key)) {
firetray.LOG("REPLACE");
F.LOG("REPLACE");
this.array[this.map[key]] = item;
} else if (this.freedCells.length) {
firetray.LOG("USE FREE CELL");
F.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);
firetray.LOG("FREE CELL");
F.LOG("FREE CELL");
let idx = this.map[key];
if (!delete this.map[key])

View File

@ -14,7 +14,7 @@ Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
Cu.import("resource://firetray/commons.js");
if ("undefined" == typeof(firetray.StatusIcon))
firetray.ERROR("This module MUST be imported from/after StatusIcon !");
F.ERROR("This module MUST be imported from/after StatusIcon !");
firetray.PopupMenu = {
@ -99,8 +99,8 @@ firetray.PopupMenu = {
},
popup: function(icon, button, activateTime, menu) {
firetray.LOG("menu-popup");
firetray.LOG("ARGS="+icon+", "+button+", "+activateTime+", "+menu);
F.LOG("menu-popup");
F.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) { firetray.ERROR(x); }
} catch (x) { F.ERROR(x); }
},
// we'll be creating menuItems for windows (and not showing them) even if
@ -124,7 +124,7 @@ firetray.PopupMenu = {
gobject.g_signal_connect(menuItemWindow, "activate",
firetray.PopupMenu.callbacks.menuItemWindowActivate[xid], null);
firetray.LOG("added gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
F.LOG("added gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
},
createAndAddItemToMenu: function() {
@ -138,7 +138,7 @@ firetray.PopupMenu = {
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
firetray.Handler.gtkPopupMenuWindowItems.remove(xid);
this.removeItem(menuItemWindow);
firetray.LOG("remove gtkPopupMenuWindowItems: "+firetray.Handler.gtkPopupMenuWindowItems.count);
F.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;
firetray.LOG("showSingleWindowItem");
F.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) {
firetray.LOG("about to set title: "+label);
F.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) {
firetray.LOG("hideSingleWindowItem");
F.LOG("hideSingleWindowItem");
let menuItemWindow = firetray.Handler.gtkPopupMenuWindowItems.get(xid);
this.hideItem(menuItemWindow);
},
@ -201,11 +201,11 @@ firetray.PopupMenu = {
},
showWindowSeparator: function() {
firetray.LOG("showing menuSeparatorWindows");
F.LOG("showing menuSeparatorWindows");
gtk.gtk_widget_show(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
},
hideWindowSeparator: function() {
firetray.LOG("hiding menuSeparatorWindows");
F.LOG("hiding menuSeparatorWindows");
gtk.gtk_widget_hide(ctypes.cast(this.menuSeparatorWindows, gtk.GtkWidget.ptr));
},

View File

@ -18,7 +18,7 @@ Cu.import("resource://firetray/ctypes/linux/pangocairo.jsm");
Cu.import("resource://firetray/commons.js");
if ("undefined" == typeof(firetray.Handler))
firetray.ERROR("This module MUST be imported from/after FiretrayHandler !");
F.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) {
firetray.ERROR(x);
F.ERROR(x);
return false;
}
@ -66,12 +66,12 @@ firetray.StatusIcon = {
gobject.g_signal_connect(this.trayIcon, "scroll-event",
firetray.StatusIcon.callbacks.onScroll, null);
firetray.LOG("showHideAllWindows: "+firetray.Handler.hasOwnProperty("showHideAllWindows"));
F.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);
firetray.LOG("g_connect activate="+handlerId);
F.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:
firetray.LOG("SCROLL UP");
F.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:
firetray.LOG("SCROLL DOWN");
F.LOG("SCROLL DOWN");
if (scroll_mode === "down_hides")
firetray.Handler.hideAllWindows();
else if (scroll_mode === "up_hides")
firetray.Handler.showAllWindows();
break;
default:
firetray.ERROR("SCROLL UNKNOWN");
F.ERROR("SCROLL UNKNOWN");
}
}
@ -109,13 +109,13 @@ firetray.StatusIcon = {
firetray.Handler.setIconImage = function(filename) {
if (!firetray.StatusIcon.trayIcon)
return false;
firetray.LOG(filename);
F.LOG(filename);
try {
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
filename);
} catch (x) {
firetray.ERROR(x);
F.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) {
firetray.ERROR(x);
F.ERROR(x);
return false;
}
return true;
@ -149,7 +149,7 @@ firetray.Handler.setIconTooltipDefault = function() {
};
firetray.Handler.setIconText = function(text, color) { // FIXME: function too long
firetray.LOG("setIconText, color="+color);
F.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;
firetray.LOG("colorMap="+colorMap+" visual="+visual+" visualDepth="+visualDepth);
F.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)
firetray.WARN("Undefined GdkColor fore or alpha");
F.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);
firetray.LOG("layout="+layout);
firetray.LOG("text="+text);
F.LOG("layout="+layout);
F.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());
firetray.LOG("tw="+tw.value+" th="+th.value);
F.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());
}
firetray.LOG("tw="+tw.value+" th="+th.value);
F.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);
firetray.LOG("alpha="+alpha);
F.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) {
firetray.ERROR(x);
F.ERROR(x);
return false;
}

View File

@ -25,7 +25,7 @@ Cu.import("resource://firetray/ctypes/linux/x11.jsm");
Cu.import("resource://firetray/commons.js");
if ("undefined" == typeof(firetray.Handler))
firetray.ERROR("This module MUST be imported from/after FiretrayHandler !");
F.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;
firetray.LOG("oldTitle="+oldTitle);
F.LOG("oldTitle="+oldTitle);
baseWindow.title = Services2.uuid.generateUUID().toString();
try {
@ -93,16 +93,16 @@ firetray.Window = {
ctypes.char.array()(baseWindow.title),
null
).address();
firetray.LOG("userData="+userData);
F.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!");
}
firetray.LOG("found window: "+userData.contents.outWindow);
F.LOG("found window: "+userData.contents.outWindow);
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
} finally {
// Restore
baseWindow.title = oldTitle;
@ -124,7 +124,7 @@ firetray.Window = {
let winTitle = gtk.gtk_window_get_title(gtkWin);
if (!winTitle.isNull()) {
firetray.LOG(inTitle+" = "+winTitle);
F.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) {
firetray.ERROR(x);
F.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) {
firetray.ERROR(x);
F.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);
firetray.LOG("XID="+xid);
F.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;
firetray.ERROR("unknown window while lookup");
F.ERROR("unknown window while lookup");
return null;
},
@ -181,15 +181,15 @@ firetray.Window = {
firetray.Handler.gdkWindows.remove(xid);
firetray.PopupMenu.removeWindowItem(xid);
} else {
firetray.ERROR("can't unregister unknown window "+xid);
F.ERROR("can't unregister unknown window "+xid);
return false;
}
firetray.LOG("window "+xid+" unregistered");
F.LOG("window "+xid+" unregistered");
return true;
},
showSingleStateful: function(xid) {
firetray.LOG("showSingleStateful xid="+xid);
F.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) {
firetray.LOG("showSingleStateless");
F.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) {
firetray.LOG("hideSingleStateful");
F.LOG("hideSingleStateful");
firetray.Window.savePositionAndSize(xid);
firetray.Window.saveStates(xid);
@ -237,7 +237,7 @@ firetray.Window = {
* is not accurate.
*/
hideSingleStatelessOnce: function(xid) {
firetray.LOG("hideSingleStateless");
F.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;
firetray.LOG("save: gx="+gx.value+", gy="+gy.value+", gwidth="+gwidth.value+", gheight="+gheight.value);
F.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
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);
F.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;
firetray.LOG("save: windowStates="+winStates);
F.LOG("save: windowStates="+winStates);
},
restoreStates: function(xid) {
let winStates = firetray.Handler.windows[xid].savedStates;
firetray.LOG("restored WindowStates: " + winStates);
F.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;
firetray.LOG("save: windowDesktop="+winDesktop);
F.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);
firetray.LOG("restored to desktop: "+desktopDest);
F.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));
firetray.LOG("window raised");
F.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());
firetray.LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
F.LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
if (!firetray.js.strEquals(res, x11.Success)) {
firetray.ERROR("XGetWindowProperty failed");
F.ERROR("XGetWindowProperty failed");
return [null, null];
}
if (firetray.js.strEquals(actual_type.value, x11.None)) {
firetray.LOG("property not found");
F.LOG("property not found");
return [null, null];
}
firetray.LOG("prop_value="+prop_value+", size="+prop_value.constructor.size);
F.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) {
firetray.ERROR("unsupported format: "+actual_format.value);
F.ERROR("unsupported format: "+actual_format.value);
}
firetray.LOG("format OK");
F.LOG("format OK");
var props = ctypes.cast(prop_value, ctypes.unsigned_long.array(nitems.value).ptr);
firetray.LOG("props="+props+", size="+props.constructor.size);
F.LOG("props="+props+", size="+props.constructor.size);
return [props, nitems];
},
@ -409,12 +409,12 @@ firetray.Window = {
let [propsFound, nitems] =
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_STATE);
firetray.LOG("propsFound, nitems="+propsFound+", "+nitems);
F.LOG("propsFound, nitems="+propsFound+", "+nitems);
if (!propsFound) return 0;
let maximizedHorz = maximizedVert = false;
for (let i=0, len=nitems.value; i<len; ++i) {
firetray.LOG("i: "+propsFound.contents[i]);
F.LOG("i: "+propsFound.contents[i]);
let currentProp = propsFound.contents[i];
if (firetray.js.strEquals(currentProp, x11.current.Atoms['_NET_WM_STATE_HIDDEN']))
winStates |= FIRETRAY_XWINDOW_HIDDEN;
@ -437,11 +437,11 @@ firetray.Window = {
let [propsFound, nitems] =
firetray.Window.getXWindowProperties(xwin, x11.current.Atoms._NET_WM_DESKTOP);
firetray.LOG("DESKTOP propsFound, nitems="+propsFound+", "+nitems);
F.LOG("DESKTOP propsFound, nitems="+propsFound+", "+nitems);
if (!propsFound) return null;
if (firetray.js.strEquals(nitems.value, 0))
firetray.WARN("desktop number not found");
F.WARN("desktop number not found");
else if (firetray.js.strEquals(nitems.value, 1))
desktop = propsFound.contents[0];
else
@ -454,7 +454,7 @@ firetray.Window = {
getWindowTitle: function(xid) {
let title = firetray.Handler.windows[xid].baseWin.title;
firetray.LOG("baseWin.title="+title);
F.LOG("baseWin.title="+title);
let tailIndex = title.indexOf(" - Mozilla "+firetray.Handler.appName);
if (tailIndex !== -1)
return title.substring(0, tailIndex);
@ -475,10 +475,10 @@ firetray.Window = {
switch (xany.contents.type) {
case x11.UnmapNotify:
firetray.LOG("UnmapNotify");
F.LOG("UnmapNotify");
let winStates = firetray.Window.getXWindowStates(xwin);
let isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
firetray.LOG("winStates="+winStates+", isHidden="+isHidden);
F.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:
// firetray.LOG("xany.type="+xany.contents.type);
// F.LOG("xany.type="+xany.contents.type);
break;
}
} catch(x) {
firetray.ERROR(x);
F.ERROR(x);
}
return gdk.GDK_FILTER_CONTINUE;
@ -509,14 +509,14 @@ firetray.Window = {
/** debug facility */
firetray.Handler.dumpWindows = function() {
firetray.LOG(firetray.Handler.windowsCount);
for (let winId in firetray.Handler.windows) firetray.LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
F.LOG(firetray.Handler.windowsCount);
for (let winId in firetray.Handler.windows) F.LOG(winId+"="+firetray.Handler.gtkWindows.get(winId));
};
firetray.Handler.getWindowIdFromChromeWindow = firetray.Window.getXIDFromChromeWindow;
firetray.Handler.registerWindow = function(win) {
firetray.LOG("register window");
F.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;
firetray.LOG("window "+xid+" registered");
F.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);
firetray.ERROR(x);
F.ERROR(x);
return null;
}
@ -566,35 +566,35 @@ firetray.Handler.registerWindow = function(win) {
this.windows[xid].show = firetray.Window.showSingleStateful;
}
firetray.LOG("AFTER"); firetray.Handler.dumpWindows();
F.LOG("AFTER"); firetray.Handler.dumpWindows();
return xid;
};
firetray.Handler.unregisterWindow = function(win) {
firetray.LOG("unregister window");
F.LOG("unregister window");
let xid = firetray.Window.getXIDFromChromeWindow(win);
return firetray.Window.unregisterWindowByXID(xid);
};
firetray.Handler.showSingleWindow = function(xid) {
firetray.LOG("showSingleWindow xid="+xid);
F.LOG("showSingleWindow xid="+xid);
this.windows[xid].show(xid);
};
firetray.Handler.hideSingleWindow = function(xid) {
firetray.LOG("hideSingleWindow xid="+xid);
F.LOG("hideSingleWindow xid="+xid);
this.windows[xid].hide(xid);
};
firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
firetray.LOG("showHideAllWindows: "+userData);
F.LOG("showHideAllWindows: "+userData);
// NOTE: showHideAllWindows being a callback, we need to use
// 'firetray.Handler' explicitely instead of 'this'
firetray.LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
firetray.LOG("windowsCount="+firetray.Handler.windowsCount);
F.LOG("visibleWindowsCount="+firetray.Handler.visibleWindowsCount);
F.LOG("windowsCount="+firetray.Handler.windowsCount);
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
firetray.LOG("visibilityRate="+visibilityRate);
F.LOG("visibilityRate="+visibilityRate);
if ((0.5 < visibilityRate) && (visibilityRate < 1)
|| visibilityRate === 0) // TODO: should be configurable
firetray.Handler.showAllWindows();
@ -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);
firetray.LOG("x11.current.Atoms."+atomName+"="+this.current.Atoms[atomName]);
F.LOG("x11.current.Atoms."+atomName+"="+this.current.Atoms[atomName]);
}, this);
return true;
} catch (x) {
firetray.ERROR(x);
F.ERROR(x);
return false;
}
};

View File

@ -1,9 +1,9 @@
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
var EXPORTED_SYMBOLS = [ "firetray" ];
var EXPORTED_SYMBOLS = [ "F" ];
if ("undefined" == typeof(firetray)) {
var firetray = {};
if ("undefined" == typeof(F)) {
var F = {}; // helper wrapper
};
// about:config extensions.logging.enabled
@ -13,4 +13,4 @@ if ("undefined" == typeof(firetray)) {
LogManager.getLogger("firetray", this);
return this[aName];
});
}, firetray);
}, F);