[Pkg-mozext-commits] [firetray] 01/22: * Linux: add debug for icon theme search path. * Logging: fix superfluous newline, and expose Log module.

David Prévot taffit at moszumanska.debian.org
Wed Dec 31 17:04:37 UTC 2014


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

taffit pushed a commit to branch master
in repository firetray.

commit a0c0061cd680a3a92b820969b093cc4780dfb10c
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Mon Nov 10 15:06:49 2014 +0100

    * Linux: add debug for icon theme search path.
    * Logging: fix superfluous newline, and expose Log module.
    
    The additional newline was introduced by Log.jsm in FF32 (see
    https://bugzilla.mozilla.org/show_bug.cgi?id=966674).
---
 src/modules/ctypes/linux/glib.jsm      |  2 ++
 src/modules/ctypes/linux/gtk.jsm       |  1 +
 src/modules/linux/FiretrayGtkIcons.jsm | 17 +++++++++++++++++
 src/modules/log4moz.js                 |  4 ++--
 src/modules/logging.jsm                | 26 +++++++++++++-------------
 5 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/src/modules/ctypes/linux/glib.jsm b/src/modules/ctypes/linux/glib.jsm
index a411d4a..e1d5d71 100644
--- a/src/modules/ctypes/linux/glib.jsm
+++ b/src/modules/ctypes/linux/glib.jsm
@@ -16,6 +16,8 @@ function glib_defines(lib) {
   /* mutual inclusion not possible */
   this.GQuark = ctypes.uint32_t; // this.GQuark = gobject.guint32;
   this.GError = ctypes.StructType("GError");
+
+  lib.lazy_bind("g_strfreev", ctypes.void_t, ctypes.char.ptr.ptr);
 };
 
 new ctypes_library(GLIB_LIBNAME, GLIB_ABIS, glib_defines, this);
diff --git a/src/modules/ctypes/linux/gtk.jsm b/src/modules/ctypes/linux/gtk.jsm
index fc70953..95c84b6 100644
--- a/src/modules/ctypes/linux/gtk.jsm
+++ b/src/modules/ctypes/linux/gtk.jsm
@@ -101,6 +101,7 @@ function gtk_defines(lib) {
 
   lib.lazy_bind("gtk_icon_theme_get_default", this.GtkIconTheme.ptr);
   lib.lazy_bind("gtk_icon_theme_get_for_screen", this.GtkIconTheme.ptr, gdk.GdkScreen.ptr);
+  lib.lazy_bind("gtk_icon_theme_get_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr.ptr.array(), gobject.gint.ptr);
   lib.lazy_bind("gtk_icon_theme_append_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
   lib.lazy_bind("gtk_icon_theme_prepend_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
   lib.lazy_bind("gtk_icon_theme_choose_icon", this.GtkIconInfo.ptr, this.GtkIconTheme.ptr, gobject.gchar.ptr.array(), gobject.gint, this.GtkIconLookupFlags);
diff --git a/src/modules/linux/FiretrayGtkIcons.jsm b/src/modules/linux/FiretrayGtkIcons.jsm
index 6b9af1c..33fdec8 100644
--- a/src/modules/linux/FiretrayGtkIcons.jsm
+++ b/src/modules/linux/FiretrayGtkIcons.jsm
@@ -44,6 +44,23 @@ firetray.GtkIcons = {
     let gtkIconTheme = gtk.gtk_icon_theme_get_default();
     log.debug("gtkIconTheme="+gtkIconTheme);
     gtk.gtk_icon_theme_append_search_path(gtkIconTheme, this.GTK_THEME_ICON_PATH);
+
+    if (log.level <= firetray.Logging.LogMod.Level.Debug) {
+      Cu.import("resource://firetray/ctypes/linux/glib.jsm");
+      Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
+      firetray.Handler.subscribeLibsForClosing([glib, gobject]);
+      let path = new gobject.gchar.ptr.ptr;
+      let n_elements = new gobject.gint;
+      gtk.gtk_icon_theme_get_search_path(gtkIconTheme, path.address(), n_elements.address());
+      log.debug("n_elements="+n_elements+" path="+path);
+      let pathIt = path;
+      for (let i=0, len=n_elements.value; i<len || pathIt.isNull(); ++i) {
+        log.debug("path["+i+"]="+pathIt.contents.readString());
+        pathIt = pathIt.increment();
+      }
+      log.debug("path="+path+" pathIt="+pathIt);
+      glib.g_strfreev(path);
+    }
   }
 
 };
diff --git a/src/modules/log4moz.js b/src/modules/log4moz.js
index 462f806..674e240 100644
--- a/src/modules/log4moz.js
+++ b/src/modules/log4moz.js
@@ -335,7 +335,7 @@ BasicFormatter.prototype = Object.create(Formatter.prototype);
 BasicFormatter.prototype.constructor = BasicFormatter;
 BasicFormatter.prototype.format = function BF_format(message) {
   return message.time + "\t" + message.loggerName + "\t" + message.levelDesc
-    + "\t" + message.message + "\n";
+    + "\t" + message.message;
 };
 
 /*
@@ -373,7 +373,7 @@ function DumpAppender(formatter) {
 DumpAppender.prototype = Object.create(Appender.prototype);
 DumpAppender.prototype.constructor = DumpAppender;
 DumpAppender.prototype.doAppend = function DApp_doAppend(message) {
-  dump(message);
+  dump(message + "\n");
 };
 
 /*
diff --git a/src/modules/logging.jsm b/src/modules/logging.jsm
index f4f1b83..3a83a97 100644
--- a/src/modules/logging.jsm
+++ b/src/modules/logging.jsm
@@ -47,11 +47,11 @@ var colorTermLogColors = {
 if ("undefined" == typeof(firetray)) {
   var firetray = {};
 };
-var LogMod;
 
 // https://wiki.mozilla.org/Labs/JS_Modules#Logging
 firetray.Logging = {
   initialized: false,
+  LogMod: null,
 
   init: function() {
     if (this.initialized) return;
@@ -65,9 +65,9 @@ firetray.Logging = {
       }, this);
 
     if ("undefined" != typeof(Log)) {
-      LogMod = Log;
+      this.LogMod = Log;
     } else if ("undefined" != typeof(Log4Moz)) {
-      LogMod = Log4Moz;
+      this.LogMod = Log4Moz;
     } else {
       let errMsg = "Log module not found";
       dump(errMsg+"\n");
@@ -85,8 +85,8 @@ firetray.Logging = {
   setupLogging: function(loggerName) {
 
     // lifted from log4moz.js
-    function SimpleFormatter() {LogMod.Formatter.call(this);}
-    SimpleFormatter.prototype = Object.create(LogMod.Formatter.prototype);
+    function SimpleFormatter() {firetray.Logging.LogMod.Formatter.call(this);}
+    SimpleFormatter.prototype = Object.create(firetray.Logging.LogMod.Formatter.prototype);
     SimpleFormatter.prototype.constructor = SimpleFormatter;
     SimpleFormatter.prototype.format = function(message) {
       let messageString = "";
@@ -104,7 +104,7 @@ firetray.Logging = {
             date.getSeconds() + "." + date.getMilliseconds();
       let stringLog = dateStr + " " +
             message.levelDesc + " " + message.loggerName + " " +
-            messageString + "\n";
+            messageString;
 
       if (message.exception)
         stringLog += message.stackTrace + "\n";
@@ -124,14 +124,14 @@ firetray.Logging = {
     };
 
     // Loggers are hierarchical, affiliation is handled by a '.' in the name.
-    this._logger = LogMod.repository.getLogger(loggerName);
+    this._logger = this.LogMod.repository.getLogger(loggerName);
     // Lowering this log level will affect all of our addon output
-    this._logger.level = LogMod.Level[FIRETRAY_LOG_LEVEL];
+    this._logger.level = this.LogMod.Level[FIRETRAY_LOG_LEVEL];
 
     // A console appender outputs to the JS Error Console
     let simpleFormatter = new SimpleFormatter();
-    let capp = new LogMod.ConsoleAppender(simpleFormatter);
-    capp.level = LogMod.Level["Debug"];
+    let capp = new this.LogMod.ConsoleAppender(simpleFormatter);
+    capp.level = this.LogMod.Level["Debug"];
     this._logger.addAppender(capp);
 
     // A dump appender outputs to standard out
@@ -141,13 +141,13 @@ firetray.Logging = {
     } else {
       dumpFormatter = new SimpleFormatter();
     }
-    let dapp = new LogMod.DumpAppender(dumpFormatter);
-    dapp.level = LogMod.Level["Debug"];
+    let dapp = new this.LogMod.DumpAppender(dumpFormatter);
+    dapp.level = this.LogMod.Level["Debug"];
     this._logger.addAppender(dapp);
   },
 
   getLogger: function(loggerName){
-    return LogMod.repository.getLogger(loggerName);
+    return this.LogMod.repository.getLogger(loggerName);
   }
 
 };                              // firetray.Logging

-- 
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