Merge branch 'themable-icons'
Conflicts: src/chrome/content/options.js src/chrome/content/options.xul src/modules/FiretrayHandler.jsm src/modules/commons.js src/modules/linux/FiretrayStatusIcon.jsm
|
@ -31,8 +31,9 @@ extension_name := firetray
|
|||
# The name of the profile dir where the extension can be installed.
|
||||
profile_id := mozilla-dev
|
||||
|
||||
# The zip application to be used.
|
||||
ZIP := zip
|
||||
# The zip application to be used. NOTE: symlinks seem not supported in XPI
|
||||
# ("could not be installed because Firefox cannot modify the needed file")
|
||||
ZIP := zip # --symlinks
|
||||
|
||||
# The target location of the build and build files.
|
||||
build_dir := ../build
|
||||
|
@ -77,6 +78,8 @@ chrome_sources := $(chrome_sources_js) \
|
|||
$(wildcard $(chrome_source_root)/skin/*.css) \
|
||||
$(wildcard $(chrome_source_root)/skin/*.png) \
|
||||
$(wildcard $(chrome_source_root)/skin/*.gif) \
|
||||
$(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/22x22/apps/*.png) \
|
||||
$(wildcard $(chrome_source_root)/skin/linux/icons/hicolor/32x32/apps/*.png) \
|
||||
$(wildcard $(chrome_source_root)/locale/*/*.dtd) \
|
||||
$(wildcard $(chrome_source_root)/locale/*/*.properties)
|
||||
|
||||
|
@ -126,7 +129,7 @@ YES_RE := yes|y|Y|true|on
|
|||
# called via $(build_includes)
|
||||
$(build_dir)/%: %
|
||||
@mkdir -p $(dir $@)
|
||||
@cp -f $< $@
|
||||
@cp -f $< $@ # -d for symlinks
|
||||
|
||||
# Debug calls are removed for performance.
|
||||
# NOTE: we could also use m4 for filtering source files...
|
||||
|
|
|
@ -19,16 +19,20 @@ var firetrayUIOptions = {
|
|||
onLoad: function(e) {
|
||||
this.strings = document.getElementById("firetray-options-strings");
|
||||
|
||||
this.updateWindowAndIconOptions();
|
||||
this.updateScrollOptions();
|
||||
|
||||
if(firetray.Handler.inMailApp) {
|
||||
if (firetray.Handler.inMailApp) {
|
||||
Cu.import("resource://firetray/FiretrayMessaging.jsm");
|
||||
this.initMailControls();
|
||||
} else {
|
||||
let mailTab = document.getElementById("mail_tab");
|
||||
this.hideElement(mailTab, true);
|
||||
}
|
||||
|
||||
this.updateWindowAndIconOptions();
|
||||
this.updateScrollOptions();
|
||||
this.initAppIconType();
|
||||
this.initAppIconNames();
|
||||
if (firetray.Handler.inMailApp)
|
||||
this.initNewMailIconNames();
|
||||
},
|
||||
|
||||
onQuit: function(e) {
|
||||
|
@ -58,8 +62,9 @@ var firetrayUIOptions = {
|
|||
|
||||
disableChildren: function(group, disableval) {
|
||||
try {
|
||||
for (let i=0, len=group.childNodes.length; i<len ; ++i)
|
||||
group.childNodes[i].disabled = disableval;
|
||||
let children = group.childNodes;
|
||||
for (let i=0, len=children.length; i<len ; ++i)
|
||||
children[i].disabled = disableval;
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
|
@ -84,6 +89,66 @@ var firetrayUIOptions = {
|
|||
this.disableChildren(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
|
||||
},
|
||||
|
||||
initAppIconType: function() {
|
||||
document.getElementById("ui_app_icon_type_themed").value =
|
||||
FIRETRAY_APPLICATION_ICON_TYPE_THEMED;
|
||||
document.getElementById("ui_app_icon_type_custom").value =
|
||||
FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM;
|
||||
|
||||
let prefAppIconType = firetray.Utils.prefService.getIntPref("app_icon_type");
|
||||
document.getElementById("ui_app_icon_type").selectedIndex = prefAppIconType;
|
||||
|
||||
this.disableIconTypeMaybe(prefAppIconType);
|
||||
},
|
||||
|
||||
initAppIconNames: function() {
|
||||
this.initIconNames(firetray.StatusIcon.prefAppIconNames,
|
||||
"app_icon_type_themed_name", firetray.StatusIcon.defaultAppIconName);
|
||||
},
|
||||
initNewMailIconNames: function() {
|
||||
this.initIconNames("new_mail_icon_names",
|
||||
"radio_mail_notification_newmail_icon_name", firetray.StatusIcon.defaultNewMailIconName);
|
||||
},
|
||||
|
||||
initIconNames: function(prefIconNames, uiIconNameId, defaultIconName) {
|
||||
let appIconNames = firetray.Utils.getArrayPref(prefIconNames);
|
||||
F.LOG("appIconNames="+appIconNames);
|
||||
let len = appIconNames.length;
|
||||
if (len>2)
|
||||
throw new RangeError("Too many icon names");
|
||||
for (let i=0; i<len; ++i) {
|
||||
let textbox = document.getElementById(uiIconNameId+(i+1));
|
||||
textbox.value = appIconNames[i];
|
||||
}
|
||||
let textbox = document.getElementById(uiIconNameId+3);
|
||||
textbox.value = defaultIconName;
|
||||
},
|
||||
|
||||
updateAppIconNames: function(textbox) {
|
||||
this.updateIconNames(firetray.StatusIcon.prefAppIconNames, "app_icon_type_themed_name");
|
||||
},
|
||||
updateNewMailIconNames: function(textbox) {
|
||||
this.updateIconNames("new_mail_icon_names", "radio_mail_notification_newmail_icon_name");
|
||||
},
|
||||
|
||||
updateIconNames: function(prefIconNames, uiIconNameId) {
|
||||
let iconNames = [];
|
||||
for (let i=1; i<3; ++i) {
|
||||
let textbox = document.getElementById(uiIconNameId+i);
|
||||
let val = textbox.value.trim();
|
||||
F.LOG("val="+val);
|
||||
if (val) iconNames.push(val);
|
||||
}
|
||||
F.LOG("iconNames="+iconNames);
|
||||
firetray.Utils.setArrayPref(prefIconNames, iconNames);
|
||||
},
|
||||
|
||||
disableIconTypeMaybe: function(appIconType) {
|
||||
let customIconGroup = document.getElementById("custom_app_icon");
|
||||
this.disableChildren(customIconGroup,
|
||||
(appIconType !== FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM));
|
||||
},
|
||||
|
||||
initMailControls: function() {
|
||||
this.populateExcludedFoldersList();
|
||||
this.populateTreeAccountsOrServerTypes();
|
||||
|
@ -186,6 +251,12 @@ var firetrayUIOptions = {
|
|||
this.disableMessageCountMaybe(messageCountType);
|
||||
},
|
||||
|
||||
chooseAppIconFile: function() {
|
||||
var filepath = document.getElementById("app_icon_custom_filename");
|
||||
this._chooseIconFile(filepath);
|
||||
firetray.Handler.setIconImageDefault();
|
||||
},
|
||||
|
||||
chooseMailIconFile: function() {
|
||||
var filepath = document.getElementById("custom_mail_icon_filename");
|
||||
this._chooseIconFile(filepath);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
<preference id="pref_show_activates" name="extensions.firetray.show_activates" type="bool"/>
|
||||
<preference id="pref_remember_desktop" name="extensions.firetray.remember_desktop" type="bool"/>
|
||||
<preference id="pref_show_icon_on_hide" name="extensions.firetray.show_icon_on_hide" type="bool"/>
|
||||
<preference id="pref_app_icon_type" name="extensions.firetray.app_icon_type" type="int"/>
|
||||
<preference id="pref_app_icon_filename" name="extensions.firetray.app_icon_filename" type="string"/>
|
||||
<preference id="pref_scroll_hides" name="extensions.firetray.scroll_hides" type="bool" />
|
||||
<preference id="pref_scroll_mode" name="extensions.firetray.scroll_mode" type="string" />
|
||||
<preference id="pref_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
|
||||
|
@ -38,7 +40,8 @@
|
|||
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="&windows_icon_options;"/>
|
||||
<tab label="&windows_options;"/>
|
||||
<tab label="&icon_options;"/>
|
||||
<tab label="&mail_options;" id="mail_tab" />
|
||||
</tabs>
|
||||
<tabpanels flex="1">
|
||||
|
@ -46,8 +49,6 @@
|
|||
<tabpanel id="general_tabpanel" flex="1">
|
||||
<vbox pack="start" align="left" flex="1">
|
||||
|
||||
<groupbox>
|
||||
<caption label="&windows_behaviour;" />
|
||||
<checkbox id="ui_hides_on_close" preference="pref_hides_on_close"
|
||||
label="&bool_hides_on_close.label;"
|
||||
accesskey="&bool_hides_on_close.accesskey;"
|
||||
|
@ -70,13 +71,48 @@
|
|||
<checkbox id="ui_remember_desktop" preference="pref_remember_desktop"
|
||||
label="&bool_remember_desktop.label;"
|
||||
accesskey="&bool_remember_desktop.accesskey;"/>
|
||||
</groupbox>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&icon_settings;" />
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
|
||||
|
||||
<tabpanel id="icon_tabpanel" flex="1">
|
||||
<vbox pack="start" align="left" flex="1">
|
||||
|
||||
<radiogroup id="ui_app_icon_type" preference="pref_app_icon_type"
|
||||
oncommand="firetrayUIOptions.disableIconTypeMaybe(this.selectedIndex);">
|
||||
<vbox align="left" flex="1">
|
||||
<label class="header">&app_icon_type;</label>
|
||||
|
||||
<hbox>
|
||||
<radio id="ui_app_icon_type_themed" label="&app_icon_themed.label;"
|
||||
accesskey="&app_icon_themed.accesskey;" tooltiptext="&icon_themed.tooltip;" />
|
||||
<textbox id="app_icon_type_themed_name1" size="12" placeholder="&app_icon_themed_name;"
|
||||
onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
|
||||
<textbox id="app_icon_type_themed_name2" size="12" placeholder="&app_icon_themed_name;"
|
||||
onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1" />
|
||||
<textbox id="app_icon_type_themed_name3" size="12" placeholder="&app_icon_themed_name;"
|
||||
onchange="firetrayUIOptions.updateAppIconNames(this);" flex="1"
|
||||
disabled="true"/>
|
||||
</hbox>
|
||||
<hbox id="ui_app_icon_type_custom_group">
|
||||
<radio id="ui_app_icon_type_custom" label="&app_icon_custom.label;"
|
||||
accesskey="&app_icon_custom.accesskey;" />
|
||||
<hbox id="custom_app_icon" align="center" flex="1" >
|
||||
<textbox id="app_icon_custom_filename" preference="pref_app_icon_filename" flex="1" />
|
||||
<button id="app_icon_custom_select" label="&choose;"
|
||||
accesskey="&choose.accesskey;"
|
||||
oncommand="firetrayUIOptions.chooseAppIconFile()" />
|
||||
</hbox>
|
||||
</hbox>
|
||||
|
||||
</vbox>
|
||||
</radiogroup>
|
||||
|
||||
<checkbox id="ui_show_icon_on_hide" preference="pref_show_icon_on_hide"
|
||||
label="&bool_show_icon_on_hide.label;"
|
||||
accesskey="&bool_show_icon_on_hide.accesskey;"/>
|
||||
|
||||
<checkbox id="ui_scroll_hides" preference="pref_scroll_hides"
|
||||
label="&enable_mouse_scroll.label;"
|
||||
accesskey="&enable_mouse_scroll.accesskey;"
|
||||
|
@ -85,7 +121,6 @@
|
|||
<radio id="ui_radio_scroll_down_hides" label="&down;=&hide;, &up;=&restore;" value="down_hides" />
|
||||
<radio id="ui_radio_scroll_up_hides" label="&up;=&hide;, &down;=&restore;" value="up_hides" />
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
|
@ -135,10 +170,25 @@
|
|||
observes="broadcaster-notification-disabled"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
<radio id="ui_radio_mail_notification_newmail_icon" label="&mail_notification_newmail_icon.label;"
|
||||
accesskey="&mail_notification_newmail_icon.accesskey;"
|
||||
oncommand="firetrayUIOptions.updateNotificationSettings()"
|
||||
observes="broadcaster-notification-disabled" />
|
||||
<hbox>
|
||||
<radio id="ui_radio_mail_notification_newmail_icon" label="&mail_notification_newmail_icon.label;"
|
||||
accesskey="&mail_notification_newmail_icon.accesskey;"
|
||||
oncommand="firetrayUIOptions.updateNotificationSettings()"
|
||||
observes="broadcaster-notification-disabled"
|
||||
tooltiptext="&icon_themed.tooltip;" />
|
||||
<textbox id="radio_mail_notification_newmail_icon_name1" size="12"
|
||||
placeholder="&app_icon_themed_name;" flex="1"
|
||||
observes="broadcaster-notification-disabled"
|
||||
onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
|
||||
<textbox id="radio_mail_notification_newmail_icon_name2" size="12"
|
||||
placeholder="&app_icon_themed_name;" flex="1"
|
||||
observes="broadcaster-notification-disabled"
|
||||
onchange="firetrayUIOptions.updateNewMailIconNames(this);" />
|
||||
<textbox id="radio_mail_notification_newmail_icon_name3" size="12"
|
||||
placeholder="&app_icon_themed_name;" flex="1"
|
||||
onchange="firetrayUIOptions.updateNewMailIconNames(this);"
|
||||
disabled="true"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<radio id="ui_radio_mail_notification_custom_mail_icon" label="&mail_notification_custom_mail_icon.label;"
|
||||
accesskey="&mail_notification_custom_mail_icon.accesskey;"
|
||||
|
@ -146,7 +196,7 @@
|
|||
observes="broadcaster-notification-disabled" />
|
||||
<hbox id="custom_mail_icon" align="center" flex="1" >
|
||||
<textbox id="custom_mail_icon_filename" preference="pref_custom_mail_icon"
|
||||
onblur="firetray.Messaging.updateMsgCount();" flex="1" />
|
||||
onchange="firetray.Messaging.updateMsgCount();" flex="1" />
|
||||
<button id="custom_mail_icon_select" label="&choose;"
|
||||
accesskey="&choose.accesskey;"
|
||||
oncommand="firetrayUIOptions.chooseMailIconFile()" />
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
<!ENTITY NOT_IMPLEMENTED_YET "NOT IMPLEMENTED YET">
|
||||
|
||||
<!ENTITY windows_icon_options "Windows and Icon">
|
||||
<!ENTITY windows_options "Windows">
|
||||
<!ENTITY icon_options "Icon">
|
||||
<!ENTITY mail_options "Mail">
|
||||
|
||||
<!ENTITY windows_behaviour "Windows behaviour">
|
||||
<!ENTITY bool_hides_on_close.label "Closing window hides to tray">
|
||||
<!ENTITY bool_hides_on_close.accesskey "C">
|
||||
<!ENTITY bool_hides_on_minimize.label "Minimizing window hides to tray">
|
||||
|
@ -23,9 +23,16 @@
|
|||
<!ENTITY bool_remember_desktop.label "Remember desktop (per-window)">
|
||||
<!ENTITY bool_remember_desktop.accesskey "R">
|
||||
|
||||
<!ENTITY icon_settings "Icon settings">
|
||||
<!ENTITY bool_show_icon_on_hide.label "Show tray icon only if a window is hidden">
|
||||
<!ENTITY bool_show_icon_on_hide.accesskey "w">
|
||||
<!ENTITY app_icon_type "Application icon type">
|
||||
<!ENTITY app_icon_themed.label "Default themed">
|
||||
<!ENTITY app_icon_themed.accesskey "D">
|
||||
<!ENTITY app_icon_themed_name "icon-name">
|
||||
<!ENTITY icon_themed.tooltip "Icon names provided by graphical environment">
|
||||
<!ENTITY app_icon_custom.label "Custom">
|
||||
<!ENTITY app_icon_custom.accesskey "u">
|
||||
|
||||
<!ENTITY mouse_wheel_options "Mouse wheel options" >
|
||||
<!ENTITY enable_mouse_scroll.label "Handle mouse scroll on tray icon" >
|
||||
<!ENTITY enable_mouse_scroll.accesskey "l">
|
||||
|
|
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.8 KiB |
|
@ -0,0 +1 @@
|
|||
../../../../../mail-unread.png
|
|
@ -0,0 +1 @@
|
|||
../../../../../chatzilla22.png
|
|
@ -0,0 +1 @@
|
|||
../../../../../firefox22.png
|
|
@ -0,0 +1 @@
|
|||
../../../../../seamonkey22.png
|
|
@ -0,0 +1 @@
|
|||
../../../../../thunderbird22.png
|
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 770 B |
After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.8 KiB |
|
@ -11,6 +11,12 @@ pref("extensions.firetray.start_hidden", false);
|
|||
pref("extensions.firetray.show_activates", false);
|
||||
pref("extensions.firetray.remember_desktop", false);
|
||||
|
||||
pref("extensions.firetray.app_icon_type", 0);
|
||||
pref("extensions.firetray.app_browser_icon_names", '["web-browser", "internet-web-browser"]');
|
||||
pref("extensions.firetray.app_mail_icon_names", '["indicator-messages", "applications-email-panel"]');
|
||||
pref("extensions.firetray.app_default_icon_names", '[]');
|
||||
pref("extensions.firetray.app_icon_filename", "");
|
||||
pref("extensions.firetray.new_mail_icon_names", '["indicator-messages-new", "mail-message-new"]');
|
||||
pref("extensions.firetray.show_icon_on_hide", false);
|
||||
pref("extensions.firetray.scroll_hides", true);
|
||||
pref("extensions.firetray.scroll_mode", "down_hides");
|
||||
|
|
|
@ -171,7 +171,8 @@ firetray.Handler = {
|
|||
},
|
||||
|
||||
// these get overridden in OS-specific Icon/Window handlers
|
||||
setIconImage: function(filename) {},
|
||||
setIconImage: function(icon) {},
|
||||
setIconImageFromFile: function(filename) {},
|
||||
setIconImageDefault: function() {},
|
||||
setIconText: function(text, color) {},
|
||||
setIconTooltip: function(localizedMessage) {},
|
||||
|
@ -390,10 +391,22 @@ firetray.PrefListener = new PrefListener(
|
|||
case 'show_icon_on_hide':
|
||||
firetray.Handler.showHideIcon();
|
||||
break;
|
||||
case 'new_mail_icon_names':
|
||||
firetray.StatusIcon.loadThemedIcons();
|
||||
case 'message_count_type':
|
||||
case 'folder_count_recursive':
|
||||
firetray.Messaging.updateMsgCount();
|
||||
break;
|
||||
case 'app_mail_icon_names':
|
||||
case 'app_browser_icon_names':
|
||||
case 'app_default_icon_names':
|
||||
firetray.StatusIcon.loadThemedIcons();
|
||||
case 'app_icon_type':
|
||||
if (firetray.Handler.inMailApp)
|
||||
firetray.Messaging.updateMsgCount();
|
||||
else
|
||||
firetray.Handler.setIconImageDefault();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
});
|
||||
|
|
|
@ -179,11 +179,11 @@ firetray.Messaging = {
|
|||
firetray.Handler.setIconText(newMsgCount.toString(), prefIconTextColor);
|
||||
break;
|
||||
case FIRETRAY_NOTIFICATION_NEWMAIL_ICON:
|
||||
firetray.Handler.setIconImage(firetray.Handler.FILENAME_NEWMAIL);
|
||||
firetray.Handler.setIconImage(firetray.StatusIcon.themedIconNewMail);
|
||||
break;
|
||||
case FIRETRAY_NOTIFICATION_CUSTOM_ICON:
|
||||
let prefCustomIconPath = firetray.Utils.prefService.getCharPref("custom_mail_icon");
|
||||
firetray.Handler.setIconImage(prefCustomIconPath);
|
||||
firetray.Handler.setIconImageFromFile(prefCustomIconPath);
|
||||
break;
|
||||
default:
|
||||
F.ERROR("Unknown notification mode: "+prefMailNotification);
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
provided by this module */
|
||||
var EXPORTED_SYMBOLS =
|
||||
[ "firetray", "F", "FIRETRAY_ID", "FIRETRAY_SPLASH_PAGE",
|
||||
"FIRETRAY_APPLICATION_ICON_TYPE_THEMED",
|
||||
"FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM",
|
||||
"FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT",
|
||||
"FIRETRAY_NOTIFICATION_NEWMAIL_ICON", "FIRETRAY_NOTIFICATION_CUSTOM_ICON",
|
||||
"FIRETRAY_DELAY_BROWSER_STARTUP_MILLISECONDS",
|
||||
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS", "FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD",
|
||||
"FIRETRAY_DELAY_NOWAIT_MILLISECONDS",
|
||||
"FIRETRAY_DELAY_PREF_CLEANING_MILLISECONDS",
|
||||
"FIRETRAY_MESSAGE_COUNT_TYPE_NEW" ];
|
||||
"FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD", "FIRETRAY_MESSAGE_COUNT_TYPE_NEW" ];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
@ -21,6 +23,9 @@ Cu.import("resource://firetray/logging.jsm");
|
|||
const FIRETRAY_ID = "{9533f794-00b4-4354-aa15-c2bbda6989f8}";
|
||||
const FIRETRAY_SPLASH_PAGE = "http://foudfou.github.com/FireTray/";
|
||||
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_THEMED = 0;
|
||||
const FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM = 1;
|
||||
|
||||
const FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT = 0;
|
||||
const FIRETRAY_NOTIFICATION_NEWMAIL_ICON = 1;
|
||||
const FIRETRAY_NOTIFICATION_CUSTOM_ICON = 3;
|
||||
|
@ -237,3 +242,10 @@ if(!Object.keys) Object.keys = function(o){
|
|||
for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
|
||||
return ret;
|
||||
};
|
||||
|
||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim
|
||||
if(!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s+|\s+$/g,'');
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
var EXPORTED_SYMBOLS = [ "gio" ];
|
||||
|
||||
const GIO_LIBNAME = "gio-2.0";
|
||||
const GIO_ABIS = [ "0" ];
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
Cu.import("resource://firetray/ctypes/ctypes-utils.jsm");
|
||||
|
||||
function gio_defines(lib) {
|
||||
this.GIcon = ctypes.StructType("GIcon");
|
||||
this.GThemedIcon = ctypes.StructType("GThemedIcon");
|
||||
|
||||
lib.lazy_bind("g_themed_icon_new_from_names", this.GIcon.ptr, ctypes.char.ptr.ptr, ctypes.int);
|
||||
|
||||
}
|
||||
|
||||
new ctypes_library(GIO_LIBNAME, GIO_ABIS, gio_defines, this);
|
|
@ -6,7 +6,7 @@
|
|||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
|
@ -34,7 +34,7 @@
|
|||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var EXPORTED_SYMBOLS = [ "gobject", "glib" ];
|
||||
|
@ -140,6 +140,7 @@ function gobject_defines(lib) {
|
|||
return this.g_signal_connect_data(instance, detailed_signal, handler, data, null, this.G_CONNECT_AFTER);
|
||||
};
|
||||
|
||||
lib.lazy_bind("g_free", ctypes.void_t, this.gpointer);
|
||||
lib.lazy_bind("g_object_unref", ctypes.void_t, this.gpointer);
|
||||
lib.lazy_bind("g_list_free", ctypes.void_t, this.GList.ptr);
|
||||
lib.lazy_bind("g_list_length", this.guint, this.GList.ptr);
|
||||
|
|
|
@ -12,6 +12,7 @@ const Ci = Components.interfaces;
|
|||
Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
Cu.import("resource://firetray/ctypes/ctypes-utils.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gdk.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gio.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/pango.jsm");
|
||||
|
||||
|
@ -42,6 +43,7 @@ function gtk_defines(lib) {
|
|||
{ "parent": this.GtkWidget.ptr }
|
||||
]);
|
||||
|
||||
this.GtkIconTheme = ctypes.StructType("GtkIconTheme");
|
||||
this.GtkMenu = ctypes.StructType("GtkMenu");
|
||||
// use ctypes.cast(menu, LibGtkStatusIcon.GtkMenuShell.ptr);
|
||||
this.GtkMenuShell = ctypes.StructType("GtkMenuShell");
|
||||
|
@ -72,8 +74,15 @@ function gtk_defines(lib) {
|
|||
ctypes.default_abi, gobject.gboolean,
|
||||
[this.GtkWidget.ptr, gdk.GdkEventWindowState.ptr, gobject.gpointer]).ptr;
|
||||
|
||||
lib.lazy_bind("gtk_icon_theme_get_default", this.GtkIconTheme.ptr);
|
||||
lib.lazy_bind("gtk_icon_theme_get_for_screen", this.GtkIconTheme.ptr, gdk.GdkScreen.ptr);
|
||||
lib.lazy_bind("gtk_icon_theme_append_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
|
||||
lib.lazy_bind("gtk_icon_theme_prepend_search_path", ctypes.void_t, this.GtkIconTheme.ptr, gobject.gchar.ptr);
|
||||
|
||||
lib.lazy_bind("gtk_status_icon_new", this.GtkStatusIcon.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_from_file", ctypes.void_t, this.GtkStatusIcon.ptr, ctypes.char.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_from_icon_name", ctypes.void_t, this.GtkStatusIcon.ptr, gobject.gchar.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_from_gicon", ctypes.void_t, this.GtkStatusIcon.ptr, gio.GIcon.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_tooltip_text", ctypes.void_t, this.GtkStatusIcon.ptr, ctypes.char.ptr);
|
||||
lib.lazy_bind("gtk_status_icon_set_visible", ctypes.void_t, this.GtkStatusIcon.ptr, gobject.gboolean);
|
||||
lib.lazy_bind("gtk_menu_new", this.GtkMenu.ptr);
|
||||
|
|
|
@ -12,6 +12,7 @@ Cu.import("resource://gre/modules/ctypes.jsm");
|
|||
Cu.import("resource://firetray/ctypes/linux/cairo.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gobject.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gdk.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gio.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/pango.jsm");
|
||||
Cu.import("resource://firetray/ctypes/linux/pangocairo.jsm");
|
||||
|
@ -22,15 +23,32 @@ if ("undefined" == typeof(firetray.Handler))
|
|||
|
||||
|
||||
firetray.StatusIcon = {
|
||||
GTK_THEME_ICON_PATH: null,
|
||||
|
||||
initialized: false,
|
||||
// pointers to JS functions. MUST LIVE DURING ALL THE EXECUTION
|
||||
callbacks: {},
|
||||
callbacks: {}, // pointers to JS functions. MUST LIVE DURING ALL THE EXECUTION
|
||||
trayIcon: null,
|
||||
themedIconApp: null,
|
||||
themedIconNewMail: null,
|
||||
prefAppIconNames: null,
|
||||
prefNewMailIconNames: null,
|
||||
defaultAppIconName: null,
|
||||
defaultNewMailIconName: null,
|
||||
|
||||
init: function() {
|
||||
this.defineIconNames();
|
||||
|
||||
try {
|
||||
// init tray icon, some variables
|
||||
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.loadThemedIcons();
|
||||
|
||||
this.trayIcon = gtk.gtk_status_icon_new();
|
||||
|
||||
} catch (x) {
|
||||
F.ERROR(x);
|
||||
return false;
|
||||
|
@ -55,6 +73,58 @@ firetray.StatusIcon = {
|
|||
this.initialized = false;
|
||||
},
|
||||
|
||||
defineIconNames: function() {
|
||||
this.prefAppIconNames = (function() {
|
||||
if (firetray.Handler.inMailApp) {
|
||||
return "app_mail_icon_names";
|
||||
} else if (firetray.Handler.inBrowserApp) {
|
||||
return "app_browser_icon_names";
|
||||
} else {
|
||||
return "app_default_icon_names";
|
||||
}
|
||||
})();
|
||||
this.defaultAppIconName = firetray.Handler.appName.toLowerCase();
|
||||
|
||||
this.prefNewMailIconNames = "new_mail_icon_names";
|
||||
this.defaultNewMailIconName = "mail-unread";
|
||||
},
|
||||
|
||||
loadThemedIcons: function() {
|
||||
if (firetray.Handler.inMailApp) {
|
||||
let newMailIconNames = this.getNewMailIconNames();
|
||||
if (this.themedIconNewMail) gobject.g_object_unref(this.themedIconNewMail);
|
||||
this.themedIconNewMail = this.initThemedIcon(newMailIconNames);
|
||||
}
|
||||
let appIconNames = this.getAppIconNames();
|
||||
if (this.themedIconApp) gobject.g_object_unref(this.themedIconApp);
|
||||
this.themedIconApp = this.initThemedIcon(appIconNames);
|
||||
},
|
||||
|
||||
getAppIconNames: function() {
|
||||
let appIconNames = firetray.Utils.getArrayPref(this.prefAppIconNames);
|
||||
appIconNames.push(this.defaultAppIconName);
|
||||
return appIconNames;
|
||||
},
|
||||
getNewMailIconNames: function() {
|
||||
let newMailIconNames = firetray.Utils.getArrayPref(this.prefNewMailIconNames);
|
||||
newMailIconNames.push(this.defaultNewMailIconName);
|
||||
return newMailIconNames;
|
||||
},
|
||||
|
||||
initThemedIcon: function(names) {
|
||||
if (!firetray.js.isArray(names)) throw new TypeError();
|
||||
F.LOG("themedIconNames="+names);
|
||||
let namesLen = names.length;
|
||||
F.LOG("themedIconNamesLen="+namesLen);
|
||||
let themedIconNames = ctypes.char.ptr.array(namesLen)();
|
||||
for (let i=0; i<namesLen; ++i)
|
||||
themedIconNames[i] = ctypes.char.array()(names[i]);
|
||||
F.LOG("themedIconNames="+themedIconNames);
|
||||
let themedIcon = gio.g_themed_icon_new_from_names(themedIconNames, namesLen);
|
||||
F.LOG("themedIcon="+themedIcon);
|
||||
return themedIcon;
|
||||
},
|
||||
|
||||
addCallbacks: function() {
|
||||
/* NOTE: here we do use a function handler (instead of a function
|
||||
definition) because we need the args passed to it ! As a consequence, we
|
||||
|
@ -101,30 +171,47 @@ firetray.StatusIcon = {
|
|||
default:
|
||||
F.ERROR("SCROLL UNKNOWN");
|
||||
}
|
||||
},
|
||||
|
||||
setIconImageFromFile: function(filename) {
|
||||
if (!firetray.StatusIcon.trayIcon)
|
||||
F.ERROR("Icon missing");
|
||||
F.LOG(filename);
|
||||
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
|
||||
filename);
|
||||
},
|
||||
|
||||
setIconImageFromName: function(iconName) {
|
||||
if (!firetray.StatusIcon.trayIcon)
|
||||
F.ERROR("Icon missing");
|
||||
F.LOG(iconName);
|
||||
gtk.gtk_status_icon_set_from_icon_name(firetray.StatusIcon.trayIcon, iconName);
|
||||
},
|
||||
|
||||
setIconImageFromGIcon: function(gicon) {
|
||||
if (!firetray.StatusIcon.trayIcon || !gicon)
|
||||
F.ERROR("Icon missing");
|
||||
F.LOG(gicon);
|
||||
gtk.gtk_status_icon_set_from_gicon(firetray.StatusIcon.trayIcon, gicon);
|
||||
}
|
||||
|
||||
}; // firetray.StatusIcon
|
||||
|
||||
|
||||
firetray.Handler.setIconImage = function(filename) {
|
||||
if (!firetray.StatusIcon.trayIcon)
|
||||
return false;
|
||||
F.LOG(filename);
|
||||
firetray.Handler.setIconImage = firetray.StatusIcon.setIconImageFromGIcon;
|
||||
|
||||
try {
|
||||
gtk.gtk_status_icon_set_from_file(firetray.StatusIcon.trayIcon,
|
||||
filename);
|
||||
} catch (x) {
|
||||
F.ERROR(x);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
firetray.Handler.setIconImageFromFile = firetray.StatusIcon.setIconImageFromFile;
|
||||
|
||||
firetray.Handler.setIconImageDefault = function() {
|
||||
if (!this.FILENAME_DEFAULT)
|
||||
throw "Default application icon filename not set";
|
||||
this.setIconImage(this.FILENAME_DEFAULT);
|
||||
if (!firetray.StatusIcon.themedIconApp)
|
||||
throw "Default application themed icon not set";
|
||||
let appIconType = firetray.Utils.prefService.getIntPref("app_icon_type");
|
||||
if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_THEMED)
|
||||
firetray.Handler.setIconImage(firetray.StatusIcon.themedIconApp);
|
||||
else if (appIconType === FIRETRAY_APPLICATION_ICON_TYPE_CUSTOM) {
|
||||
let appIconFilename = firetray.Utils.prefService.getCharPref("app_icon_filename");
|
||||
firetray.Handler.setIconImageFromFile(appIconFilename);
|
||||
}
|
||||
};
|
||||
|
||||
// GTK bug: Gdk-CRITICAL **: IA__gdk_window_get_root_coords: assertion `GDK_IS_WINDOW (window)' failed
|
||||
|
|