mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-06 11:08:04 -05:00
Minor refactoring.
This commit is contained in:
parent
0dc0cc34b3
commit
f2acc43dce
@ -201,6 +201,14 @@ firetray.Handler = {
|
||||
return this.appHasChat && Services.prefs.getBoolPref("mail.chat.enabled");
|
||||
},
|
||||
|
||||
subscribeLibsForClosing: function(libs) {
|
||||
for (let i=0, len=libs.length; i<len; ++i) {
|
||||
let lib = libs[i];
|
||||
if (!this.ctypesLibs.hasOwnProperty(lib.name))
|
||||
this.ctypesLibs[lib.name] = lib;
|
||||
}
|
||||
},
|
||||
|
||||
tryCloseLibs: function() {
|
||||
try {
|
||||
for (let libName in this.ctypesLibs) {
|
||||
@ -211,14 +219,6 @@ firetray.Handler = {
|
||||
} catch(x) { log.error(x); }
|
||||
},
|
||||
|
||||
subscribeLibsForClosing: function(libs) {
|
||||
for (let i=0, len=libs.length; i<len; ++i) {
|
||||
let lib = libs[i];
|
||||
if (!this.ctypesLibs.hasOwnProperty(lib.name))
|
||||
this.ctypesLibs[lib.name] = lib;
|
||||
}
|
||||
},
|
||||
|
||||
readTBRestoreWindowsCount: function() {
|
||||
Cu.import("resource:///modules/IOUtils.js");
|
||||
let sessionFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
|
@ -15,8 +15,8 @@ var EXPORTED_SYMBOLS =
|
||||
"FIRETRAY_ACCOUNT_SERVER_TYPE_IM", "FIRETRAY_DELAY_STARTUP_MILLISECONDS",
|
||||
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
|
||||
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW", "FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
|
||||
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE", "FIRETRAY_APP_DB",
|
||||
"FIRETRAY_CB_SENTINEL" ];
|
||||
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE", "FIRETRAY_APPINDICATOR_ID",
|
||||
"FIRETRAY_APP_DB", "FIRETRAY_CB_SENTINEL" ];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
@ -56,6 +56,8 @@ const FIRETRAY_DELAY_NOWAIT_MILLISECONDS = 0;
|
||||
const FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL = 0;
|
||||
const FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE = 1;
|
||||
|
||||
const FIRETRAY_APPINDICATOR_ID = "firetray";
|
||||
|
||||
const FIRETRAY_APP_DB = {
|
||||
|
||||
firefox: {
|
||||
|
@ -39,6 +39,7 @@ firetray.StatusIcon = {
|
||||
prefNewMailIconNames: null,
|
||||
defaultAppIconName: null,
|
||||
defaultNewMailIconName: null,
|
||||
inidicator: null,
|
||||
|
||||
init: function() {
|
||||
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
||||
@ -49,43 +50,24 @@ firetray.StatusIcon = {
|
||||
this.defineIconNames();
|
||||
this.loadThemedIcons();
|
||||
|
||||
this.trayIcon = gtk.gtk_status_icon_new();
|
||||
firetray.Handler.setIconImageDefault();
|
||||
firetray.Handler.setIconTooltipDefault();
|
||||
|
||||
Cu.import("resource://firetray/linux/FiretrayPopupMenu.jsm");
|
||||
if (!firetray.PopupMenu.init())
|
||||
return false;
|
||||
|
||||
this.addCallbacks();
|
||||
|
||||
Cu.import("resource://firetray/ctypes/linux/appindicator.jsm");
|
||||
if (appind3.available() && this.isNotificationWatcherReady()) {
|
||||
this.indicator = appind3.app_indicator_new(
|
||||
'FOUDIL',
|
||||
'firefox',
|
||||
appind3.APP_INDICATOR_CATEGORY_APPLICATION_STATUS
|
||||
);
|
||||
appind3.app_indicator_set_status(this.indicator, appind3.APP_INDICATOR_STATUS_ACTIVE);
|
||||
appind3.app_indicator_set_menu(this.indicator, firetray.PopupMenu.menu); // mandatory
|
||||
log.warn("indicator="+this.indicator);
|
||||
/*
|
||||
let gval = new gobject.gboolean;
|
||||
gobject.g_object_get(
|
||||
ctypes.cast(this.indicator, gobject.gpointer),
|
||||
"connected",
|
||||
gval.address(),
|
||||
ctypes.voidptr_t(null)
|
||||
);
|
||||
log.warn("gval="+gval+" true? "+!firetray.js.strEquals(gval, gobject.FALSE));
|
||||
*/
|
||||
this.callbacks.indicator = appind3.AppIndicatorConnectionChangedCb_t(
|
||||
firetray.StatusIcon.onAppIndicatorConnectionChanged); // void return, no sentinel
|
||||
gobject.g_signal_connect(this.indicator, "connection-changed",
|
||||
firetray.StatusIcon.callbacks.indicator, null);
|
||||
log.warn("status="+appind3.app_indicator_get_status(this.indicator));
|
||||
if (appind3.available() && this.dbusNotificationWatcherReady()) {
|
||||
firetray.Handler.subscribeLibsForClosing([appind3]);
|
||||
// FIXME: we may want to split into 2 separate modules: GtkStatusIcon and
|
||||
// AppIndicator.
|
||||
this.indicatorInit();
|
||||
}
|
||||
|
||||
this.trayIcon = gtk.gtk_status_icon_new();
|
||||
firetray.Handler.setIconImageDefault();
|
||||
firetray.Handler.setIconTooltipDefault();
|
||||
|
||||
this.addCallbacks();
|
||||
|
||||
this.initialized = true;
|
||||
return true;
|
||||
},
|
||||
@ -98,6 +80,32 @@ firetray.StatusIcon = {
|
||||
this.initialized = false;
|
||||
},
|
||||
|
||||
indicatorInit: function() {
|
||||
this.indicator = appind3.app_indicator_new(
|
||||
FIRETRAY_APPINDICATOR_ID,
|
||||
'firefox',
|
||||
appind3.APP_INDICATOR_CATEGORY_COMMUNICATIONS
|
||||
);
|
||||
appind3.app_indicator_set_status(this.indicator, appind3.APP_INDICATOR_STATUS_ACTIVE);
|
||||
appind3.app_indicator_set_menu(this.indicator, firetray.PopupMenu.menu); // mandatory
|
||||
log.warn("indicator="+this.indicator);
|
||||
/*
|
||||
let gval = new gobject.gboolean;
|
||||
gobject.g_object_get(
|
||||
ctypes.cast(this.indicator, gobject.gpointer),
|
||||
"connected",
|
||||
gval.address(),
|
||||
ctypes.voidptr_t(null)
|
||||
);
|
||||
log.warn("gval="+gval+" true? "+!firetray.js.strEquals(gval, gobject.FALSE));
|
||||
*/
|
||||
this.callbacks.indicator = appind3.AppIndicatorConnectionChangedCb_t(
|
||||
firetray.StatusIcon.onAppIndicatorConnectionChanged); // void return, no sentinel
|
||||
gobject.g_signal_connect(this.indicator, "connection-changed",
|
||||
firetray.StatusIcon.callbacks.indicator, null);
|
||||
log.warn("status="+appind3.app_indicator_get_status(this.indicator));
|
||||
},
|
||||
|
||||
defineIconNames: function() {
|
||||
this.prefAppIconNames = (function() {
|
||||
if (firetray.Handler.inMailApp) {
|
||||
@ -235,7 +243,7 @@ firetray.StatusIcon = {
|
||||
log.warn("AppIndicator connection-changed: "+connected);
|
||||
},
|
||||
|
||||
isNotificationWatcherReady: function() {
|
||||
dbusNotificationWatcherReady: function() {
|
||||
let watcherReady = false;
|
||||
|
||||
let conn = new gio.GDBusConnection.ptr;
|
||||
|
Loading…
Reference in New Issue
Block a user