mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-29 09:34:58 +03:00
Add 'Check for Updates' menu item
This commit is contained in:
parent
cc233fb7f6
commit
caeb70cf4a
@ -4,7 +4,8 @@
|
||||
submenu: [
|
||||
{ label: 'About Atom', command: 'application:about' }
|
||||
{ label: "VERSION", enabled: false }
|
||||
{ label: "Install update", command: 'application:install-update', visible: false }
|
||||
{ label: "Restart and Install Update", command: 'application:install-update', visible: false}
|
||||
{ label: "Check for Update", command: 'application:check-for-update'}
|
||||
{ type: 'separator' }
|
||||
{ label: 'Preferences...', command: 'application:show-settings' }
|
||||
{ label: 'Open Your Config', command: 'application:open-your-config' }
|
||||
|
@ -69,19 +69,13 @@ class ApplicationMenu
|
||||
if (item = _.find(@flattenMenuTemplate(template), (i) -> i.label == 'VERSION'))
|
||||
item.label = "Version #{@version}"
|
||||
|
||||
# Public: Makes the download menu item visible if available.
|
||||
#
|
||||
# Note: The update menu item's must match 'Install update' exactly otherwise
|
||||
# this function will fail to work.
|
||||
#
|
||||
# * newVersion:
|
||||
# FIXME: Unused.
|
||||
# * quitAndUpdateCallback:
|
||||
# Function to call when the install menu item has been clicked.
|
||||
showDownloadUpdateItem: (newVersion, quitAndUpdateCallback) ->
|
||||
if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Install update'))
|
||||
item.visible = true
|
||||
item.click = quitAndUpdateCallback
|
||||
showInstallUpdateItem: (visible=true) ->
|
||||
if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Restart and Install Update'))
|
||||
item.visible = visible
|
||||
|
||||
showCheckForUpdateItem: (visible=true) ->
|
||||
if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Check for Update'))
|
||||
item.visible = visible
|
||||
|
||||
# Private: Default list of menu items.
|
||||
#
|
||||
|
@ -140,6 +140,30 @@ class AtomApplication
|
||||
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
checkForUpdate: ->
|
||||
autoUpdater.once 'update-available', ->
|
||||
dialog.showMessageBox
|
||||
type: 'info'
|
||||
buttons: ['OK']
|
||||
message: 'Update available.'
|
||||
detail: 'A new update is being downloading.'
|
||||
|
||||
autoUpdater.once 'update-not-available', =>
|
||||
dialog.showMessageBox
|
||||
type: 'info'
|
||||
buttons: ['OK']
|
||||
message: 'No update available.'
|
||||
detail: "Version #{@version} is the latest version."
|
||||
|
||||
autoUpdater.once 'error', (event, message)->
|
||||
dialog.showMessageBox
|
||||
type: 'warning'
|
||||
buttons: ['OK']
|
||||
message: 'There was an error checking for updates.'
|
||||
detail: message
|
||||
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
# Private: Registers basic application commands, non-idempotent.
|
||||
handleEvents: ->
|
||||
@on 'application:about', -> Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:')
|
||||
@ -159,6 +183,8 @@ class AtomApplication
|
||||
@on 'application:inspect', ({x,y}) -> @focusedWindow().browserWindow.inspectElement(x, y)
|
||||
@on 'application:open-documentation', -> shell.openExternal('https://www.atom.io/docs/latest/?app')
|
||||
@on 'application:report-issue', -> shell.openExternal('https://github.com/atom/atom/issues/new')
|
||||
@on 'application:install-update', -> autoUpdater.quitAndInstall()
|
||||
@on 'application:check-for-update', => @checkForUpdate()
|
||||
|
||||
@openPathOnEvent('application:show-settings', 'atom://config')
|
||||
@openPathOnEvent('application:open-your-config', 'atom://.atom/config')
|
||||
|
Loading…
Reference in New Issue
Block a user