[Pkg-mozext-commits] [firetray] 269/399: extract from StatusIcon to GtkIcons code to share with IMStatusIcon

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:56 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 a9cc29925966539fbb9f54d29bcbd767a885f711
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Sat Aug 4 14:58:58 2012 +0200

    extract from StatusIcon to GtkIcons code to share with IMStatusIcon
---
 src/modules/FiretrayHandler.jsm          |    4 ---
 src/modules/linux/FiretrayGtkIcons.jsm   |   45 ++++++++++++++++++++++++++++++
 src/modules/linux/FiretrayStatusIcon.jsm |   28 ++++++++-----------
 3 files changed, 56 insertions(+), 21 deletions(-)

diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index d89cec8..63bfcfc 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -27,7 +27,6 @@ if ("undefined" == typeof(firetray)) {
 // other global functions
 // (https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management)
 firetray.Handler = {
-  FILENAME_BLANK: null,
 
   initialized: false,
   inMailApp: false,
@@ -78,9 +77,6 @@ firetray.Handler = {
 
     this.appStartupTopic = this.getAppStartupTopic(this.appId);
 
-    this.FILENAME_BLANK = firetray.Utils.chromeToPath(
-      "chrome://firetray/skin/blank-icon.png");
-
     VersionChange.init(FIRETRAY_ID, FIRETRAY_VERSION, FIRETRAY_PREF_BRANCH);
     VersionChange.addHook(["install", "upgrade", "reinstall"], firetray.VersionChangeHandler.showReleaseNotes);
     VersionChange.addHook(["upgrade", "reinstall"], firetray.VersionChangeHandler.tryEraseOldOptions);
diff --git a/src/modules/linux/FiretrayGtkIcons.jsm b/src/modules/linux/FiretrayGtkIcons.jsm
new file mode 100644
index 0000000..5979f2a
--- /dev/null
+++ b/src/modules/linux/FiretrayGtkIcons.jsm
@@ -0,0 +1,45 @@
+/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+var EXPORTED_SYMBOLS = [ "firetray" ];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
+Cu.import("resource://firetray/commons.js");
+
+if ("undefined" == typeof(firetray.StatusIcon))
+  F.ERROR("This module MUST be imported from/after StatusIcon !");
+
+
+firetray.GtkIcons = {
+  initialized: false,
+
+  GTK_THEME_ICON_PATH: null,
+
+  init: function() {
+    try {
+      this.loadDefaultTheme();
+      this.initialized = true;
+      return true;
+    } catch (x) {
+      F.ERROR(x);
+      return false;
+    }
+  },
+
+  shutdown: function() {
+    firetray.Utils.tryCloseLibs([gtk]);
+    this.initialized = false;
+  },
+
+  loadDefaultTheme: function() {
+    this.GTK_THEME_ICON_PATH = firetray.Utils.chromeToPath("chrome://firetray/skin/linux/icons");
+    F.LOG(this.GTK_THEME_ICON_PATH);
+    let gtkIconTheme = gtk.gtk_icon_theme_get_default();
+    F.LOG("gtkIconTheme="+gtkIconTheme);
+    gtk.gtk_icon_theme_append_search_path(gtkIconTheme, this.GTK_THEME_ICON_PATH);
+  }
+
+};
diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm
index 84b0710..24727e6 100644
--- a/src/modules/linux/FiretrayStatusIcon.jsm
+++ b/src/modules/linux/FiretrayStatusIcon.jsm
@@ -23,7 +23,7 @@ if ("undefined" == typeof(firetray.Handler))
 
 
 firetray.StatusIcon = {
-  GTK_THEME_ICON_PATH: null,
+  FILENAME_BLANK: null,
 
   initialized: false,
   callbacks: {}, // pointers to JS functions. MUST LIVE DURING ALL THE EXECUTION
@@ -36,26 +36,18 @@ firetray.StatusIcon = {
   defaultNewMailIconName: null,
 
   init: function() {
-    this.defineIconNames();
-
-    try {
-      this.GTK_THEME_ICON_PATH = firetray.Utils.chromeToPath("chrome://firetray/skin/linux/icons");
-      F.LOG(this.GTK_THEME_ICON_PATH);
-      let gtkIconTheme = gtk.gtk_icon_theme_get_default();
-      F.LOG("gtkIconTheme="+gtkIconTheme);
-      gtk.gtk_icon_theme_append_search_path(gtkIconTheme, this.GTK_THEME_ICON_PATH);
+    this.FILENAME_BLANK = firetray.Utils.chromeToPath(
+      "chrome://firetray/skin/blank-icon.png");
 
-      this.loadThemedIcons();
+    this.defineIconNames();
 
-      this.trayIcon  = gtk.gtk_status_icon_new();
+    Cu.import("resource://firetray/linux/FiretrayGtkIcons.jsm");
+    firetray.GtkIcons.init();
 
-    } catch (x) {
-      F.ERROR(x);
-      return false;
-    }
+    this.loadThemedIcons();
+    this.trayIcon = gtk.gtk_status_icon_new();
 
     firetray.Handler.setIconImageDefault();
-
     firetray.Handler.setIconTooltipDefault();
 
     Cu.import("resource://firetray/linux/FiretrayPopupMenu.jsm");
@@ -70,6 +62,7 @@ firetray.StatusIcon = {
 
   shutdown: function() {
     firetray.PopupMenu.shutdown();
+    firetray.GtkIcons.shutdown();
     firetray.Utils.tryCloseLibs([cairo, gobject, gdk, gio, gtk, pango, pangocairo]);
     this.initialized = false;
   },
@@ -243,7 +236,8 @@ firetray.Handler.setIconText = function(text, color) { // FIXME: function too lo
 
   try {
     // build background from image
-    let specialIcon = gdk.gdk_pixbuf_new_from_file(this.FILENAME_BLANK, null); // GError **error);
+    let specialIcon = gdk.gdk_pixbuf_new_from_file(
+      firetray.StatusIcon.FILENAME_BLANK, null); // GError **error);
     let dest = gdk.gdk_pixbuf_copy(specialIcon);
     let w = gdk.gdk_pixbuf_get_width(specialIcon);
     let h = gdk.gdk_pixbuf_get_height(specialIcon);

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