2 * Ext JS Library 0.30
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * @class Ext.air.SystemTray
\r
16 Ext.air.SystemTray = function(){
\r
17 var app = air.NativeApplication.nativeApplication;
\r
18 var icon, isWindows = false, bitmaps;
\r
21 if(air.NativeApplication.supportsSystemTrayIcon) {
\r
27 if(air.NativeApplication.supportsDockIcon) {
\r
33 * Sets the Icon and tooltip for the currently running application in the
\r
34 * SystemTray or Dock depending on the operating system.
\r
35 * @param {String} icon Icon to load with a URLRequest
\r
36 * @param {String} tooltip Tooltip to use when mousing over the icon
\r
37 * @param {Boolean} initWithIcon Boolean to initialize with icon immediately
\r
39 setIcon : function(icon, tooltip, initWithIcon){
\r
40 if(!icon){ // not supported OS
\r
43 var loader = new air.Loader();
\r
44 loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, function(e){
\r
45 bitmaps = new runtime.Array(e.target.content.bitmapData);
\r
47 icon.bitmaps = bitmaps;
\r
51 loader.load(new air.URLRequest(icon));
\r
52 if(tooltip && air.NativeApplication.supportsSystemTrayIcon) {
\r
53 app.icon.tooltip = tooltip;
\r
58 * Bounce the OS X dock icon. Accepts a priority to notify the user
\r
59 * whether the event which has just occurred is informational (single bounce)
\r
60 * or critcal (continual bounce).
\r
61 * @param priority {air.NotificationType} The priorities are air.NotificationType.INFORMATIONAL and air.NotificationType.CRITICAL.
\r
63 bounce : function(priority){
\r
64 icon.bounce(priority);
\r
67 on : function(eventName, fn, scope){
\r
68 icon.addEventListener(eventName, function(){
\r
69 fn.apply(scope || this, arguments);
\r
74 * Hide the custom icon
\r
76 hideIcon : function(){
\r
77 if(!icon){ // not supported OS
\r
84 * Show the custom icon
\r
86 showIcon : function(){
\r
87 if(!icon){ // not supported OS
\r
90 icon.bitmaps = bitmaps;
\r
94 * Sets a menu for the icon
\r
95 * @param {Array} actions Configurations for Ext.air.MenuItem's
\r
97 setMenu: function(actions, _parentMenu){
\r
98 if(!icon){ // not supported OS
\r
101 var menu = new air.NativeMenu();
\r
103 for (var i = 0, len = actions.length; i < len; i++) {
\r
104 var a = actions[i];
\r
106 menu.addItem(new air.NativeMenuItem("", true));
\r
108 var item = menu.addItem(Ext.air.MenuItem(a));
\r
109 if(a.menu || (a.initialConfig && a.initialConfig.menu)){
\r
110 item.submenu = Ext.air.SystemTray.setMenu(a.menu || a.initialConfig.menu, menu);
\r