[Pkg-mozext-commits] [firetray] 18/399: Revert "new version of LibGtkStatusIcon.js with XPCOMUtils.defineLazyGetter()"

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:06 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 890c4579c349ba9826cef1bbcc7d6fa4497c1d72
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Wed Aug 3 15:48:56 2011 +0200

    Revert "new version of LibGtkStatusIcon.js with XPCOMUtils.defineLazyGetter()"
    
    This reverts commit d85edced00fd09b71500cd33978b3cc28fe4ac6a.
    
    First, it'll be easier to merge with hide/show feature. Then we prefer to keep
    2 examples of js-ctypes libs: we still aren't clear about when/how to call
    lib.close()...
---
 src/chrome/content/overlay.js   |    7 ++-
 src/modules/LibGtkStatusIcon.js |  116 ++++++++++++++++++---------------------
 2 files changed, 57 insertions(+), 66 deletions(-)

diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js
index c2baeba..a58b7a1 100644
--- a/src/chrome/content/overlay.js
+++ b/src/chrome/content/overlay.js
@@ -23,14 +23,15 @@ mozt.Main = {
       return false;
     }
 
+    LibGtkStatusIcon.init();
     this.tray_icon  = LibGtkStatusIcon.gtk_status_icon_new();
     var mozApp = mozt.Utils.appInfoService.name;
     var icon_filename = MOZT_ICON_DIR + mozApp.toLowerCase() + MOZT_ICON_SUFFIX;
     LibGtkStatusIcon.gtk_status_icon_set_from_file(this.tray_icon,
                                                    icon_filename);
-    // FIXME: hover on icno produces:
-    // (firefox-bin:5302): Gdk-CRITICAL **: IA__gdk_window_get_root_coords:
-    // assertion `GDK_IS_WINDOW (window)' failed
+    // TODO: produces:
+    // (firefox-bin:5302): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
+    // (thunderbird-bin:5380): Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
     LibGtkStatusIcon.gtk_status_icon_set_tooltip_text(this.tray_icon,
                                                       mozApp);
 
diff --git a/src/modules/LibGtkStatusIcon.js b/src/modules/LibGtkStatusIcon.js
index d64a1e8..6e0c74d 100644
--- a/src/modules/LibGtkStatusIcon.js
+++ b/src/modules/LibGtkStatusIcon.js
@@ -2,91 +2,81 @@
 
 var EXPORTED_SYMBOLS = ["LibGtkStatusIcon"];
 
-const LIB_GTK = "libgtk-x11-2.0.so";
-
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
-Cu.import("resource://gre/modules/ctypes.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+const LIB_GTK = "libgtk-x11-2.0.so";
+
+var LibGtkStatusIcon = {
+
+  _lib: null,
 
-XPCOMUtils.defineLazyGetter(this, "libgtk", function() {
-  var libgtk = ctypes.open(LIB_GTK);
-  if (!libgtk)
-    throw "libgtk is unavailable";
+  init: function() {
+    // If ctypes doesn't exist, try to get it
+    Cu.import("resource://gre/modules/ctypes.jsm");
+      // If we still don't have ctypes, this isn't going to work...
+    if (typeof(ctypes) == "undefined") {
+      throw ("Could not load JS-Ctypes");
+    }
 
-  return libgtk;
-});
+    try {
+      // Try to start up dependencies - if they fail, they'll throw
+      // exceptions. ex: GObjectLib.init();
+
+      this._lib = ctypes.open(LIB_GTK);
+      if (!this._lib)
+        throw ("Could not load " + LIB_GTK);
+
+    } catch (e) {
+      this.shutdown();
+      throw(e);
+    }
+
+    // Ok, we got everything - let's declare.
+    this._declare();
+  },
+
+  shutdown: function() {
+    // Close our connection to the library.
+    if (this._lib)
+      this._lib.close();
+  },
 
-// Types
-XPCOMUtils.defineLazyGetter(this, "GtkStatusIcon", function() {
-  return ctypes.StructType("GtkStatusIcon");
-});
+  _declare: function() {
+    // Types
+    this.GtkStatusIcon = ctypes.StructType("GtkStatusIcon");
+    this.GtkStatusIconRef = ctypes.PointerType(this.GtkStatusIcon);
+    this.GdkPixbuf = ctypes.StructType("GdkPixbuf");
+    this.GdkPixbufRef = ctypes.PointerType(this.GdkPixbuf);
 
-// Functions
-XPCOMUtils.defineLazyGetter(this, "gtk_status_icon_new", function() {
-  var gtk_status_icon_new = libgtk.declare(
-    "gtk_status_icon_new",
-    ctypes.default_abi,
-    this.GtkStatusIcon.ptr
-  );
+    // Consts
+    // this.INDICATOR_MESSAGES_SERVER_TYPE = "message";
 
-  if (!gtk_status_icon_new)
-    throw "gtk_status_icon_new is unavailable";
+    // Functions
 
-  return gtk_status_icon_new;
-});
+    this.gtk_status_icon_new = this._lib.declare(
+      "gtk_status_icon_new",
+      ctypes.default_abi,
+      this.GtkStatusIconRef
+    );
 
-XPCOMUtils.defineLazyGetter(this, "gtk_status_icon_set_from_file", function() {
-    var gtk_status_icon_set_from_file = libgtk.declare(
+    this.gtk_status_icon_set_from_file = this._lib.declare(
       "gtk_status_icon_set_from_file",
       ctypes.default_abi,
       ctypes.void_t,
-      this.GtkStatusIcon.ptr,
+      this.GtkStatusIconRef,
       ctypes.char.ptr
     );
 
-  if (!gtk_status_icon_new)
-    throw "gtk_status_icon_set_from_file is unavailable";
-
-  return gtk_status_icon_set_from_file;
-});
-
-XPCOMUtils.defineLazyGetter(this, "gtk_status_icon_set_tooltip_text", function() {
-    var gtk_status_icon_set_tooltip_text = libgtk.declare(
+    this.gtk_status_icon_set_tooltip_text = this._lib.declare(
       "gtk_status_icon_set_tooltip_text",
       ctypes.default_abi,
       ctypes.void_t,
-      this.GtkStatusIcon.ptr,
+      this.GtkStatusIconRef,
       ctypes.char.ptr
     );
 
-  if (!gtk_status_icon_set_tooltip_text)
-    throw "gtk_status_icon_set_tooltip_text is unavailable";
-
-  return gtk_status_icon_set_tooltip_text;
-});
-
-var LibGtkStatusIcon = {
-  /*
-   * FIXME: for now, we manually close the lib, but m_conley said: well, the
-   * first idea that comes to mind is to add an "unload" or "shutdown" function
-   * to the main MessagingMenu object that listens for an xpcom shutdown event,
-   * and then unloads the library
-   */
-  shutdown: function() {
-    if (libgtk) libgtk.close();
-  },
-
-  // Types
-  GtkStatusIcon: GtkStatusIcon,
-
-  // Constants
-  // INDICATOR_MESSAGES_SERVER_TYPE: "message",
+  }
 
-  // Functions
-  gtk_status_icon_new: gtk_status_icon_new,
-  gtk_status_icon_set_from_file: gtk_status_icon_set_from_file,
-  gtk_status_icon_set_tooltip_text: gtk_status_icon_set_tooltip_text,
 };

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