Skip to content

Commit

Permalink
Merge pull request #110 from zenangst/feature/localized-name-for-appl…
Browse files Browse the repository at this point in the history
…ications

Add initial support for localized app names
  • Loading branch information
zenangst authored Mar 26, 2020
2 parents f1623eb + 885df1c commit f0b9604
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode10.3
osx_image: xcode11
language: objective-c

before_install:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'cocoapods', '~> 1.6.0.beta.2'
gem 'cocoapods', '~> 1.9.1'
4 changes: 2 additions & 2 deletions Gray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.15.0;
MARKETING_VERSION = 0.16.1;
PRODUCT_BUNDLE_IDENTIFIER = com.zenangst.Gray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -745,7 +745,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.15.0;
MARKETING_VERSION = 0.16.1;
PRODUCT_BUNDLE_IDENTIFIER = com.zenangst.Gray;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :macos, '10.14'

# Frameworks
pod 'Blueprints'
pod 'Blueprints', git: 'https://github.com/zenangst/Blueprints.git', branch: 'feature/preferred-layout-attributes'
pod 'Differific'
pod 'Family'
pod 'UserInterface'
Expand Down
23 changes: 16 additions & 7 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
PODS:
- Blueprints (0.13.1)
- Differific (0.8.2)
- Family (0.22.4)
- Family (0.22.11)
- Sourcery (0.17.0)
- UserInterface (0.5.0)

DEPENDENCIES:
- Blueprints
- "Blueprints (from `[email protected]:zenangst/Blueprints.git`, branch `feature/preferred-layout-attributes`)"
- Differific
- Family
- Sourcery
- UserInterface

SPEC REPOS:
https://github.com/CocoaPods/Specs:
- Blueprints
https://github.com/CocoaPods/Specs.git:
- Differific
- Family
- Sourcery
- UserInterface

EXTERNAL SOURCES:
Blueprints:
:branch: feature/preferred-layout-attributes
:git: "[email protected]:zenangst/Blueprints.git"

CHECKOUT OPTIONS:
Blueprints:
:commit: 6719ed1aba5cfca311ae04d1035832755116dfc0
:git: "[email protected]:zenangst/Blueprints.git"

SPEC CHECKSUMS:
Blueprints: ddd6ab1e455c98471aaef2fdd0b09b5f9b53af5b
Differific: c3840b9e4d1ee2216b2c0054c270e4a616df9327
Family: 0dffb3c3ec36b85a599e43b9aa3d8cefeef81873
Family: d380fa14141faf72359813338ee64ef93920f326
Sourcery: 3ed61be7c8a1218fce349266139379dba477efe0
UserInterface: 54e15db9aceaec2b9686d00f471adb15d2598ea3

PODFILE CHECKSUM: 9a4a4208e8595d7fa51cbc758521284dec9359cc
PODFILE CHECKSUM: 2c8c2d81b994943738c4544119e5d29b6bb5f0fe

COCOAPODS: 1.8.3
COCOAPODS: 1.9.1
42 changes: 37 additions & 5 deletions Resources/Base.lproj/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="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -80,6 +80,24 @@
<action selector="importAction:" target="Voe-Tx-rLC" id="ODr-UG-1fv"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WVG-bW-ENt"/>
<menuItem title="Close Window" keyEquivalent="w" id="HEn-2t-aJ4">
<connections>
<action selector="performClose:" target="-1" id="Ag9-Ec-9I2"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="RkH-bv-tyt">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Edit" id="xHZ-GJ-NC7">
<items>
<menuItem title="Find" keyEquivalent="f" id="I8X-fE-RoM">
<connections>
<action selector="search:" target="-1" id="Ngs-CP-v6F"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
Expand Down Expand Up @@ -110,7 +128,7 @@
<action selector="switchToList:" target="Voe-Tx-rLC" id="X1I-lU-zXV"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="" id="4J7-dP-txa">
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" option="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="-1" id="dU3-MA-1Rq"/>
Expand All @@ -128,8 +146,8 @@
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<menuItem title="Zoom" keyEquivalent="f" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask" shift="YES" option="YES" command="YES"/>
<connections>
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
</connections>
Expand Down Expand Up @@ -159,5 +177,19 @@
</items>
<point key="canvasLocation" x="102" y="227"/>
</menu>
<menu id="LDQ-su-H2T">
<items>
<menuItem title="Item 1" id="enw-At-piT">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Item 2" id="x29-PV-jIz">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Item 3" id="K0C-Im-LAa">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
<point key="canvasLocation" x="140" y="120"/>
</menu>
</objects>
</document>
1 change: 1 addition & 0 deletions Sources/Features/Applications/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ struct Application: Hashable {
let preferencesUrl: URL
let appearance: Appearance
let restricted: Bool
var localizedName: String?
}
2 changes: 1 addition & 1 deletion Sources/Features/Applications/ApplicationGridView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApplicationGridView: NSCollectionViewItem, CollectionViewItemComponent, Ap

// sourcery: $RawBinding = "iconStore.loadIcon(for: model.application) { image in view.iconView.image = image }"
lazy var iconView = NSImageView()
// sourcery: let title: String = "titleLabel.stringValue = model.title"
// sourcery: let title: String = "titleLabel.stringValue = model.application.localizedName ?? model.title"
lazy var titleLabel = NSTextField()
// sourcery: let subtitle: String = "subtitleLabel.stringValue = model.subtitle"
lazy var subtitleLabel = NSTextField()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Features/Applications/ApplicationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApplicationListView: NSCollectionViewItem, CollectionViewItemComponent, Ap

// sourcery: $RawBinding = "iconStore.loadIcon(for: model.application) { image in view.iconView.image = image }"
lazy var iconView: NSImageView = .init()
// sourcery: let title: String = "titleLabel.stringValue = model.title"
// sourcery: let title: String = "titleLabel.stringValue = model.application.localizedName ?? model.title"
lazy var titleLabel: NSTextField = .init()
// sourcery: let subtitle: String = "subtitleLabel.stringValue = model.subtitle"
lazy var subtitleLabel: NSTextField = .init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ ApplicationGridViewDelegate, ApplicationsLogicControllerDelegate, ApplicationLis
case 0:
filtered = applicationCache
default:
filtered = applicationCache.filter({ $0.name.lowercased().contains(query) })
filtered = applicationCache.filter({
return ($0.localizedName ?? $0.name).lowercased().contains(query)
})
}

switch mode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,15 @@ class ApplicationsLogicController {
metadata = "🔐 Locked".localized
}

let application = Application(bundleIdentifier: bundleIdentifier,
var application = Application(bundleIdentifier: bundleIdentifier,
name: bundleName, metadata: metadata,
url: url,
preferencesUrl: resolvedAppPreferenceUrl,
appearance: appearance,
restricted: restricted)

application.localizedName = FileManager.default.displayName(atPath: application.url.path)

DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
strongSelf.delegate?.applicationsLogicController(strongSelf, didLoadApplication: application, offset: offset, total: total)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ApplicationGridDataSource: NSObject, NSCollectionViewDataSource {
if let view = item as? ApplicationGridView {
view.currentAppearance = model.application.appearance
iconStore.loadIcon(for: model.application) { image in view.iconView.image = image }
view.titleLabel.stringValue = model.title
view.titleLabel.stringValue = model.application.localizedName ?? model.title
view.subtitleLabel.stringValue = model.subtitle
}

Expand Down Expand Up @@ -258,7 +258,7 @@ class ApplicationListDataSource: NSObject, NSCollectionViewDataSource {
if let view = item as? ApplicationListView {
view.currentAppearance = model.application.appearance
iconStore.loadIcon(for: model.application) { image in view.iconView.image = image }
view.titleLabel.stringValue = model.title
view.titleLabel.stringValue = model.application.localizedName ?? model.title
view.subtitleLabel.stringValue = model.subtitle
}

Expand Down

0 comments on commit f0b9604

Please sign in to comment.