[Pkg-mozext-commits] [firetray] 112/399: isolate logging functionality into logging.jsm

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:24 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch dfsg-clean
in repository firetray.

commit f1789077810cd92b358f8e0a52547efae8b1ca1a
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Wed Dec 14 22:00:01 2011 +0100

    isolate logging functionality into logging.jsm
    
    LOG, WARN, ERROR still exported by commons.js for convenience
---
 src/modules/FiretrayIconLinux.jsm |   15 ++++++++-------
 src/modules/commons.js            |   12 +++---------
 src/modules/ctypes-utils.jsm      |   11 ++---------
 src/modules/logging.jsm           |   12 ++++++++++++
 src/modules/x11.jsm               |    2 ++
 5 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/src/modules/FiretrayIconLinux.jsm b/src/modules/FiretrayIconLinux.jsm
index 88ced89..2c0bebc 100644
--- a/src/modules/FiretrayIconLinux.jsm
+++ b/src/modules/FiretrayIconLinux.jsm
@@ -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))
diff --git a/src/modules/commons.js b/src/modules/commons.js
index 27a8ae8..38a7249 100644
--- a/src/modules/commons.js
+++ b/src/modules/commons.js
@@ -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."),
diff --git a/src/modules/ctypes-utils.jsm b/src/modules/ctypes-utils.jsm
index e8a2ea2..4f80b42 100644
--- a/src/modules/ctypes-utils.jsm
+++ b/src/modules/ctypes-utils.jsm
@@ -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 {
diff --git a/src/modules/logging.jsm b/src/modules/logging.jsm
new file mode 100644
index 0000000..d328e28
--- /dev/null
+++ b/src/modules/logging.jsm
@@ -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);
diff --git a/src/modules/x11.jsm b/src/modules/x11.jsm
index 81298df..4b26669 100644
--- a/src/modules/x11.jsm
+++ b/src/modules/x11.jsm
@@ -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__) || \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git



More information about the Pkg-mozext-commits mailing list