141 Commits

Author SHA1 Message Date
Allan Odgaard
7e69f5bb2c Fix compiler warnings by initializing struct members in correct order 2021-02-04 09:35:27 +01:00
Allan Odgaard
8e6c60d013 build: Remove Info.plist files from frameworks
These were previously required when we built frameworks as dynamically linked, but the files are now explicitly ignored by our build system.
2021-01-24 10:37:22 +01:00
Allan Odgaard
6b6ff32e99 Avoid compiler warning by typecasting anonymous enum
The warning only appears when the anonymous enum is used in a conditional, hence why we do not need this change for all calls to NSFileTypeForHFSTypeCode.
2021-01-17 14:06:36 +01:00
Allan Odgaard
4e4d8ff352 File browser’s field editor (rename) would stay after pressing return
This problem started after f1a1e1920f (handling key equivalents in performKeyEquivalent: instead of keyDown:).

It does however not appear that it is necessary to manually handle the return key to activate editing, therefore we have removed handling of this key.

Most likely it was required before view-based table views.
2020-06-12 21:34:40 +07:00
Allan Odgaard
a11625421a Add “Create Link to Items” file browser context menu action
This will create symbolic links to the files on the clipboard.

It is equivalent to holding down control (⌃) when dropping files on the file browser.
2020-06-09 16:48:37 +07:00
Allan Odgaard
0f219bae4b Set (visible) key equivalents for file browser context menu
Some of the items require the key equivalent to be set as “inactive” as menu item keys are “global” and thus need to be unique, and can be triggered even when the view containing the context menu is not active.
2020-06-09 16:48:37 +07:00
Allan Odgaard
6e35cb98e1 Only update file browser menu item titles when it is the explicit target
Previously “Paste Next” in the Edit → Paste submenu could have its title updated to “Move Item Here”, which would never be restored back to “Paste Next”, similarly for regular paste.

This commit also drops the wrappers for the cut:, copy:, paste:, and delete: methods, as these wrappers resulted in a bit of redundancy related to menu item validation.
2020-06-09 16:48:37 +07:00
Allan Odgaard
b0228b9aff Remove redundant target setting from file browser context menu
We set target for all items in the menu during post-processing.
2020-06-09 16:48:37 +07:00
Allan Odgaard
f97946244a Let file browser call copyAsPathname: when seeing ⌥⌘C
We cannot do this via a menu item because this key equivalent is already used for Ignore Case in the Edit → Find → Find Options menu.
2020-06-09 16:48:37 +07:00
Allan Odgaard
f1a1e1920f Handle file browser shortcuts in performKeyEquivalent:
This is called before the main menu acts on keys, and thus allows us to catch keys that are otherwise assigned to menu items.

We only do this when the file browser is first responder, so it should be acceptable to have a few menu keys change behavior in that case.
2020-06-09 16:48:37 +07:00
Allan Odgaard
4ec10c0923 Don’t annotate types and classes with PUBLIC
This was required when we linked each framework as its own thing, which we do not do anymore, and if we do go back to this system, we can simply have symbols public by default.
2020-06-05 21:22:50 +07:00
Allan Odgaard
b1e41a7f5f Abort iterating over parent URLs if the path string grows in length
It appears that NSURL’s algorithm for “delete last path component” is to first append ‘../’ and then “normalize” the result, but the latter step can fail for some file URLs, for example with “file://localhost/path/to/https://macromates.com/” it will be stuck at the two slashes (continuing to append ‘../’).

Such malformed (file) URL can be created by running ‘mate https://macromates.com/’.
2020-05-30 10:02:52 +07:00
Allan Odgaard
eaad76f83d Minor tweak of log message 2020-05-30 09:54:30 +07:00
Allan Odgaard
d500f6e53d Remove support for initial first responder in OakSetupKeyViewLoop 2020-05-25 12:47:47 +07:00
Allan Odgaard
b693db4fd1 Use NSDictionary for SCM repository variables (instead of std::map) 2020-05-22 21:48:09 +07:00
Allan Odgaard
ad1cc8abd8 Deliver all NSUserDefaultsDidChangeNotification in main queue
This is easier than ensuring that we do not update user defaults from a background thread.
2020-05-14 09:52:38 +07:00
Allan Odgaard
cb4c12681e Use NSNotificationName as type of all our notification names 2020-05-04 19:20:04 +07:00
Allan Odgaard
f0b48ba736 Fix a few double trailing semi-colons 2020-05-04 19:20:04 +07:00
Allan Odgaard
f8c9ee079f Copy callbacks array before enumerating it (and invoking the callbacks)
This is incase a callback makes changes to the callback array, as that is not supported for fast enumerations.
2020-04-30 14:40:55 +07:00
Allan Odgaard
e4f61f12b7 Change a few leading spaces to tabs 2020-04-30 13:28:24 +07:00
Allan Odgaard
decb7f96ee Set wantsLayer to YES for file browser header view
This is required on macOS 10.12.
2020-04-29 08:02:02 +07:00
Allan Odgaard
f06161b395 Do not set content hugging and compression resistance for image button 2020-04-28 09:52:10 +07:00
Allan Odgaard
6e6dbd4a1e Ensure label colors are aligned between open and non-open files 2020-04-28 09:52:10 +07:00
Allan Odgaard
ce651e8acb Ensure labels are rendered as selected when table row is emphasized 2020-04-28 09:52:10 +07:00
Allan Odgaard
17aada3471 Let FileItemTableCellView give access to its close button via a property
This is simpler than having to proxy the action (and target) for the button.

Previously the button was created on demand, but now that we always create it (and hide it when not required), we might as well have users set action and target directly on the button instance.
2020-04-28 09:52:10 +07:00
Allan Odgaard
05a50a436b Use NSStackView for our file browser items
Minor downside is that labels for open and closed files are no longer aligned.

It would be nice to find a solution for that, but without dropping the stack view, as it saves us > 100 lines of code.
2020-04-28 09:52:10 +07:00
Allan Odgaard
19624f0fd8 Use NSStackView for tag buttons in file browser menu 2020-04-28 09:52:10 +07:00
Allan Odgaard
33424bfdf4 Improve how we check if notification is sent from one of our tag buttons 2020-04-28 09:52:10 +07:00
Allan Odgaard
715d023673 Declare “sharedInstance” as a class property 2020-04-23 12:25:11 +07:00
Allan Odgaard
4e0cb76985 fixup! Convert to reference URL for file browser’s “Select Current Document” 2020-04-18 15:22:13 +07:00
Allan Odgaard
36489aa076 Rename (internal) API method
This might be closer to Cocoa naming conventions.
2020-04-17 19:19:53 +07:00
Allan Odgaard
3668245163 Convert to reference URL for file browser’s “Select Current Document”
This fixes problems with symbolic links, for example file browser may show contents of /private/tmp when we ask to select /tmp/foo.txt. Comparing file path URLs will fail even though /tmp is a symbolic link for /private/tmp.

Note that this fix only works for when the current document is already part of the items in the file browser, as we still store pending URLs to select as file path URLs.
2020-04-14 12:58:10 +07:00
Allan Odgaard
c682655d4a Use readObjectsForClasses: with NSURL instead of NSFilenamesPboardType 2020-04-14 12:58:10 +07:00
Allan Odgaard
e1fdc852e4 Make sure URLs placed on the undo stack are file path URLs
Incase of a file reference URL, moving an item will have the URL resolve to the new file path, therefore such URL cannot be used for storing the old location/path of the item.

This is currently not a problem with TextMate, as all URLs are file path URLs, but as we are moving to using readObjectsForClasses: with NSURL, we will be receiving file reference URLs from Finder.
2020-04-14 12:58:10 +07:00
Allan Odgaard
969c541202 Fix copying files from file browser and pasting in Terminal.app
Terminal.app is peculiar about what it expects to be on the clipboard. If we only write URLs like this:

	[pboard clearContents];
	[pboard writeObjects:urls];

Then it will not paste anything. There *must* be string fallbacks for it to support paste. But if we also write an array of strings like this:

	[pboard clearContents];
	[pboard writeObjects:urls];
	[pboard writeObjects:[urls valueForKeyPath:@"path.lastPathComponent"]];

Then it will paste both the URLs and the strings, but where the URLs will be space-separated, the strings will not. If instead we write a single string fallback only for the first item, like this:

	[pboard clearContents];
	[pboard writeObjects:urls];
	[pboard setString:@"whatever" forType:NSPasteboardTypeString];

Then it will paste the URLs and ignore the string fallback for the first URL.
2020-04-14 12:58:10 +07:00
Allan Odgaard
4a1e9113f3 Make file browser state API wrap the system UI restoration methods
This avoids duplicating code, although for compatibility with old saved state, we still can restore state from a dictionary.
2020-04-14 12:58:10 +07:00
Allan Odgaard
61ec959b37 Change data type of file browser state from dictionary to opaque object
This gives us more flexibility in how we wish to represent the state, although the state should be a property list object.
2020-04-14 12:58:10 +07:00
Allan Odgaard
ac903a1fa8 Add API to observe changes to a single file
While in theory just a wrapper for VNODE events, there are some edge cases:

- Observe missing file: Report when created (observe all ancestors to know).
- Rename ancestor: Treat as rename (observe all ancestors to know).
- Move observed file to trash: Treat as delete (reported as rename).
- Rename file with symbolic link in path (e.g. /tmp): Preserve symbolic path.
- Delete observed file and write new one: Treat as a write (reported as delete).
- Rename observed file and write new one: Treat as a write (reported as rename).
- Change case of file: Tricky on case-insensitive but preserving file systems because newPath != oldPath but both exist, so it looks the same as “rename and write new file” (previous case) that should be reported as write.

There is also an issue observing a symbolic link, here we should really observe both the link itself (does it get renamed or deleted) but also the resolved path (does this file get updated).

Currently though this is NOT implemented.
2020-04-14 12:58:10 +07:00
Allan Odgaard
4013020b14 Use dot syntax for NSNumber’s boolValue property 2020-04-14 12:58:10 +07:00
Allan Odgaard
be29a7711a Export the SCMManager from FileBrowser framework
This should probably be its own framework, but nothing beyond the file browser is currently using the SCMManager.
2020-04-14 12:58:10 +07:00
Allan Odgaard
eccbb81e8a Constrain height of vertical dividers and remove intrinsic height
Previously some status bars could be compressed vertically because the dividers did not have a fixed height, so they were sized based on their intrinsic height.

With a fixed height the intrinsic height is redundant and previously it was simply hiding an issue with an under-constrained layout, so better just remove them.
2020-04-14 12:58:10 +07:00
Allan Odgaard
e490b86c47 Make horizontal dividers subviews of status bar (NSVisualEffectView)
This makes the color of the separator bar better adapt to the color of the status bar and should make things more consistent, as we already have separators inside visual effect views in various places.

Also adjust height of the vertical separators in status bars to only be 15 pixels so that we have equal padding above and below.
2020-03-29 10:23:42 +07:00
Allan Odgaard
07c8a76abd Use OakCreateNSBoxSeparator() for file browser’s actions view
This is instead of the more opaque OakCreateHorizontalLine(OakBackgroundFillViewStyleDivider).
2020-03-29 10:21:30 +07:00
Allan Odgaard
7d0a1dea74 Use OakCreateNSBoxSeparator() for file browser view
This is instead of the more opaque OakCreateHorizontalLine(OakBackgroundFillViewStyleDivider).
2020-03-29 10:21:30 +07:00
Allan Odgaard
33b615fd14 Let OFBHeaderView be NSVisualEffectView subclass with titlebar material
Previously it was a subclass of OakBackgroundFillView which adds the NSVisualEffectView as a subview, but this messes up compositing in some cases where an ancestor view is also an NSVisualEffectView, for example when placing the file browser in a “source list” split view item (using NSSplitViewController).

Also change the material to NSVisualEffectMaterialTitlebar. I think this looks better, as the previously used NSVisualEffectMaterialHeaderView does not look identical to other table view headers and only have very faint bottom border but very noticeable “within window” compositing.

A further advantage of changing to title bar material is that NSVisualEffectMaterialHeaderView requires macOS 10.14, so by using title bar material, we avoid having a different code path for users using older versions of macOS.
2020-03-29 10:21:30 +07:00
Allan Odgaard
e7ea79cffe Use OakCreateNSBoxSeparator() instead of OakCreateDividerImageView()
The latter is a wrapper around an NSBoxSeparator, only adding some size constraints.
2020-03-29 10:21:27 +07:00
Allan Odgaard
7adf668773 Always setup file browser scroll view to inset content based on header
Previously we would only do this on macOS 10.14 and later, but as we now also use “within window” compositing for the header view prior to macOS 10.14, we should always inset the scroll view.

Furthermore, even without “within window” compositing, insetting the scroll view should not cause any issues, so the code was actually not required previously.
2020-03-20 16:18:12 +07:00
Allan Odgaard
0545f02620 Add support for NSRestorableState to FileBrowserViewController 2020-03-13 16:39:15 +07:00
Allan Odgaard
2410ba345f Refactoring: Move logic from FileBrowserView → FileBrowserViewController
This is to make it easier to support Cocoa’s native resume feature, as for this, we should keep all state in the controller, but also, the controller should be able to know if view state changes, for example expanded/selected items in the outline view, which require our controller to be the delegate.
2020-03-11 21:22:25 +07:00
Allan Odgaard
fa9e690309 Formatting: Align closing braces 2020-03-11 14:08:53 +07:00