@@ -18,9 +18,10 @@ var mainWindow = null;
1818app . on ( 'ready' , function ( ) {
1919 // Creates window
2020 mainWindow = new BrowserWindow ( {
21- height : 600 ,
22- width : 900 ,
23- icon : Path . join ( __dirname , 'gfx' , 'app-icon.png' ) ,
21+ "height" : 600 ,
22+ "width" : 900 ,
23+ "icon" : Path . join ( __dirname , "gfx" , "app-icon.png" ) ,
24+ "skip-taskbar" : conf . get ( "general.mode" ) == "tray" ? true : false
2425 } ) ;
2526
2627 // Check if php_path is already known
@@ -31,29 +32,46 @@ app.on('ready', function() {
3132 // Nope! Go and find it!
3233 runCheck ( ) ;
3334 }
35+
3436} ) ;
3537
3638function startApp ( ) {
37- mainWindow . loadURL ( 'file://' + Path . join ( __dirname , 'index.html' ) ) ;
39+ // Loading main HTML
40+ mainWindow . loadURL ( "file://" + Path . join ( __dirname , 'index.html' ) ) ;
41+
42+ // Checks app mode (regular, tray, both)
43+ var mode = conf . get ( "general.mode" ) ;
44+ if ( ! mode ) mode = "both"
45+
46+ switch ( mode ) {
47+ case "both" :
48+ createTrayIcon ( ) ;
49+ break ;
50+ case "tray" :
51+ createTrayIcon ( ) ;
52+ hideAppIcon ( ) ;
53+ break ;
54+ }
55+ }
3856
57+ function createTrayIcon ( ) {
3958 // Set tray icon
40- var trayIcon = Path . join ( __dirname , ' gfx' ) ;
41- if ( process . platform !== ' darwin' )
42- trayIcon = Path . join ( trayIcon , ' tray.png' ) ;
59+ var trayIcon = Path . join ( __dirname , " gfx" ) ;
60+ if ( process . platform !== " darwin" )
61+ trayIcon = Path . join ( trayIcon , " tray.png" ) ;
4362 else
44- trayIcon = Path . join ( trayIcon , ' tray-black.png' ) ;
63+ trayIcon = Path . join ( trayIcon , " tray-black.png" ) ;
4564
4665 appIcon = new Tray ( trayIcon ) ;
47- // var contextMenu = Menu.buildFromTemplate([
48- // {
49- // label: 'Show assistant'
50- // },
51- // { label: 'Quit',
52- // selector: 'terminate:',
53- // }
54- // ]);
55- appIcon . setToolTip ( 'PHP Assistant' ) ;
56- appIcon . on ( 'click' , focusBehavior ) ;
66+
67+ appIcon . setToolTip ( "PHP Assistant" ) ;
68+ appIcon . on ( "click" , focusBehavior ) ;
69+ }
70+
71+ // Hides app from taskbar/dock
72+ function hideAppIcon ( ) {
73+ if ( app . dock )
74+ app . dock . hide ( ) ;
5775}
5876
5977function runCheck ( ) {
0 commit comments