]> khamidou — GitHub mirrors - electron.git/commitdiff
Show a simple menu in default_app on Windows.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 2 Oct 2013 13:51:19 +0000 (21:51 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 2 Oct 2013 13:51:19 +0000 (21:51 +0800)
browser/default_app/default_app.js

index a40e876c43ccf5846278b97de9f641b31f0fe3e4..dd43d8296dcb642d53f06d2a1b1986a8126c8bc9 100644 (file)
@@ -31,7 +31,6 @@ app.on('finish-launching', function() {
   });
 
   mainWindow.on('closed', function() {
-    console.log('closed');
     mainWindow = null;
   });
 
@@ -39,131 +38,167 @@ app.on('finish-launching', function() {
     console.log('unresponsive');
   });
 
-  var template = [
-    {
-      label: 'Atom Shell',
-      submenu: [
-        {
-          label: 'About Atom Shell',
-          selector: 'orderFrontStandardAboutPanel:'
-        },
-        {
-          type: 'separator'
-        },
-        {
-          label: 'Hide Atom Shell',
-          accelerator: 'Command+H',
-          selector: 'hide:'
-        },
-        {
-          label: 'Hide Others',
-          accelerator: 'Command+Shift+H',
-          selector: 'hideOtherApplications:'
-        },
-        {
-          label: 'Show All',
-          selector: 'unhideAllApplications:'
-        },
-        {
-          type: 'separator'
-        },
-        {
-          label: 'Quit',
-          accelerator: 'Command+Q',
-          click: function() { app.quit(); }
-        },
-      ]
-    },
-    {
-      label: 'Edit',
-      submenu: [
-        {
-          label: 'Undo',
-          accelerator: 'Command+Z',
-          selector: 'undo:'
-        },
-        {
-          label: 'Redo',
-          accelerator: 'Shift+Command+Z',
-          selector: 'redo:'
-        },
-        {
-          type: 'separator'
-        },
-        {
-          label: 'Cut',
-          accelerator: 'Command+X',
-          selector: 'cut:'
-        },
-        {
-          label: 'Copy',
-          accelerator: 'Command+C',
-          selector: 'copy:'
-        },
-        {
-          label: 'Paste',
-          accelerator: 'Command+V',
-          selector: 'paste:'
-        },
-        {
-          label: 'Select All',
-          accelerator: 'Command+A',
-          selector: 'selectAll:'
-        },
-      ]
-    },
-    {
-      label: 'View',
-      submenu: [
-        {
-          label: 'Reload',
-          accelerator: 'Command+R',
-          click: function() { BrowserWindow.getFocusedWindow().restart(); }
-        },
-        {
-          label: 'Enter Fullscreen',
-          click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); }
-        },
-        {
-          label: 'Toggle DevTools',
-          accelerator: 'Alt+Command+I',
-          click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
-        },
-      ]
-    },
-    {
-      label: 'Window',
-      submenu: [
-        {
-          label: 'Minimize',
-          accelerator: 'Command+M',
-          selector: 'performMiniaturize:'
-        },
-        {
-          label: 'Close',
-          accelerator: 'Command+W',
-          selector: 'performClose:'
-        },
-        {
-          type: 'separator'
-        },
-        {
-          label: 'Bring All to Front',
-          selector: 'arrangeInFront:'
-        },
-      ]
-    },
-  ];
+  if (process.platform == 'darwin') {
+    var template = [
+      {
+        label: 'Atom Shell',
+        submenu: [
+          {
+            label: 'About Atom Shell',
+            selector: 'orderFrontStandardAboutPanel:'
+          },
+          {
+            type: 'separator'
+          },
+          {
+            label: 'Hide Atom Shell',
+            accelerator: 'Command+H',
+            selector: 'hide:'
+          },
+          {
+            label: 'Hide Others',
+            accelerator: 'Command+Shift+H',
+            selector: 'hideOtherApplications:'
+          },
+          {
+            label: 'Show All',
+            selector: 'unhideAllApplications:'
+          },
+          {
+            type: 'separator'
+          },
+          {
+            label: 'Quit',
+            accelerator: 'Command+Q',
+            click: function() { app.quit(); }
+          },
+        ]
+      },
+      {
+        label: 'Edit',
+        submenu: [
+          {
+            label: 'Undo',
+            accelerator: 'Command+Z',
+            selector: 'undo:'
+          },
+          {
+            label: 'Redo',
+            accelerator: 'Shift+Command+Z',
+            selector: 'redo:'
+          },
+          {
+            type: 'separator'
+          },
+          {
+            label: 'Cut',
+            accelerator: 'Command+X',
+            selector: 'cut:'
+          },
+          {
+            label: 'Copy',
+            accelerator: 'Command+C',
+            selector: 'copy:'
+          },
+          {
+            label: 'Paste',
+            accelerator: 'Command+V',
+            selector: 'paste:'
+          },
+          {
+            label: 'Select All',
+            accelerator: 'Command+A',
+            selector: 'selectAll:'
+          },
+        ]
+      },
+      {
+        label: 'View',
+        submenu: [
+          {
+            label: 'Reload',
+            accelerator: 'Command+R',
+            click: function() { BrowserWindow.getFocusedWindow().restart(); }
+          },
+          {
+            label: 'Enter Fullscreen',
+            click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); }
+          },
+          {
+            label: 'Toggle DevTools',
+            accelerator: 'Alt+Command+I',
+            click: function() { BrowserWindow.getFocusedWindow().toggleDevTools(); }
+          },
+        ]
+      },
+      {
+        label: 'Window',
+        submenu: [
+          {
+            label: 'Minimize',
+            accelerator: 'Command+M',
+            selector: 'performMiniaturize:'
+          },
+          {
+            label: 'Close',
+            accelerator: 'Command+W',
+            selector: 'performClose:'
+          },
+          {
+            type: 'separator'
+          },
+          {
+            label: 'Bring All to Front',
+            selector: 'arrangeInFront:'
+          },
+        ]
+      },
+    ];
 
-  menu = Menu.buildFromTemplate(template);
-
-  if (process.platform == 'darwin')
+    menu = Menu.buildFromTemplate(template);
     Menu.setApplicationMenu(menu);
-  else
+  } else {
+    var template = [
+      {
+        label: 'File',
+        submenu: [
+          {
+            label: 'Open',
+            accelerator: 'Command+O',
+          },
+          {
+            label: 'Close',
+            accelerator: 'Command+W',
+            click: function() { mainWindow.close(); }
+          },
+        ]
+      },
+      {
+        label: 'View',
+        submenu: [
+          {
+            label: 'Reload',
+            accelerator: 'Command+R',
+            click: function() { mainWindow.restart(); }
+          },
+          {
+            label: 'Enter Fullscreen',
+            click: function() { mainWindow.setFullscreen(true); }
+          },
+          {
+            label: 'Toggle DevTools',
+            accelerator: 'Alt+Command+I',
+            click: function() { mainWindow.toggleDevTools(); }
+          },
+        ]
+      },
+    ];
+
+    menu = Menu.buildFromTemplate(template);
     mainWindow.setMenu(menu);
+  }
 
   ipc.on('message', function(processId, routingId, type) {
-    console.log(type);
     if (type == 'menu')
       menu.popup(mainWindow);
   });