Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
integrate mac's menubar item about/preference to current about page
Browse files Browse the repository at this point in the history
  • Loading branch information
yjlintw committed May 10, 2017
1 parent e862fa2 commit c5451d8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
27 changes: 20 additions & 7 deletions main-process/menu/mainmenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const {app, Menu} = require('electron')
const path = require('path')
var openAboutWindow = require('about-window').default;

// var openAboutWindow = require('about-window').default;
// Support only macOS for now. Don't have a windows machine to test the menu.
if (process.platform === 'darwin') {
const name = app.getName()
Expand All @@ -10,13 +9,26 @@ if (process.platform === 'darwin') {
submenu: [
{
label: `About ${name}`,
click() {
openAboutWindow({
win_options: {minimizable: false, maximizable: false, fullscreen: false},
icon_path: path.join('file://', __dirname, '../../assets/icons/icon.png')
})
click: function(item, focusedWindow) {
console.log(focusedWindow.webContents);
let main_web_contents = focusedWindow.webContents;
main_web_contents.send("open-about");
}
},
{ type: 'separator' },
{
label: 'Preferences',
accelerator: (function() {
if (process.platform === 'darwin') {
return 'Command+,';
}
})(),
click: function(item, focusedWindow) {
console.log(focusedWindow.webContents);
let main_web_contents = focusedWindow.webContents;
main_web_contents.send("open-about");
}
},
{
label: 'Toggle Developer Tools',
accelerator: (function () {
Expand All @@ -40,3 +52,4 @@ if (process.platform === 'darwin') {
Menu.setApplicationMenu(menu)
}


4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ function createWindow () {
})

autoUpdater.checkForUpdates();
require('./main-process/menu/mainmenu')
let mainmenu = require('./main-process/menu/mainmenu')
// console.log("set main_window");
// mainmenu.main_window = win;
}

autoUpdater.on('checking-for-update', () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "comic-reader",
"productName": "Comic Reader",
"author": "Team Comic Reader",
"version": "0.1.35",
"version": "0.1.36",
"description": "Quickly, smoothly and cooler reading experience. The best move to read comics.",
"main": "main.js",
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
var read_viewcontroller = require('./read-viewcontroller');
var titlebar_viewcontroller = require('./titlebar-viewcontroller');
const EA = require("electron-analytics");
const ipc = require('electron').ipcRenderer;

// Variable definition
var updateAllUIFunc;
Expand Down Expand Up @@ -110,6 +111,11 @@ $(document).ready(function() {
$(".sidebar .entry").click(onTabEntryClick);
});

ipc.on("open-about", function(event) {
console.log("open-about received");
tabswitch(TAB_NAME.ABOUT);
});


module.exports = {
TAB_NAME: TAB_NAME,
Expand Down

0 comments on commit c5451d8

Please sign in to comment.