mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 17:13:45 +03:00
Revert "Dynamically replace Atom version in application menu"
This reverts commit 9b7bc34d44
.
This commit is contained in:
parent
9b7bc34d44
commit
8682bad958
@ -3,7 +3,7 @@
|
||||
label: 'Atom'
|
||||
submenu: [
|
||||
{ label: 'About Atom', command: 'application:about' }
|
||||
{ label: "VERSION", enabled: false }
|
||||
{ label: "Version #{@version}", enabled: false }
|
||||
{ label: "Install update", command: 'application:install-update', visible: false }
|
||||
{ type: 'separator' }
|
||||
{ label: 'Preferences...', command: 'application:show-settings' }
|
||||
|
@ -24,8 +24,7 @@ class ApplicationMenu
|
||||
# An Object where the keys are commands and the values are Arrays containing
|
||||
# the keystrokes.
|
||||
update: (template, keystrokesByCommand) ->
|
||||
@translateTemplate(template, keystrokesByCommand)
|
||||
@substituteVersion(template)
|
||||
@translateTemplate template, keystrokesByCommand
|
||||
@menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(@menu)
|
||||
|
||||
@ -35,24 +34,11 @@ class ApplicationMenu
|
||||
# A complete menu configuration object for atom-shell's menu API.
|
||||
#
|
||||
# Returns an Array of native menu items.
|
||||
flattenMenuItems: (menu) ->
|
||||
allItems: (menu=@menu) ->
|
||||
items = []
|
||||
for index, item of menu.items or {}
|
||||
items.push(item)
|
||||
items = items.concat(@flattenMenuItems(item.submenu)) if item.submenu
|
||||
items
|
||||
|
||||
# Private: Flattens the given menu template into an single Array.
|
||||
#
|
||||
# * template:
|
||||
# An object describing the menu item.
|
||||
#
|
||||
# Returns an Array of native menu items.
|
||||
flattenMenuTemplate: (template) ->
|
||||
items = []
|
||||
for item in template
|
||||
items.push(item)
|
||||
items = items.concat(@flattenMenuTemplate(item.submenu)) if item.submenu
|
||||
items = items.concat(@allItems(item.submenu)) if item.submenu
|
||||
items
|
||||
|
||||
# Public: Used to make all window related menu items are active.
|
||||
@ -61,14 +47,9 @@ class ApplicationMenu
|
||||
# If true enables all window specific items, if false disables all window
|
||||
# specific items.
|
||||
enableWindowSpecificItems: (enable) ->
|
||||
for item in @flattenMenuItems(@menu)
|
||||
for item in @allItems()
|
||||
item.enabled = enable if item.metadata?['windowSpecific']
|
||||
|
||||
# Private: Replaces VERSION with the current version.
|
||||
substituteVersion: (template) ->
|
||||
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
|
||||
@ -79,9 +60,10 @@ class ApplicationMenu
|
||||
# * 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
|
||||
downloadUpdateItem = _.find @allItems(), (item) -> item.label == 'Install update'
|
||||
if downloadUpdateItem
|
||||
downloadUpdateItem.visible = true
|
||||
downloadUpdateItem.click = quitAndUpdateCallback
|
||||
|
||||
# Private: Default list of menu items.
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user