diff --git a/src/pane-view.coffee b/src/pane-view.coffee index d5644f652..97b28b2b8 100644 --- a/src/pane-view.coffee +++ b/src/pane-view.coffee @@ -141,13 +141,18 @@ class PaneView extends View @activeItem onActiveItemChanged: (item) => - @previousActiveItem?.off? 'title-changed', @activeItemTitleChanged + if @previousActiveItem?.off? + @previousActiveItem.off 'title-changed', @activeItemTitleChanged + @previousActiveItem.off 'modified-status-changed', + @activeItemModifiedChanged @previousActiveItem = item return unless item? hasFocus = @hasFocus() - item.on? 'title-changed', @activeItemTitleChanged + if item.on? + item.on 'title-changed', @activeItemTitleChanged + item.on 'modified-status-changed', @activeItemModifiedChanged view = @viewForItem(item) otherView.hide() for otherView in @itemViews.children().not(view).views() @itemViews.append(view) unless view.parent().is(@itemViews) @@ -183,6 +188,9 @@ class PaneView extends View activeItemTitleChanged: => @trigger 'pane:active-item-title-changed' + activeItemModifiedChanged: => + @trigger 'pane:active-item-modified-changed' + viewForItem: (item) -> return unless item? if item instanceof $ diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 4206e9f83..1c068ea38 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -110,6 +110,7 @@ class WorkspaceView extends View atom.project.on 'path-changed', => @updateTitle() @on 'pane-container:active-pane-item-changed', => @updateTitle() @on 'pane:active-item-title-changed', '.active.pane', => @updateTitle() + @on 'pane:active-item-modified-changed', '.active.pane', => @updateDocumentEdited() @command 'application:about', -> ipc.send('command', 'application:about') @command 'application:run-all-specs', -> ipc.send('command', 'application:run-all-specs') @@ -210,19 +211,29 @@ class WorkspaceView extends View confirmClose: -> @panes.confirmClose() - # Updates the application's title, based on whichever file is open. + # Updates the application's title and proxy icon based on whichever file is + # open. updateTitle: -> if projectPath = atom.project.getPath() if item = @getModel().getActivePaneItem() - @setTitle("#{item.getTitle?() ? 'untitled'} - #{projectPath}") + title = "#{item.getTitle?() ? 'untitled'} - #{projectPath}" + proxyIconPath = item.getPath?() ? '' + @setTitle(title, proxyIconPath) else - @setTitle(projectPath) + @setTitle(projectPath, projectPath) else @setTitle('untitled') - # Sets the application's title. - setTitle: (title) -> + # Sets the application's title (and the proxy icon on OS X) + setTitle: (title, proxyIconPath) -> document.title = title + atom.getCurrentWindow().setRepresentedFilename(proxyIconPath ? '') + + # On OS X, fades the application window's proxy icon when the current file + # has been modified. + updateDocumentEdited: -> + modified = @getModel().getActivePaneItem()?.isModified?() ? false + atom.getCurrentWindow().setDocumentEdited modified # Get all editor views. #