mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-07 19:48:03 -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");
|
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() {
|
tryCloseLibs: function() {
|
||||||
try {
|
try {
|
||||||
for (let libName in this.ctypesLibs) {
|
for (let libName in this.ctypesLibs) {
|
||||||
@ -211,14 +219,6 @@ firetray.Handler = {
|
|||||||
} catch(x) { log.error(x); }
|
} 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() {
|
readTBRestoreWindowsCount: function() {
|
||||||
Cu.import("resource:///modules/IOUtils.js");
|
Cu.import("resource:///modules/IOUtils.js");
|
||||||
let sessionFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
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_ACCOUNT_SERVER_TYPE_IM", "FIRETRAY_DELAY_STARTUP_MILLISECONDS",
|
||||||
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
|
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
|
||||||
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW", "FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
|
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW", "FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL",
|
||||||
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE", "FIRETRAY_APP_DB",
|
"FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE", "FIRETRAY_APPINDICATOR_ID",
|
||||||
"FIRETRAY_CB_SENTINEL" ];
|
"FIRETRAY_APP_DB", "FIRETRAY_CB_SENTINEL" ];
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
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_NORMAL = 0;
|
||||||
const FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE = 1;
|
const FIRETRAY_CHAT_ICON_BLINK_STYLE_FADE = 1;
|
||||||
|
|
||||||
|
const FIRETRAY_APPINDICATOR_ID = "firetray";
|
||||||
|
|
||||||
const FIRETRAY_APP_DB = {
|
const FIRETRAY_APP_DB = {
|
||||||
|
|
||||||
firefox: {
|
firefox: {
|
||||||
|
@ -39,6 +39,7 @@ firetray.StatusIcon = {
|
|||||||
prefNewMailIconNames: null,
|
prefNewMailIconNames: null,
|
||||||
defaultAppIconName: null,
|
defaultAppIconName: null,
|
||||||
defaultNewMailIconName: null,
|
defaultNewMailIconName: null,
|
||||||
|
inidicator: null,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
this.FILENAME_BLANK = firetray.Utils.chromeToPath(
|
||||||
@ -49,43 +50,24 @@ firetray.StatusIcon = {
|
|||||||
this.defineIconNames();
|
this.defineIconNames();
|
||||||
this.loadThemedIcons();
|
this.loadThemedIcons();
|
||||||
|
|
||||||
this.trayIcon = gtk.gtk_status_icon_new();
|
|
||||||
firetray.Handler.setIconImageDefault();
|
|
||||||
firetray.Handler.setIconTooltipDefault();
|
|
||||||
|
|
||||||
Cu.import("resource://firetray/linux/FiretrayPopupMenu.jsm");
|
Cu.import("resource://firetray/linux/FiretrayPopupMenu.jsm");
|
||||||
if (!firetray.PopupMenu.init())
|
if (!firetray.PopupMenu.init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.addCallbacks();
|
|
||||||
|
|
||||||
Cu.import("resource://firetray/ctypes/linux/appindicator.jsm");
|
Cu.import("resource://firetray/ctypes/linux/appindicator.jsm");
|
||||||
if (appind3.available() && this.isNotificationWatcherReady()) {
|
if (appind3.available() && this.dbusNotificationWatcherReady()) {
|
||||||
this.indicator = appind3.app_indicator_new(
|
firetray.Handler.subscribeLibsForClosing([appind3]);
|
||||||
'FOUDIL',
|
// FIXME: we may want to split into 2 separate modules: GtkStatusIcon and
|
||||||
'firefox',
|
// AppIndicator.
|
||||||
appind3.APP_INDICATOR_CATEGORY_APPLICATION_STATUS
|
this.indicatorInit();
|
||||||
);
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.trayIcon = gtk.gtk_status_icon_new();
|
||||||
|
firetray.Handler.setIconImageDefault();
|
||||||
|
firetray.Handler.setIconTooltipDefault();
|
||||||
|
|
||||||
|
this.addCallbacks();
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -98,6 +80,32 @@ firetray.StatusIcon = {
|
|||||||
this.initialized = false;
|
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() {
|
defineIconNames: function() {
|
||||||
this.prefAppIconNames = (function() {
|
this.prefAppIconNames = (function() {
|
||||||
if (firetray.Handler.inMailApp) {
|
if (firetray.Handler.inMailApp) {
|
||||||
@ -235,7 +243,7 @@ firetray.StatusIcon = {
|
|||||||
log.warn("AppIndicator connection-changed: "+connected);
|
log.warn("AppIndicator connection-changed: "+connected);
|
||||||
},
|
},
|
||||||
|
|
||||||
isNotificationWatcherReady: function() {
|
dbusNotificationWatcherReady: function() {
|
||||||
let watcherReady = false;
|
let watcherReady = false;
|
||||||
|
|
||||||
let conn = new gio.GDBusConnection.ptr;
|
let conn = new gio.GDBusConnection.ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user