1
0
mirror of https://github.com/moparisthebest/FireTray synced 2025-03-11 06:50:18 -04:00

display IM icon when IM enabled

This commit is contained in:
foudfou 2012-08-04 16:29:44 +02:00
parent 6f95421a2f
commit ceba669bcd
14 changed files with 77 additions and 3 deletions

View File

@ -89,4 +89,4 @@ Acknowledgment
[Nils Maier](https://addons.mozilla.org/fr/firefox/addon/minimizetotray-revived/
"MinToTrayR addon page").
* kind support from Neil Deaking, Bobby Holley
* default icons borrowed from Mozilla and Pidgin

View File

@ -0,0 +1 @@
../../../../../pidgin-tray-available.png

View File

@ -0,0 +1 @@
../../../../../pidgin-tray-away.png

View File

@ -0,0 +1 @@
../../../../../pidgin-tray-busy.png

View File

@ -0,0 +1 @@
../../../../../pidgin-tray-offline.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -7,6 +7,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://firetray/commons.js");
Cu.import("resource://firetray/linux/FiretrayIMStatusIcon.jsm");
firetray.InstantMessaging = {
initialized: false,
@ -26,6 +27,8 @@ firetray.InstantMessaging = {
"visited-status-resolution"
]);
firetray.IMStatusIcon.init();
this.initialized = true;
},
@ -33,6 +36,8 @@ firetray.InstantMessaging = {
if (!this.initialized) return;
F.LOG("Disabling InstantMessaging");
firetray.IMStatusIcon.shutdown();
firetray.Utils.removeAllObservers(firetray.InstantMessaging);
this.initialized = false;

View File

@ -54,10 +54,8 @@ firetray.Messaging = {
F.LOG("Disabling Messaging");
firetray.InstantMessaging.shutdown();
F.LOG("HI THERE");
MailServices.mailSession.RemoveFolderListener(this.mailSessionListener);
firetray.Handler.setIconImageDefault();
firetray.Utils.removeAllObservers(firetray.Messaging);

View File

@ -16,6 +16,7 @@ function gio_defines(lib) {
this.GIcon = ctypes.StructType("GIcon");
this.GThemedIcon = ctypes.StructType("GThemedIcon");
lib.lazy_bind("g_themed_icon_new", this.GIcon.ptr, ctypes.char.ptr);
lib.lazy_bind("g_themed_icon_new_from_names", this.GIcon.ptr, ctypes.char.ptr.ptr, ctypes.int);
}

View File

@ -0,0 +1,65 @@
/* -*- 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://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
Cu.import("resource://firetray/ctypes/linux/gio.jsm");
Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
Cu.import("resource://firetray/commons.js");
if ("undefined" == typeof(firetray.Handler))
F.ERROR("This module MUST be imported from/after FiretrayHandler !");
firetray.IMStatusIcon = {
GTK_THEME_ICON_PATH: null,
initialized: false,
trayIcon: null,
themedIcons: {
"user-available": null,
"user-away": null,
"user-busy": null,
"user-offline": null
},
init: function() {
if (!firetray.Handler.inMailApp) throw "IMStatusIcon for mail app only";
if (!firetray.GtkIcons.initialized) throw "GtkIcons should have been initialized by StatusIcon";
this.trayIcon = gtk.gtk_status_icon_new();
this.loadThemedIcons();
this.setIconImageFromGIcon(this.themedIcons["user-offline"]);
this.initialized = true;
return true;
},
shutdown: function() {
gtk.gtk_status_icon_set_visible(this.trayIcon, false);
// FIXME: tryCloseLibs should be done by Handler only, submodules should
// just pass the imported ctypes modules to it
// firetray.Utils.tryCloseLibs([gobject, gio, gtk]);
this.initialized = false;
},
loadThemedIcons: function() {
for (let name in this.themedIcons)
this.themedIcons[name] = gio.g_themed_icon_new(name);
},
setIconImageFromGIcon: function(gicon) {
if (!firetray.IMStatusIcon.trayIcon || !gicon)
F.ERROR("Icon missing");
F.LOG(gicon);
gtk.gtk_status_icon_set_from_gicon(firetray.IMStatusIcon.trayIcon, gicon);
}
}; // firetray.IMStatusIcon

View File

@ -61,6 +61,7 @@ firetray.StatusIcon = {
shutdown: function() {
F.LOG("Disabling StatusIcon");
firetray.PopupMenu.shutdown();
// FIXME: should destroy/hide icon here
firetray.GtkIcons.shutdown();
firetray.Utils.tryCloseLibs([cairo, gobject, gdk, gio, gtk, pango, pangocairo]);
this.initialized = false;