126 Commits

Author SHA1 Message Date
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
Allan Odgaard
3ca83220bb Add URL property to FileBrowserViewController
This should be used instead of path, as we may display non-file URLs.
2020-03-11 13:35:04 +07:00
Allan Odgaard
4b4e5fca8b Remove code required for compatibility with 10.10 and earlier 2019-10-07 21:28:16 +02:00
Allan Odgaard
5e96d41a3d Look for numeric prefix when duplicating a file and increase it if found
For example if we have a directory with files named 001-foo.txt, 002-bar.txt, and 003-fud.txt, duplicating one of these will result in the duplicate starting with 004.

Also improve support for finding dates in file names being duplicated. Previously we only looked for YYYY-MM-DD but now we also support YYYY_MM_DD and YYYYMMDD. If a date is found in the file name being duplicated, it is replaced with the current date in the duplicate.
2019-08-08 21:37:42 +02:00
Allan Odgaard
f33ba968a8 Don’t ignore result from writeObjects: 2019-08-02 21:07:04 +02:00
Allan Odgaard
454b1b4644 Use availableTypeFromArray: instead of checking types array directly 2019-08-02 21:06:21 +02:00
Allan Odgaard
8f685ff25c Use std::clamp instead of oak::cap (C++17) 2019-08-01 10:23:55 +02:00
Allan Odgaard
dae1103728 Update LINK declarations 2019-07-16 19:42:29 +02:00
Allan Odgaard
1c1358bcce Workaround for missing content when expanding file browser items
The workaround is untested, as I have not found a way to reproduce the issue, but there is some debug output that can be reviewed and hopefully give some idea as to what is causing the issue.

The debug information can be collected by running the following in a terminal:

    log show --predicate 'process = "TextMate" AND eventMessage CONTAINS "loadChildrenForItem:expandChildren:"'
2019-07-06 18:18:56 +02:00
Allan Odgaard
11d67f3a22 Avoid NSString’s deprecated percent encoding methods 2019-06-30 10:32:45 +02:00
Allan Odgaard
1ef78b3af7 Rename symbols to what’s expected by the 10.14 SDK 2019-06-29 20:14:15 +02:00
Allan Odgaard
5aa58e5543 Do not include $APP_NAME in framework’s bundle identifier
Since we have multiple application targets, it doesn’t make sense with a global APP_NAME variable.

Though if building the frameworks as standalone bundles and embedding them in different applications, we may need some sort of unique component in the bundle identifier, but we currently do not do this (they are all statically linked, so the Info.plist is currently unused).
2019-06-26 23:32:54 +02:00
Allan Odgaard
b8017b9f22 Do not set NSBackgroundStyleRaised for controls and text in status bars
It appears to be ignored on 10.14 but earlier versions of macOS rendered the elements with a shadow, which is probably not a good fit for our current design.
2018-12-06 22:00:22 +07:00
Ronald Wampler
ca80254b80 Refactor finder tags to use catalog colors
Also, reworked the OFBFinderTagsChooser to have a similar look as on 10.14.
2018-12-05 21:16:54 +07:00
Allan Odgaard
9e3b1d6028 Set wantsLayer to YES for all NSVisualEffectView subclasses
This is required when using NSVisualEffectBlendingModeWithinWindow although on macOS 10.13 and later a view is layer backed by default.
2018-12-04 15:43:15 +07:00
Allan Odgaard
42cdb1c430 Add URL escaping for the path component of SCM URLs 2018-11-22 16:24:17 +07:00