@@ -120,17 +120,8 @@ final class ViewController: NSViewController {
120120 tableView. reloadData ( )
121121 }
122122
123- private func openFolder( ) {
124- let openPanel = NSOpenPanel ( )
125- openPanel. allowsMultipleSelection = false
126- openPanel. canChooseDirectories = true
127- openPanel. canCreateDirectories = true
128- openPanel. canChooseFiles = false
129- openPanel. begin { [ unowned self] result -> Void in
130- guard result. rawValue == NSApplication . ModalResponse. OK. rawValue, let url = openPanel. url else {
131- return
132- }
133-
123+ private func openFolder( forPath path: String ? = nil ) {
124+ let handleOpenFolder : ( URL ) -> Void = { url in
134125 self . progressIndicator. startAnimation ( self )
135126 self . dataSource. load ( folder: url) { [ unowned self] languages, title, localizationFiles in
136127 self . reloadData ( with: languages, title: title)
@@ -142,6 +133,22 @@ final class ViewController: NSViewController {
142133 }
143134 }
144135 }
136+
137+ if let path = path {
138+ handleOpenFolder ( URL ( fileURLWithPath: path) )
139+ } else {
140+ let openPanel = NSOpenPanel ( )
141+ openPanel. allowsMultipleSelection = false
142+ openPanel. canChooseDirectories = true
143+ openPanel. canCreateDirectories = true
144+ openPanel. canChooseFiles = false
145+ openPanel. begin { result -> Void in
146+ guard result. rawValue == NSApplication . ModalResponse. OK. rawValue, let url = openPanel. url else {
147+ return
148+ }
149+ handleOpenFolder ( url)
150+ }
151+ }
145152 }
146153}
147154
@@ -253,6 +260,13 @@ extension ViewController: WindowControllerToolbarDelegate {
253260 func userDidRequestFolderOpen( ) {
254261 openFolder ( )
255262 }
263+
264+ /**
265+ Invoked when user requests opening a folder for specific path
266+ */
267+ func userDidRequestFolderOpen( withPath path: String ) {
268+ openFolder ( forPath: path)
269+ }
256270}
257271
258272// MARK: - AddViewControllerDelegate
0 commit comments