Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL Object Source #2408

Merged
merged 9 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,9 @@ - (void)setIcon:(NSImage *)newIcon {
[icon setCacheMode:NSImageCacheNever];
if (iconChange) {
// icon is being replaced, not set - notify UI
[[NSNotificationCenter defaultCenter] postNotificationName:QSObjectIconModified object:self];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: weird indent

QSGCDMainAsync(^{
[[NSNotificationCenter defaultCenter] postNotificationName:QSObjectIconModified object:self];
});
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Quicksilver/Code-QuickStepCore/QSObject_FileHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#import <QSCore/QSClangAnalyzer.h>
#import "QSObject.h"

NSArray *QSGetRecentDocumentsForBundle(NSString *bundleIdentifier);

@protocol QSFileObjectCreationProtocol
- (id)createFileObject:(QSObject *)object ofType:(NSString *)type;
@end
Expand Down
4 changes: 2 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSObject_FileHandling.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
return [paths componentsJoinedByString:@" "];
}

NSArray *recentDocumentsForBundle(NSString *bundleIdentifier) {
NSArray *QSGetRecentDocumentsForBundle(NSString *bundleIdentifier) {
if (bundleIdentifier == nil) {
return nil;
}
Expand Down Expand Up @@ -514,7 +514,7 @@ - (BOOL)loadChildrenForObject:(QSObject *)object {
QSCatalogEntry *theEntry = [[QSLibrarian sharedInstance] entryForID:childPreset];
newChildren = [theEntry contentsScanIfNeeded:YES];
} else {
NSArray *recentDocuments = recentDocumentsForBundle(bundleIdentifier);
NSArray *recentDocuments = QSGetRecentDocumentsForBundle(bundleIdentifier);
NSArray *iCloudDocuments = [QSDownloads iCloudDocumentsForBundleID:bundleIdentifier];
// combine recent and iCloud documents, removing duplicates
NSIndexSet *ind = [iCloudDocuments indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(QSObject *icdoc, NSUInteger i, BOOL *stop) {
Expand Down
1 change: 1 addition & 0 deletions Quicksilver/Code-QuickStepCore/QSRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define kQSActionProviders @"QSActionProviders"
#define kQSFSParsers @"QSFSParsers"
#define kQSURLParsers @"QSURLParsers"
#define kQSObjectSources @"QSObjectSources"
#define kQSObjectHandlers @"QSObjectHandlers"
#define kQSPreferencePanes @"QSPreferencePanes"
Expand Down
10 changes: 4 additions & 6 deletions Quicksilver/Code-QuickStepInterface/QSResultController.m
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,10 @@ - (void)setResultChildIconLoader:(QSIconLoader *)aResultChildIconLoader {

- (void)objectIconModified:(NSNotification *)notif
{
QSGCDMainAsync(^{
[resultTable setNeedsDisplay];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSResultsShowChildren"]) {
[resultChildTable setNeedsDisplay];
}
});
[resultTable setNeedsDisplay];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSResultsShowChildren"]) {
[resultChildTable setNeedsDisplay];
}
}

#pragma mark -
Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ - (void)selectObject:(QSBasicObject *)obj {

- (void)objectIconModified:(NSNotification *)notif {
// icon changed - update it in the pane
[self setNeedsDisplay:YES];
[self setNeedsDisplay:YES];
}

#pragma mark -
Expand Down
75 changes: 75 additions & 0 deletions Quicksilver/Nibs/QSWebSource.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="QSWebSource">
<connections>
<outlet property="itemLocationField" destination="QPI-HB-wCF" id="g2u-JO-GNh"/>
<outlet property="itemParserPopUp" destination="gZt-qP-axv" id="Ido-5G-6hq"/>
<outlet property="settingsView" destination="c22-O7-iKe" id="gVh-jx-sMh"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView misplaced="YES" id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="350" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" misplaced="YES" id="QPI-HB-wCF">
<rect key="frame" x="20" y="230" width="310" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="URL to Scan" drawsBackground="YES" id="fTf-J1-hTs">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="setValueForSender:" target="-2" id="c2n-Tl-Dgb"/>
<outlet property="delegate" destination="-2" id="7ym-SM-o1C"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" misplaced="YES" id="rNc-2U-Mi8">
<rect key="frame" x="18" y="206" width="31" height="13"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Add" id="ooL-JV-omv">
<font key="font" metaFont="label"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton toolTip="Type of content scanner" verticalHuggingPriority="750" misplaced="YES" id="gZt-qP-axv">
<rect key="frame" x="41" y="201" width="147" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Parsers" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="clipping" state="on" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="sfY-HN-ZD8" id="Txk-2M-jbu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
<menu key="menu" title="OtherViews" id="iEm-NK-2Fc">
<items>
<menuItem title="Parsers" state="on" id="sfY-HN-ZD8">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="setValueForSender:" target="-2" id="44M-Jw-6lB"/>
</connections>
</popUpButton>
<textField verticalHuggingPriority="750" misplaced="YES" id="Zde-wJ-43h">
<rect key="frame" x="191" y="206" width="96" height="13"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="to Catalog" id="U4Z-jp-Hg8">
<font key="font" metaFont="label"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="-8" y="-94"/>
</customView>
</objects>
</document>
8 changes: 3 additions & 5 deletions Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSWebSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
// Copyright 2004 Blacktree. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@interface QSWebSource : NSObject {

@interface QSWebSource : QSObjectSource {
IBOutlet NSTextField *itemLocationField;
IBOutlet NSPopUpButton *itemParserPopUp;
}

@end
68 changes: 62 additions & 6 deletions Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSWebSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ - (NSArray *)objectsForEntry:(QSCatalogEntry *)theEntry {
NSString *location = [settings objectForKey:kItemPath];
if (location) {
NSArray *contents = [(QSHTMLLinkParser *)[QSReg getClassInstance:@"QSHTMLLinkParser"] objectsFromURL:[NSURL URLWithString:location] withSettings:settings];
if (!contents) {
// return the original contents of the catalog entry if there was a problem getting data from the internet
return [QSLib entryForID:theEntry.identifier].contents;
} else {
return contents;
}
if (contents) {
return contents;
}
// return the original contents of the catalog entry if there was a problem getting data from the internet
return [QSLib entryForID:theEntry.identifier].contents;
}
return nil;
}
Expand All @@ -38,4 +37,61 @@ - (BOOL)indexIsValidFromDate:(NSDate *)indexDate forEntry:(QSCatalogEntry *)theE
return YES;
}

- (BOOL)isVisibleSource
{
return YES;
}

- (NSView *)settingsView
{
if (![super settingsView]) {
[[NSBundle bundleForClass:[self class]] loadNibNamed:NSStringFromClass([self class]) owner:self topLevelObjects:NULL];
}
return [super settingsView];
}

- (void)populateFields
{
NSMutableDictionary *settings = self.selectedEntry.sourceSettings;
// set values for controls in the view based on settings
NSString *path = [settings objectForKey:kItemPath];
[itemLocationField setStringValue:(path?path:@"")];
NSString *parser = [settings objectForKey:kItemParser];
NSMenu *parserMenu = [[NSMenu alloc] initWithTitle:kQSURLParsers];

[parserMenu addItemWithTitle:@"None" action:nil keyEquivalent:@""];
[parserMenu addItem:[NSMenuItem separatorItem]];
NSMutableDictionary *parsers = [QSReg instancesForTable:kQSURLParsers];

NSMenuItem *item;
for(NSString *key in parsers) {
NSString *title = [[NSBundle bundleForClass:NSClassFromString(key)] safeLocalizedStringForKey:key value:key table:@"QSParser.name"];
if ([title isEqualToString:key]) title = [[NSBundle mainBundle] safeLocalizedStringForKey:key value:key table:@"QSParser.name"];

item = (NSMenuItem *)[parserMenu addItemWithTitle:title action:nil keyEquivalent:@""];
[item setRepresentedObject:key];
}
[itemParserPopUp setMenu:parserMenu];
NSInteger parserEntry = [itemParserPopUp indexOfItemWithRepresentedObject:parser];
[itemParserPopUp selectItemAtIndex:(parserEntry == -1?0:parserEntry)];
}

- (IBAction)setValueForSender:(id)sender {
NSMutableDictionary *settings = self.selectedEntry.sourceSettings;
if (sender == itemLocationField) {
// Box showing the URL to scan
[settings setObject:[sender stringValue] forKey:kItemPath];
} else if (sender == itemParserPopUp) {
// 'Include Contents' popup menu
NSString *parserName = [[sender selectedItem] representedObject];
if (parserName)
[settings setObject:[[sender selectedItem] representedObject] forKey:kItemParser];
else
[settings removeObjectForKey:kItemParser];
}
[[self selectedEntry] scanAndCache];
[self populateFields];

[[NSNotificationCenter defaultCenter] postNotificationName:QSCatalogEntryChangedNotification object:[self selectedEntry]];
}
@end
7 changes: 7 additions & 0 deletions Quicksilver/PlugIns-Main/QSCorePlugIn/QSCorePlugIn-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,13 @@
<key>QSTextLineParser</key>
<string>QSTextLineParser</string>
</dict>
<key>QSURLParsers</key>
<dict>
<key>QSHTMLLinkParser</key>
<string>QSHTMLLinkParser</string>
<key>QSTextLineParser</key>
<string>QSTextLineParser</string>
</dict>
</dict>
<key>QSResourceAdditions</key>
<dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@
<string>Proxies</string>
<key>QSUserDefinedProxySource</key>
<string>Synonym</string>
<key>QSWebSource</key>
<string>URL Scanner</string>
</dict>
</plist>
4 changes: 4 additions & 0 deletions Quicksilver/Quicksilver.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
D46D3C7D16B33D0B00387EA9 /* countBadge4@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D46D3C7916B33D0B00387EA9 /* countBadge4@2x.png */; };
D46D3C7E16B33D0B00387EA9 /* countBadge5@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D46D3C7A16B33D0B00387EA9 /* countBadge5@2x.png */; };
D48F231D1C99CCC4006504A8 /* QSSharedFileListSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D48F231C1C99CCC4006504A8 /* QSSharedFileListSource.m */; };
D48FC4FC1FBE89B4009600EB /* QSWebSource.xib in Resources */ = {isa = PBXBuildFile; fileRef = D48FC4FB1FBE89B4009600EB /* QSWebSource.xib */; };
D493990D1350078E00B908C6 /* QSDownloads.h in Headers */ = {isa = PBXBuildFile; fileRef = D49399091350078E00B908C6 /* QSDownloads.h */; settings = {ATTRIBUTES = (Public, ); }; };
D493990E1350078E00B908C6 /* QSDownloads.m in Sources */ = {isa = PBXBuildFile; fileRef = D493990A1350078E00B908C6 /* QSDownloads.m */; };
D49A8B02166EA8FC0086B5A9 /* QSUserDefinedProxySource.m in Sources */ = {isa = PBXBuildFile; fileRef = D49A8B01166EA8FC0086B5A9 /* QSUserDefinedProxySource.m */; };
Expand Down Expand Up @@ -2039,6 +2040,7 @@
D46D3C7A16B33D0B00387EA9 /* countBadge5@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "countBadge5@2x.png"; sourceTree = "<group>"; };
D48F231B1C99CCC4006504A8 /* QSSharedFileListSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSSharedFileListSource.h; sourceTree = "<group>"; };
D48F231C1C99CCC4006504A8 /* QSSharedFileListSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSSharedFileListSource.m; sourceTree = "<group>"; };
D48FC4FB1FBE89B4009600EB /* QSWebSource.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QSWebSource.xib; sourceTree = "<group>"; };
D49399091350078E00B908C6 /* QSDownloads.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSDownloads.h; sourceTree = "<group>"; usesTabs = 1; };
D493990A1350078E00B908C6 /* QSDownloads.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QSDownloads.m; sourceTree = "<group>"; usesTabs = 1; };
D49A8B00166EA8FC0086B5A9 /* QSUserDefinedProxySource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QSUserDefinedProxySource.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2970,6 +2972,7 @@
E102F98C06625D7300843027 /* QuitConfirm.xib */,
E102F98D06625D7300843027 /* ResultWindow.xib */,
D4AA5992166F9DD4006E8FD1 /* QSUserDefinedProxySource.xib */,
D48FC4FB1FBE89B4009600EB /* QSWebSource.xib */,
);
path = Nibs;
sourceTree = "<group>";
Expand Down Expand Up @@ -4470,6 +4473,7 @@
E1186AD606A6D6F700F3EA8E /* QSKindDescriptions.plist in Resources */,
E103ED5D06471DBF00447FE0 /* ResourceLocations.plist in Resources */,
92DC402D0E25A0C40091BD92 /* Action.png in Resources */,
D48FC4FC1FBE89B4009600EB /* QSWebSource.xib in Resources */,
92DC402C0E25A0C40091BD92 /* Action_p.png in Resources */,
E1B2890506E3DAFA00CACB9E /* AppearanceBack.png in Resources */,
E1B2890406E3DAFA00CACB9E /* AppearanceSelection.png in Resources */,
Expand Down
1 change: 1 addition & 0 deletions Quicksilver/Resources/ResourceLocations.plist
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
</dict>
<key>appearanceIcon</key>
<array>
<string>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ProfileFontAndColor.icns</string>
<string>/System/Library/PreferencePanes/Appearance.prefPane/Contents/Resources/GeneralPrefsIcons.icns</string>
<string>/System/Library/PreferencePanes/Appearance.prefPane/Contents/Resources/General.tiff</string>
<string>/System/Library/PreferencePanes/Appearance.prefPane/Contents/Resources/General.icns</string>
Expand Down