@@ -12,6 +12,7 @@ const Cu = Components.utils;
1212Cu . import ( "resource://gre/modules/Services.jsm" ) ;
1313Cu . import ( "resource://gre/modules/XPCOMUtils.jsm" ) ;
1414Cu . import ( "resource://gre/modules/ctypes.jsm" ) ;
15+ Cu . import ( "resource://gre/modules/osfile.jsm" ) ;
1516Cu . import ( "resource://firetray/ctypes/ctypesMap.jsm" ) ;
1617Cu . import ( "resource://firetray/ctypes/winnt/win32.jsm" ) ;
1718Cu . import ( "resource://firetray/ctypes/winnt/gdi32.jsm" ) ;
@@ -20,24 +21,14 @@ Cu.import("resource://firetray/ctypes/winnt/shell32.jsm");
2021Cu . import ( "resource://firetray/ctypes/winnt/user32.jsm" ) ;
2122Cu . import ( "resource://firetray/winnt/FiretrayWin32.jsm" ) ;
2223Cu . import ( "resource://firetray/commons.js" ) ;
24+ Cu . import ( "resource://firetray/icons.jsm" ) ;
2325firetray . Handler . subscribeLibsForClosing ( [ gdi32 , kernel32 , shell32 , user32 ] ) ;
2426
2527let log = firetray . Logging . getLogger ( "firetray.StatusIcon" ) ;
2628
2729if ( "undefined" == typeof ( firetray . Handler ) )
2830 log . error ( "This module MUST be imported from/after FiretrayHandler !" ) ;
2931
30- const ICON_CHROME_PATH = "chrome://firetray/skin/icons/winnt" ;
31- const ICON_CHROME_FILES = {
32- 'blank-icon' : { use :'tray' , path :ICON_CHROME_PATH + "/blank-icon.bmp" } ,
33- 'mail-unread' : { use :'tray' , path :ICON_CHROME_PATH + "/mail-unread.bmp" } ,
34- 'prefs' : { use :'menu' , path :ICON_CHROME_PATH + "/gtk-preferences.bmp" } ,
35- 'quit' : { use :'menu' , path :ICON_CHROME_PATH + "/application-exit.bmp" } ,
36- 'new-wnd' : { use :'menu' , path :ICON_CHROME_PATH + "/document-new.bmp" } ,
37- 'new-msg' : { use :'menu' , path :ICON_CHROME_PATH + "/gtk-edit.bmp" } ,
38- 'reset' : { use :'menu' , path :ICON_CHROME_PATH + "/gtk-apply.bmp" } ,
39- } ;
40-
4132
4233firetray . StatusIcon = {
4334 initialized : false ,
@@ -93,10 +84,21 @@ firetray.StatusIcon = {
9384
9485 /* we'll take the first icon in the .ico file. To get the icon count in the
9586 file, pass ctypes.cast(ctypes.int(-1), win32.UINT); */
96- for ( let imgName in ICON_CHROME_FILES ) {
97- let path = firetray . Utils . chromeToPath ( ICON_CHROME_FILES [ imgName ] . path ) ;
87+ for ( let imgName in EMBEDDED_ICON_FILES ) {
88+ let path = OS . Path . join ( OS . Constants . Path . tmpDir , imgName + '.' + EMBEDDED_ICON_FILES [ imgName ] . type ) ;
89+ log . debug ( "Path: " + path ) ;
90+
91+ let byte_buf = ctypes . unsigned_char . array ( ) ( EMBEDDED_ICON_FILES [ imgName ] . bin ) ;
92+ let hFile = kernel32 . CreateFileW ( path , kernel32 . GENERIC_WRITE , 0 , null , kernel32 . CREATE_ALWAYS , kernel32 . FILE_ATTRIBUTE_NORMAL , null ) ;
93+ let written = new win32 . DWORD ;
94+ let status = kernel32 . WriteFile ( hFile , byte_buf , byte_buf . length , written . address ( ) , null ) ;
95+ status = kernel32 . CloseHandle ( hFile ) ;
96+
9897 let img = this . loadImageFromFile ( path ) ;
99- if ( img && ICON_CHROME_FILES [ imgName ] . use == 'menu' )
98+ log . debug ( "Img Type: " + img [ 'type' ] ) ;
99+ log . debug ( "Img hImg: " + img [ 'himg' ] ) ;
100+
101+ if ( img && EMBEDDED_ICON_FILES [ imgName ] . use == 'menu' )
100102 /* Ideally we should rebuild the menu each time it is shown as the menu
101103 color may change. But let's just consider it's not worth it for
102104 now. */
@@ -173,6 +175,12 @@ firetray.StatusIcon = {
173175 map . remove ( imgName ) ;
174176 }
175177 } ) ;
178+
179+ for ( let imgName in EMBEDDED_ICON_FILES ) {
180+ let path = OS . Path . join ( OS . Constants . Path . tmpDir , imgName + '.' + EMBEDDED_ICON_FILES [ imgName ] . type ) ;
181+ kernel32 . DeleteFileW ( path ) ;
182+ }
183+
176184 log . debug ( "Icons destroyed" ) ;
177185 } ,
178186
0 commit comments