+++ /dev/null
-/*\r
- * Ext JS Library 0.30\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.air.SystemTray\r
- * @singleton\r
- *\r
- * \r
- *\r
- */\r
-Ext.air.SystemTray = function(){\r
- var app = air.NativeApplication.nativeApplication;\r
- var icon, isWindows = false, bitmaps;\r
- \r
- // windows\r
- if(air.NativeApplication.supportsSystemTrayIcon) {\r
- icon = app.icon;\r
- isWindows = true;\r
- }\r
- \r
- // mac\r
- if(air.NativeApplication.supportsDockIcon) {\r
- icon = app.icon;\r
- }\r
- \r
- return {\r
- /**\r
- * Sets the Icon and tooltip for the currently running application in the\r
- * SystemTray or Dock depending on the operating system.\r
- * @param {String} icon Icon to load with a URLRequest\r
- * @param {String} tooltip Tooltip to use when mousing over the icon\r
- * @param {Boolean} initWithIcon Boolean to initialize with icon immediately\r
- */\r
- setIcon : function(icon, tooltip, initWithIcon){\r
- if(!icon){ // not supported OS\r
- return;\r
- }\r
- var loader = new air.Loader();\r
- loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, function(e){\r
- bitmaps = new runtime.Array(e.target.content.bitmapData);\r
- if (initWithIcon) {\r
- icon.bitmaps = bitmaps;\r
- }\r
- });\r
- \r
- loader.load(new air.URLRequest(icon));\r
- if(tooltip && air.NativeApplication.supportsSystemTrayIcon) {\r
- app.icon.tooltip = tooltip;\r
- }\r
- },\r
- \r
- /**\r
- * Bounce the OS X dock icon. Accepts a priority to notify the user\r
- * whether the event which has just occurred is informational (single bounce)\r
- * or critcal (continual bounce).\r
- * @param priority {air.NotificationType} The priorities are air.NotificationType.INFORMATIONAL and air.NotificationType.CRITICAL.\r
- */\r
- bounce : function(priority){\r
- icon.bounce(priority);\r
- },\r
- \r
- on : function(eventName, fn, scope){\r
- icon.addEventListener(eventName, function(){\r
- fn.apply(scope || this, arguments);\r
- });\r
- },\r
- \r
- /**\r
- * Hide the custom icon\r
- */\r
- hideIcon : function(){\r
- if(!icon){ // not supported OS\r
- return;\r
- }\r
- icon.bitmaps = [];\r
- },\r
- \r
- /**\r
- * Show the custom icon\r
- */\r
- showIcon : function(){\r
- if(!icon){ // not supported OS\r
- return;\r
- }\r
- icon.bitmaps = bitmaps;\r
- },\r
- \r
- /**\r
- * Sets a menu for the icon\r
- * @param {Array} actions Configurations for Ext.air.MenuItem's\r
- */\r
- setMenu: function(actions, _parentMenu){\r
- if(!icon){ // not supported OS\r
- return;\r
- }\r
- var menu = new air.NativeMenu();\r
- \r
- for (var i = 0, len = actions.length; i < len; i++) {\r
- var a = actions[i];\r
- if(a == '-'){\r
- menu.addItem(new air.NativeMenuItem("", true));\r
- }else{\r
- var item = menu.addItem(Ext.air.MenuItem(a));\r
- if(a.menu || (a.initialConfig && a.initialConfig.menu)){\r
- item.submenu = Ext.air.SystemTray.setMenu(a.menu || a.initialConfig.menu, menu);\r
- }\r
- }\r
- \r
- if(!_parentMenu){\r
- icon.menu = menu;\r
- }\r
- }\r
- \r
- return menu;\r
- }\r
- }; \r
-}();
\ No newline at end of file