mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add Project::onDidChangePaths event
This commit is contained in:
@@ -620,7 +620,7 @@ class Atom extends Model
|
||||
watchProjectPath: ->
|
||||
onProjectPathChanged = =>
|
||||
ipc.send('window-command', 'project-path-changed', @project.getPaths()[0])
|
||||
@subscribe @project, 'path-changed', onProjectPathChanged
|
||||
@subscribe @project.onDidChangePaths(onProjectPathChanged)
|
||||
onProjectPathChanged()
|
||||
|
||||
exit: (status) ->
|
||||
|
||||
@@ -6,7 +6,8 @@ fs = require 'fs-plus'
|
||||
Q = require 'q'
|
||||
{deprecate} = require 'grim'
|
||||
{Model} = require 'theorist'
|
||||
{Emitter, Subscriber} = require 'emissary'
|
||||
{Subscriber} = require 'emissary'
|
||||
{Emitter} = require 'event-kit'
|
||||
Serializable = require 'serializable'
|
||||
TextBuffer = require 'text-buffer'
|
||||
{Directory} = require 'pathwatcher'
|
||||
@@ -35,6 +36,7 @@ class Project extends Model
|
||||
###
|
||||
|
||||
constructor: ({path, paths, @buffers}={}) ->
|
||||
@emitter = new Emitter
|
||||
@buffers ?= []
|
||||
|
||||
for buffer in @buffers
|
||||
@@ -69,6 +71,19 @@ class Project extends Model
|
||||
params.buffers = params.buffers.map (bufferState) -> atom.deserializers.deserialize(bufferState)
|
||||
params
|
||||
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
###
|
||||
|
||||
onDidChangePaths: (callback) ->
|
||||
@emitter.on 'did-change-paths', callback
|
||||
|
||||
on: (eventName) ->
|
||||
if eventName is 'path-changed'
|
||||
Grim.deprecate("Use Project::onDidChangePaths instead")
|
||||
super
|
||||
|
||||
###
|
||||
Section: Accessing the git repository
|
||||
###
|
||||
@@ -112,6 +127,7 @@ class Project extends Model
|
||||
@rootDirectory = null
|
||||
|
||||
@emit "path-changed"
|
||||
@emitter.emit 'did-change-paths', projectPaths
|
||||
setPath: (path) ->
|
||||
Grim.deprecate("Use ::setPaths instead")
|
||||
@setPaths([path])
|
||||
|
||||
@@ -102,7 +102,7 @@ class WorkspaceView extends View
|
||||
@subscribe $(window), 'focus', (e) =>
|
||||
@handleFocus(e) if document.activeElement is document.body
|
||||
|
||||
atom.project.on 'path-changed', => @updateTitle()
|
||||
atom.project.onDidChangePaths => @updateTitle()
|
||||
@on 'pane-container:active-pane-item-changed', => @updateTitle()
|
||||
@on 'pane:active-item-title-changed', '.active.pane', => @updateTitle()
|
||||
@on 'pane:active-item-modified-status-changed', '.active.pane', => @updateDocumentEdited()
|
||||
|
||||
Reference in New Issue
Block a user