1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-17 14:25:01 -05:00

isolate logging functionality into logging.jsm

LOG, WARN, ERROR still exported by commons.js for convenience
This commit is contained in:
foudfou 2011-12-14 22:00:01 +01:00
parent c00d69b1ad
commit f178907781
5 changed files with 27 additions and 25 deletions

View File

@ -160,7 +160,7 @@ firetray.IconLinux = {
* @param window nsIDOMWindow from Services.wm
* @return a gtk.GtkWindow.ptr
*/
_getGtkWindowHandle: function(window) {
getGtkWindowHandle: function(window) {
let baseWindow = window
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
@ -223,7 +223,7 @@ firetray.IconLinux = {
}
},
_getGdkWindowFromGtkWindow: function(gtkWin) {
getGdkWindowFromGtkWindow: function(gtkWin) {
try {
let gtkWid = ctypes.cast(gtkWin, gtk.GtkWidget.ptr);
var gdkWin = gtk.gtk_widget_get_window(gtkWid);
@ -235,9 +235,9 @@ firetray.IconLinux = {
getGdkWindowHandle: function(win) {
try {
let gtkWin = firetray.IconLinux._getGtkWindowHandle(win);
let gtkWin = firetray.IconLinux.getGtkWindowHandle(win);
LOG("FOUND: "+gtk.gtk_window_get_title(gtkWin).readString());
let gdkWin = this._getGdkWindowFromGtkWindow(gtkWin);
let gdkWin = this.getGdkWindowFromGtkWindow(gtkWin);
if (!gdkWin.isNull()) {
LOG("has window");
return gdkWin;
@ -335,7 +335,6 @@ firetray.IconLinux = {
}; // firetray.IconLinux
firetray.Handler.setImage = function(filename) {
if (!firetray.IconLinux.trayIcon)
return false;
@ -486,8 +485,10 @@ firetray.Handler.setText = function(text, color) { // TODO: split into smaller f
/**
* init X11 Display and handled XATOMS. needs to be defined and called outside
* x11.jsm because gdk already import x11.
* init X11 Display and handled XAtoms.
* Needs to be defined and called outside x11.jsm because: gdk already import
* x11, and there is no means to get the default Display solely with Xlib
* without opening one... :-(
*/
x11.init = function() {
if (!isEmpty(this.current))

View File

@ -1,5 +1,7 @@
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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", "isArray", "isEmpty", "strEquals",
@ -11,6 +13,7 @@ const Ci = Components.interfaces;
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}";
@ -31,15 +34,6 @@ if ("undefined" == typeof(firetray)) {
var firetray = {};
};
// about:config extensions.logging.enabled
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function() {
Components.utils.import("resource://gre/modules/AddonLogging.jsm");
LogManager.getLogger("firetray", this);
return this[aName];
});
}, this);
firetray.Utils = {
prefService: Services.prefs.getBranch("extensions.firetray."),

View File

@ -40,16 +40,9 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://firetray/logging.jsm");
var EXPORTED_SYMBOLS = [ "ctypes_library", "ERROR" ];
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function() {
Components.utils.import("resource://gre/modules/AddonLogging.jsm");
LogManager.getLogger("firetray", this);
return this[aName];
});
}, this);
var EXPORTED_SYMBOLS = [ "ctypes_library" ];
function ctypes_library(name, abis, defines) {
try {

12
src/modules/logging.jsm Normal file
View File

@ -0,0 +1,12 @@
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
var EXPORTED_SYMBOLS = ["LOG", "WARN", "ERROR"];
// about:config extensions.logging.enabled
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function() {
Components.utils.import("resource://gre/modules/AddonLogging.jsm");
LogManager.getLogger("firetray", this);
return this[aName];
});
}, this);

View File

@ -16,6 +16,7 @@ const Ci = Components.interfaces;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://firetray/ctypes-utils.jsm");
Cu.import("resource://firetray/logging.jsm");
const XATOMS_ICCCM = [ "WM_DELETE_WINDOW", "WM_STATE", "WM_CHANGE_STATE" ];
const XATOMS_EWMH_GENERAL = [ "_NET_CLOSE_WINDOW", "_NET_WM_NAME",
@ -119,6 +120,7 @@ if (!x11) {
var x11 = new ctypes_library(X11_LIBNAME, X11_ABIS, x11_defines);
}
/* Xorg 1.10.4
#if defined (_LP64) || \
defined(__alpha) || defined(__alpha__) || \