Skip to content

Commit

Permalink
Added path bar
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinbjornt committed Nov 18, 2023
1 parent 1c9be32 commit 5582002
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 17 deletions.
8 changes: 8 additions & 0 deletions Sloth.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>
9 changes: 7 additions & 2 deletions Sloth.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
F4A8B5CD222DB5280049FA51 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
F4A9D5EE206A68BC0069B2B6 /* LICENSE.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
F4B977AF1F8EBBEB0099971E /* sloth_screenshot1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = sloth_screenshot1.jpg; sourceTree = "<group>"; };
F4E41CF12B06990D00F2897D /* Sloth.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Sloth.entitlements; sourceTree = "<group>"; };
F4ED53C21C789A0A0024540F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
F4F1D8A01C7623AF00945D3E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
F4F1D9111C7CB95700945D3E /* dsa_priv.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = dsa_priv.pem; sourceTree = "<group>"; };
Expand Down Expand Up @@ -136,6 +137,7 @@
29B97314FDCFA39411CA2CEA /* Sloth */ = {
isa = PBXGroup;
children = (
F4E41CF12B06990D00F2897D /* Sloth.entitlements */,
F44FC67225AD5EA200BC72F5 /* macos.yml */,
F4A8B5CD222DB5280049FA51 /* Makefile */,
F4F1D8A01C7623AF00945D3E /* README.md */,
Expand Down Expand Up @@ -387,13 +389,14 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_ENTITLEMENTS = Sloth.entitlements;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
DEPLOYMENT_POSTPROCESSING = YES;
DEVELOPMENT_TEAM = 5WX26Y89JP;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/sparkle",
Expand All @@ -402,6 +405,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = "";
GENERATE_PKGINFO_FILE = NO;
GENERATE_PROFILING_CODE = YES;
INFOPLIST_EXPAND_BUILD_SETTINGS = YES;
INFOPLIST_FILE = resources/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Sloth;
Expand All @@ -423,13 +427,14 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_ENTITLEMENTS = Sloth.entitlements;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = YES;
DEPLOYMENT_POSTPROCESSING = YES;
DEVELOPMENT_TEAM = 5WX26Y89JP;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/sparkle",
Expand Down
2 changes: 2 additions & 0 deletions resources/Defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@
<integer>0</integer>
<key>accessMode</key>
<string>Any</string>
<key>showPathBar</key>
<true/>
</dict>
</plist>
13 changes: 11 additions & 2 deletions resources/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -246,6 +246,15 @@
</connections>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="AXe-vw-pHE">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Show Path Bar" keyEquivalent="t" toolTip="File" id="xbt-al-SJr">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<binding destination="560" name="value" keyPath="values.showPathBar" id="4BZ-rv-Y8Q"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="Z80-LP-DWV">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
Expand Down
17 changes: 13 additions & 4 deletions resources/Prefs.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -24,7 +24,7 @@
<rect key="screenRect" x="0.0" y="0.0" width="1536" height="935"/>
<view key="contentView" id="637-Nx-CnL">
<rect key="frame" x="0.0" y="0.0" width="398" height="289"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button toolTip="Restore default preferences" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3fT-Oj-lxR">
<rect key="frame" x="13" y="13" width="141" height="32"/>
Expand Down Expand Up @@ -117,7 +117,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="f5c-N0-0X2">
<rect key="frame" x="1" y="1" width="316" height="135"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" id="hIM-Sy-Pvd">
<rect key="frame" x="0.0" y="0.0" width="316" height="135"/>
Expand Down Expand Up @@ -193,6 +193,15 @@ CA
<action selector="removeFilter:" target="-2" id="bUG-sK-2Fe"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d1O-Cm-meW">
<rect key="frame" x="17" y="17" width="182" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" title="Supports regular expressions" id="s3j-6l-ysb">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</tabViewItem>
Expand Down
Binary file modified resources/sloth.icns
Binary file not shown.
75 changes: 66 additions & 9 deletions source/SlothController.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
@"interfaceSize",
@"searchFilterCaseSensitive",
@"searchFilterRegex",
@"updateInterval"
@"updateInterval",
@"showPathBar"
]) {
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
forKeyPath:VALUES_KEYPATH(key)
Expand All @@ -198,6 +199,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[self updateDiscloseControl];
[self updateSorting];
// if ([DEFAULTS boolForKey:@"showPathBar"] == NO) {
// [pathControl setHidden:YES];
// }
[self updatePathControl];

if ([DEFAULTS boolForKey:@"authenticateOnLaunch"]) {
[self toggleAuthentication:self]; // Triggers refresh
Expand Down Expand Up @@ -365,6 +370,10 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
[self setUpdateTimerFromDefaults];
return;
}
if ([VALUES_KEYPATH(@"showPathBar") isEqualToString:keyPath]) {
[self updatePathControl];
return;
}
// The default that changed was one of the filters
[self updateFiltering];
}
Expand Down Expand Up @@ -1006,14 +1015,6 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
item[@"displayname"] = [[NSAttributedString alloc] initWithString:item[@"name"]
attributes:@{NSForegroundColorAttributeName: color}];
}
// Update path shown in path control
if (canReveal || hasBundlePath) {
NSString *path = item[@"path"] != nil ? item[@"path"] : item[@"name"];
[pathControl setURL:[NSURL fileURLWithPath:path]];
//[pathControl sxetURL:nil];
} else {
[pathControl setURL:nil];
}
} else {
[revealButton setEnabled:NO];
[killButton setEnabled:NO];
Expand All @@ -1022,6 +1023,7 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
[[infoPanelController window] orderOut:self];
}
}
[self updatePathControl];
}

- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item {
Expand All @@ -1045,6 +1047,61 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView
return YES;
}

#pragma mark - Path Control

- (void)updatePathControl {
NSDictionary *item = nil;
NSInteger selectedRow = [outlineView selectedRow];
if (selectedRow >= 0) {
item = [[outlineView itemAtRow:selectedRow] representedObject];
}

if (item == nil) {
[pathControl setURL:nil];
return;
}
BOOL canReveal = [WORKSPACE canRevealFileAtPath:item[@"name"]];
BOOL hasBundlePath = [WORKSPACE canRevealFileAtPath:item[@"path"]];

if (canReveal || hasBundlePath) {
NSString *path = item[@"path"] != nil ? item[@"path"] : item[@"name"];
[pathControl setURL:[NSURL fileURLWithPath:path]];
} else {
[pathControl setURL:nil];
}

BOOL showBar = [DEFAULTS boolForKey:@"showPathBar"] && [pathControl URL] != nil;
if (showBar == NO) {
[self hidePathControl];
} else {
[self showPathControl];
}
}

- (void)hidePathControl {
if ([pathControl isHidden] == YES) {
return;
}
[pathControl setHidden:YES];
NSView *v = [[outlineView superview] superview];
NSRect r = [v frame];
r.size.height += 36;
r.origin.y -= 36;
[v setFrame:r];
}

- (void)showPathControl {
if ([pathControl isHidden] == NO) {
return;
}
[pathControl setHidden:NO];
NSView *v = [[outlineView superview] superview];
NSRect r = [v frame];
r.size.height -= 36;
r.origin.y += 36;
[v setFrame:r];
}

#pragma mark - Menus

- (void)menuWillOpen:(NSMenu *)menu {
Expand Down

0 comments on commit 5582002

Please sign in to comment.