1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-22 05:48:49 -05:00

extract from StatusIcon to GtkIcons code to share with IMStatusIcon

This commit is contained in:
foudfou 2012-08-04 14:58:58 +02:00
parent b3869630c2
commit a9cc299259
3 changed files with 56 additions and 21 deletions

View File

@ -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);

View File

@ -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);
}
};

View File

@ -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.FILENAME_BLANK = firetray.Utils.chromeToPath(
"chrome://firetray/skin/blank-icon.png");
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);
Cu.import("resource://firetray/linux/FiretrayGtkIcons.jsm");
firetray.GtkIcons.init();
this.loadThemedIcons();
this.trayIcon = gtk.gtk_status_icon_new();
} 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);