Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Support for save and save as #24

Merged
merged 18 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Desktop application for [Glyphr Studio](http://glyphrstudio.com) built in [Elect

## Download

- [Mac 64-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-darwin-x64.zip)
- [Windows 64-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-win32-x64.zip)
- [Windows 32-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-win32-ia32.zip)
- [Linux 64-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-linux-x64.zip)
- [Linux 32-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-linux-ia32.zip)
- [Linux 64-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-linux-x64.zip)
- [macOS](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-darwin-x64.zip)
- [Windows 32-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-win32-ia32.zip)
- [Windows 64-bit](https://github.com/glyphr-studio/Glyphr-Studio-Desktop/releases/download/v0.4.1/Glyphr.Studio-win32-x64.zip)

## How to run from source

Expand Down Expand Up @@ -43,12 +43,16 @@ All Platforms: `npm run build`

64-Bit Platforms Only: `npm run build -- -64`

macOS: `npm run build -- -mac`
Linux 32-Bit: `npm run build -- -linux32`

Windows 64-Bit: `npm run build -- -win`
Linux 64-Bit: `npm run build -- -linux`

macOS: `npm run build -- -mac`

Windows 32-Bit: `npm run build -- -win32`

Linux 64-Bit: `npm run build -- -linux`
Windows 64-Bit: `npm run build -- -win`

Linux 32-Bit: `npm run build -- -linux32`
## Troubleshooting

Ubuntu users may need to `sudo apt install libgconf-2-4` in order to run the app.
123 changes: 114 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,116 @@
const electron = require('electron')
const {app} = electron
const {BrowserWindow} = electron
const {app, BrowserWindow, Menu} = electron
const open = require('open')
const path = require('path')

// menu template
const template = [
{
label: 'File',
submenu: [
{
label: 'Save',
accelerator: 'CmdOrCtrl+S',
enabled: false,
click () {
win.webContents.send('save', '')
}
},
{
label: 'Save As',
accelerator: 'CmdOrCtrl+Shift+S',
enabled: false,
click () {
win.webContents.send('saveas', '')
}
}
]
},
{
label: 'Edit',
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
]
},
{
label: 'View',
submenu: [
{role: 'resetzoom'},
{role: 'zoomin'},
{role: 'zoomout'},
{type: 'separator'},
{role: 'togglefullscreen'}
]
},
{
role: 'window',
submenu: [
{role: 'minimize'},
{role: 'close'}
]
},
{
role: 'help',
submenu: [
{
label: 'Learn More',
click () {
electron.shell.openExternal('http://glyphrstudio.com')
}
}
]
}
]

if (process.platform === 'darwin') {
template.unshift({
label: 'Glyphr Studio',
submenu: [
{role: 'about'},
{type: 'separator'},
{role: 'services', submenu: []},
{type: 'separator'},
{role: 'hide'},
{role: 'hideothers'},
{role: 'unhide'},
{type: 'separator'},
{role: 'quit'}
]
})

// Window menu
template[3].submenu = [
{role: 'close'},
{role: 'minimize'},
{role: 'zoom'},
{type: 'separator'},
{role: 'front'}
]
}

let win

function createWindow () {
win = new BrowserWindow({
width: 1000,
height: 700,
minWidth: 1000,
minHeight: 700,
width: 1300,
height: 900,
minWidth: 1300,
minHeight: 900,
icon: process.platform === 'linux' && path.join(__dirname, '/images/appicon.png')
})
win.loadURL(path.join('file://', __dirname, '/node_modules/Glyphr-Studio/dev/Glyphr_Studio_Electron.html'))

let webContents = win.webContents

// enable for debugging
// win.webContents.openDevTools();

webContents.on('new-window', function (event, url) {
event.preventDefault()
open(url)
Expand All @@ -26,18 +119,30 @@ function createWindow () {
win.on('closed', function () {
win = null
})

const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}

app.on('ready', createWindow)

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
app.quit()
})

app.on('activate', function () {
if (win === null) {
createWindow()
}
})

app.on('enableSaveMenu', function () {
let i = 0
if (process.platform === 'darwin') {
i = 1
}
template[i].submenu[0].enabled = true
template[i].submenu[1].enabled = true
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
})
47 changes: 42 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
{
"name": "glyphr-studio-desktop",
"version": "0.4.1",
"productName": "Glyphr Studio",
"version": "0.4.2",
"description": "A desktop client for Glyphr Studio",
"author": "Troy Coutu <[email protected]>",
"author": "Glyphr Studio team <[email protected]>",
"contributors": [
"Matt LaGrandeur <[email protected]>",
"Mateusz Zawartka <[email protected]>",
"Troy Coutu <[email protected]>",
"Eric Newport <[email protected]>"
],
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/glyphr-studio/Glyphr-Studio-Desktop.git"
},
"main": "main.js",
"dependencies": {
"Glyphr-Studio": "glyphr-studio/Glyphr-Studio-1#v1.09.01",
"Glyphr-Studio": "glyphr-studio/Glyphr-Studio-1#v1.09.02",
"electron-editor-context-menu": "1.1.1",
"open": "0.0.5"
},
"devDependencies": {
"archiver": "2.0.3",
"electron": "1.7.9",
"electron": "1.7.10",
"electron-packager": "10.1.0",
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"standard": "^10.0.3"
"husky": "0.14.3",
"lint-staged": "6.0.0",
"standard": "10.0.3"
},
"standard": {
"globals": [
Expand Down
Loading