mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-12-06 12:49:02 +00:00
Convert hscommon, qtlib and cocoalib to submodules
... rather than subtrees. That also represents a small qtlib updates which needed a code adjustment.
This commit is contained in:
parent
4b6f8b45e2
commit
bb1f0f5be6
9
.gitmodules
vendored
Normal file
9
.gitmodules
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
[submodule "qtlib"]
|
||||
path = qtlib
|
||||
url = https://github.com/hsoft/qtlib.git
|
||||
[submodule "hscommon"]
|
||||
path = hscommon
|
||||
url = https://github.com/hsoft/hscommon.git
|
||||
[submodule "cocoalib"]
|
||||
path = cocoalib
|
||||
url = https://github.com/hsoft/cocoalib.git
|
@ -61,7 +61,7 @@ This folder contains the source for dupeGuru. Its documentation is in `help`, bu
|
||||
* locale: .po files for localisation.
|
||||
|
||||
There are also other sub-folder that comes from external repositories and are part of this repo as
|
||||
git subtrees:
|
||||
git submodules:
|
||||
|
||||
* hscommon: A collection of helpers used across HS applications.
|
||||
* cocoalib: A collection of helpers used across Cocoa UI codebases of HS applications.
|
||||
|
1
cocoalib
Submodule
1
cocoalib
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 65ab3b5fb61b9a477786850d3a8083e3892d9020
|
15
cocoalib/.gitignore
vendored
15
cocoalib/.gitignore
vendored
@ -1,15 +0,0 @@
|
||||
.DS_Store
|
||||
__pycache__
|
||||
autogen
|
||||
*.pyc
|
||||
*.so
|
||||
nl.lproj
|
||||
cs.lproj
|
||||
de.lproj
|
||||
fr.lproj
|
||||
it.lproj
|
||||
hy.lproj
|
||||
ru.lproj
|
||||
uk.lproj
|
||||
zh_CN.lproj
|
||||
pt_BR.lproj
|
@ -1,8 +0,0 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[hscommon.cocoalib]
|
||||
file_filter = locale/<lang>/LC_MESSAGES/cocoalib.po
|
||||
source_file = locale/cocoalib.pot
|
||||
source_lang = en
|
||||
type = PO
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface Dialogs : NSObject
|
||||
+ (void)showMessage:(NSString *)message;
|
||||
+ (NSInteger)askYesNo:(NSString *)message;
|
||||
@end
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "Dialogs.h"
|
||||
|
||||
@implementation Dialogs
|
||||
+ (void)showMessage:(NSString *)message
|
||||
{
|
||||
NSAlert *a = [[NSAlert alloc] init];
|
||||
[a addButtonWithTitle:NSLocalizedStringFromTable(@"OK", @"cocoalib", @"")];
|
||||
[a setMessageText:message];
|
||||
[a runModal];
|
||||
[a release];
|
||||
}
|
||||
|
||||
+ (NSInteger)askYesNo:(NSString *)message
|
||||
{
|
||||
NSAlert *a = [[NSAlert alloc] init];
|
||||
[a addButtonWithTitle:NSLocalizedStringFromTable(@"Yes", @"cocoalib", @"")];
|
||||
[[a addButtonWithTitle:NSLocalizedStringFromTable(@"No", @"cocoalib", @"")] setKeyEquivalent:@"\E"];
|
||||
[a setMessageText:message];
|
||||
NSInteger r = [a runModal];
|
||||
[a release];
|
||||
return r;
|
||||
}
|
||||
@end
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PyBaseApp.h"
|
||||
|
||||
@interface HSAboutBox : NSWindowController
|
||||
{
|
||||
NSTextField *titleTextField;
|
||||
NSTextField *versionTextField;
|
||||
NSTextField *copyrightTextField;
|
||||
|
||||
PyBaseApp *app;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSTextField *titleTextField;
|
||||
@property (readwrite, retain) NSTextField *versionTextField;
|
||||
@property (readwrite, retain) NSTextField *copyrightTextField;
|
||||
|
||||
- (id)initWithApp:(PyBaseApp *)app;
|
||||
- (void)updateFields;
|
||||
@end
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSAboutBox.h"
|
||||
#import "HSAboutBox_UI.h"
|
||||
|
||||
@implementation HSAboutBox
|
||||
|
||||
@synthesize titleTextField;
|
||||
@synthesize versionTextField;
|
||||
@synthesize copyrightTextField;
|
||||
|
||||
- (id)initWithApp:(PyBaseApp *)aApp
|
||||
{
|
||||
self = [super initWithWindow:nil];
|
||||
[self setWindow:createHSAboutBox_UI(self)];
|
||||
app = [aApp retain];
|
||||
[self updateFields];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[app release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)updateFields
|
||||
{
|
||||
[titleTextField setStringValue:[app appLongName]];
|
||||
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
[versionTextField setStringValue:[NSString stringWithFormat:@"Version: %@",version]];
|
||||
NSString *copyright = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
|
||||
[copyrightTextField setStringValue:copyright];
|
||||
}
|
||||
|
||||
@end
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface HSErrorReportWindow : NSWindowController
|
||||
{
|
||||
NSTextView *contentTextView;
|
||||
NSString *githubUrl;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSTextView *contentTextView;
|
||||
@property (readwrite, retain) NSString *githubUrl;
|
||||
|
||||
// True if the user wants to send the report
|
||||
+ (void)showErrorReportWithContent:(NSString *)content githubUrl:(NSString *)githubUrl;
|
||||
- (id)initWithContent:(NSString *)content githubUrl:(NSString *)githubUrl;
|
||||
|
||||
- (void)goToGithub;
|
||||
- (void)close;
|
||||
@end
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSErrorReportWindow.h"
|
||||
#import "HSErrorReportWindow_UI.h"
|
||||
|
||||
@implementation HSErrorReportWindow
|
||||
|
||||
@synthesize contentTextView;
|
||||
@synthesize githubUrl;
|
||||
|
||||
+ (void)showErrorReportWithContent:(NSString *)content githubUrl:(NSString *)githubUrl
|
||||
{
|
||||
HSErrorReportWindow *report = [[HSErrorReportWindow alloc] initWithContent:content githubUrl:githubUrl];
|
||||
[NSApp runModalForWindow:[report window]];
|
||||
[report release];
|
||||
}
|
||||
|
||||
- (id)initWithContent:(NSString *)content githubUrl:(NSString *)aGithubUrl
|
||||
{
|
||||
self = [super initWithWindow:nil];
|
||||
[self setWindow:createHSErrorReportWindow_UI(self)];
|
||||
[contentTextView alignLeft:nil];
|
||||
[[[contentTextView textStorage] mutableString] setString:content];
|
||||
self.githubUrl = aGithubUrl;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)goToGithub
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:self.githubUrl]];
|
||||
}
|
||||
|
||||
- (void)close
|
||||
{
|
||||
[[self window] orderOut:self];
|
||||
[NSApp stopModalWithCode:NSOKButton];
|
||||
}
|
||||
@end
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <math.h>
|
||||
|
||||
CGFloat deg2rad(CGFloat deg);
|
||||
CGFloat distance(NSPoint p1, NSPoint p2);
|
||||
NSPoint pointInCircle(NSPoint center, CGFloat radius, CGFloat angle);
|
||||
CGFloat angleFromPoints(NSPoint pt1, NSPoint pt2);
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSGeometry.h"
|
||||
|
||||
CGFloat deg2rad(CGFloat deg)
|
||||
{
|
||||
return deg * M_PI / 180;
|
||||
}
|
||||
|
||||
CGFloat distance(NSPoint p1, NSPoint p2)
|
||||
{
|
||||
CGFloat dX = p1.x - p2.x;
|
||||
CGFloat dY = p1.y - p2.y;
|
||||
return sqrt(dX * dX + dY * dY);
|
||||
}
|
||||
|
||||
NSPoint pointInCircle(NSPoint center, CGFloat radius, CGFloat angle)
|
||||
{
|
||||
// a/sin(A) = b/sin(B) = c/sin(C) = 2R
|
||||
// the start point it (center.x + radius, center.y) and goes counterclockwise
|
||||
angle = fmod(angle, M_PI*2);
|
||||
CGFloat C = M_PI/2;
|
||||
CGFloat A = fmod(angle, M_PI/2);
|
||||
CGFloat B = C - A;
|
||||
CGFloat c = radius;
|
||||
CGFloat ratio = c / sin(C);
|
||||
CGFloat b = ratio * sin(B);
|
||||
CGFloat a = ratio * sin(A);
|
||||
if (angle >= M_PI * 1.5)
|
||||
return NSMakePoint(center.x + a, center.y - b);
|
||||
else if (angle >= M_PI)
|
||||
return NSMakePoint(center.x - b, center.y - a);
|
||||
else if (angle >= M_PI/2)
|
||||
return NSMakePoint(center.x - a, center.y + b);
|
||||
else
|
||||
return NSMakePoint(center.x + b, center.y + a);
|
||||
}
|
||||
|
||||
CGFloat angleFromPoints(NSPoint pt1, NSPoint pt2)
|
||||
{
|
||||
// Returns the angle (radian) formed by the line pt1-pt2. The angle follows the same logic
|
||||
// as in pointInCircle.
|
||||
// What we do here is that we take the line and reduce it to fit a "unit circle" (circle with
|
||||
// a radius of 1). Then, either asin(adjusted_dy) or acos(adjusted_dx) will give us our angle.
|
||||
// We'll use asin(adjusted_dy).
|
||||
CGFloat length = distance(pt1, pt2);
|
||||
CGFloat dx = pt2.x - pt1.x;
|
||||
CGFloat dy = pt2.y - pt1.y;
|
||||
CGFloat ajdusted_dy = ABS(dy) / length;
|
||||
CGFloat angle = asin(ajdusted_dy);
|
||||
|
||||
if ((dx < 0) && (dy >= 0)) {
|
||||
// top-left quadrant
|
||||
angle = M_PI - angle;
|
||||
}
|
||||
else if ((dx < 0) && (dy < 0)) {
|
||||
// bottom-left quadrant
|
||||
angle = M_PI + angle;
|
||||
}
|
||||
else if ((dx >= 0) && (dy < 0)) {
|
||||
// bottom-right quadrant
|
||||
angle = (2 * M_PI) - angle;
|
||||
}
|
||||
return angle;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Python.h>
|
||||
|
||||
void setCocoaViewsModuleName(NSString *moduleName);
|
||||
PyObject* createCallback(NSString *aViewClassName, id aViewRef);
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSPyUtil.h"
|
||||
#import "ObjP.h"
|
||||
|
||||
static NSString *gCocoaViewsModuleName;
|
||||
void setCocoaViewsModuleName(NSString *moduleName)
|
||||
{
|
||||
if (gCocoaViewsModuleName != nil) {
|
||||
[gCocoaViewsModuleName release];
|
||||
}
|
||||
gCocoaViewsModuleName = [moduleName retain];
|
||||
}
|
||||
|
||||
PyObject* createCallback(NSString *aViewClassName, id aViewRef)
|
||||
{
|
||||
NSString *moduleName;
|
||||
if (gCocoaViewsModuleName != nil) {
|
||||
moduleName = gCocoaViewsModuleName;
|
||||
}
|
||||
else {
|
||||
moduleName = @"inter.CocoaViews";
|
||||
}
|
||||
PyGILState_STATE gilState = PyGILState_Ensure();
|
||||
PyObject *pCallback = ObjP_classInstanceWithRef(aViewClassName, moduleName, aViewRef);
|
||||
PyGILState_Release(gilState);
|
||||
return pCallback;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Quartz/Quartz.h>
|
||||
|
||||
@interface HSQLPreviewItem : NSObject <QLPreviewItem>
|
||||
{
|
||||
NSURL *url;
|
||||
NSString *title;
|
||||
}
|
||||
- (id)initWithUrl:(NSURL *)aUrl title:(NSString *)aTitle;
|
||||
@end
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSQuicklook.h"
|
||||
|
||||
@implementation HSQLPreviewItem
|
||||
- (id)initWithUrl:(NSURL *)aUrl title:(NSString *)aTitle
|
||||
{
|
||||
self = [super init];
|
||||
url = [aUrl retain];
|
||||
title = [aTitle retain];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[url release];
|
||||
[title release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSURL *)previewItemURL
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
- (NSString *)previewItemTitle
|
||||
{
|
||||
return title;
|
||||
}
|
||||
@end
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface HSRecentFiles : NSObject
|
||||
{
|
||||
id delegate;
|
||||
NSMenu *menu;
|
||||
NSString *name;
|
||||
NSMutableArray *filepaths;
|
||||
NSInteger numberOfMenuItemsToPreserve;
|
||||
}
|
||||
- (id)initWithName:(NSString *)aName menu:(NSMenu *)aMenu;
|
||||
|
||||
- (void)addFile:(NSString *)path;
|
||||
- (void)rebuildMenu;
|
||||
- (void)fillMenu:(NSMenu *)menu;
|
||||
- (void)clearMenu:(id)sender;
|
||||
- (void)menuClick:(id)sender;
|
||||
|
||||
- (NSMenu *)menu;
|
||||
- (id)delegate;
|
||||
- (void)setDelegate:(id)aDelegate;
|
||||
- (NSArray *)filepaths;
|
||||
@end
|
||||
|
||||
@protocol HSRecentFilesDelegate
|
||||
- (void)recentFileClicked:(NSString *)path;
|
||||
@end
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSRecentFiles.h"
|
||||
|
||||
@implementation HSRecentFiles
|
||||
- (id)initWithName:(NSString *)aName menu:(NSMenu *)aMenu
|
||||
{
|
||||
self = [super init];
|
||||
name = aName;
|
||||
menu = [aMenu retain];
|
||||
numberOfMenuItemsToPreserve = [menu numberOfItems];
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
filepaths = [[NSMutableArray alloc] initWithArray:[ud arrayForKey:name]];
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
for (NSInteger i=[filepaths count]-1;i>=0;i--) {
|
||||
NSString *path = [filepaths objectAtIndex:i];
|
||||
// We check for path class because we might be fed with garbage from the prefs.
|
||||
if ((![path isKindOfClass:[NSString class]]) || (![fm fileExistsAtPath:path])) {
|
||||
[filepaths removeObjectAtIndex:i];
|
||||
}
|
||||
}
|
||||
[self rebuildMenu];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setObject:filepaths forKey:name];
|
||||
[ud synchronize];
|
||||
[filepaths release];
|
||||
[menu release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)addFile:(NSString *)path
|
||||
{
|
||||
[filepaths removeObject:path];
|
||||
[filepaths insertObject:path atIndex:0];
|
||||
[self rebuildMenu];
|
||||
}
|
||||
|
||||
- (void)rebuildMenu
|
||||
{
|
||||
while ([menu numberOfItems] > numberOfMenuItemsToPreserve)
|
||||
[menu removeItemAtIndex:[menu numberOfItems]-1];
|
||||
[self fillMenu:menu];
|
||||
if ([filepaths count] > 0) {
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
NSMenuItem *mi = [menu addItemWithTitle:NSLocalizedStringFromTable(@"Clear List", @"cocoalib", @"") action:@selector(clearMenu:) keyEquivalent:@""];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fillMenu:(NSMenu *)menuToFill
|
||||
{
|
||||
for (int i=0;i<[filepaths count];i++) {
|
||||
NSMenuItem *mi = [menuToFill addItemWithTitle:[filepaths objectAtIndex:i] action:@selector(menuClick:) keyEquivalent:@""];
|
||||
[mi setTag:i];
|
||||
[mi setTarget:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearMenu:(id)sender
|
||||
{
|
||||
[filepaths removeAllObjects];
|
||||
[self rebuildMenu];
|
||||
}
|
||||
|
||||
- (void)menuClick:(id)sender
|
||||
{
|
||||
if (delegate == nil)
|
||||
return;
|
||||
if ([delegate respondsToSelector:@selector(recentFileClicked:)])
|
||||
[delegate recentFileClicked:[filepaths objectAtIndex:[sender tag]]];
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
- (NSMenu *)menu {return menu;}
|
||||
- (id)delegate { return delegate; }
|
||||
- (void)setDelegate:(id)aDelegate { delegate = aDelegate; }
|
||||
- (NSArray *)filepaths {return filepaths;}
|
||||
@end
|
@ -1,10 +0,0 @@
|
||||
Copyright 2014, Hardcoded Software Inc., http://www.hardcoded.net
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Hardcoded Software Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSEvent(NSEventAdditions)
|
||||
- (unichar)firstCharacter;
|
||||
- (NSUInteger)flags;
|
||||
- (NSUInteger)modifierKeysFlags;
|
||||
- (BOOL)isDeleteOrBackspace;
|
||||
- (BOOL)isReturnOrEnter;
|
||||
- (BOOL)isTab;
|
||||
- (BOOL)isBackTab;
|
||||
- (BOOL)isSpace;
|
||||
- (BOOL)isUp;
|
||||
- (BOOL)isDown;
|
||||
- (BOOL)isLeft;
|
||||
- (BOOL)isRight;
|
||||
@end
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "NSEventAdditions.h"
|
||||
|
||||
@implementation NSEvent(NSEventAdditions)
|
||||
|
||||
- (unichar)firstCharacter
|
||||
{
|
||||
NSString *characters = [self characters];
|
||||
if ([characters length] == 0)
|
||||
{
|
||||
return '\0';
|
||||
}
|
||||
return [characters characterAtIndex:0];
|
||||
}
|
||||
|
||||
- (NSUInteger)flags
|
||||
{
|
||||
// get flags and strip the lower 16 (device dependant) bits
|
||||
// See modifierFlags's doc for details
|
||||
return [self modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
||||
}
|
||||
|
||||
- (NSUInteger)modifierKeysFlags
|
||||
{
|
||||
// This is modifierFlags with only Command, Opt, Ctrl and Shift, without the rest of the flags
|
||||
// to pollute.
|
||||
return [self flags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
|
||||
}
|
||||
|
||||
- (BOOL)isDeleteOrBackspace
|
||||
{
|
||||
unichar firstChar = [self firstCharacter];
|
||||
return firstChar == NSDeleteFunctionKey || firstChar == NSDeleteCharFunctionKey ||
|
||||
firstChar == NSDeleteCharacter || firstChar == NSBackspaceCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isReturnOrEnter
|
||||
{
|
||||
unichar firstChar = [self firstCharacter];
|
||||
return firstChar == NSCarriageReturnCharacter || firstChar == NSEnterCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isTab
|
||||
{
|
||||
return [self firstCharacter] == NSTabCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isBackTab
|
||||
{
|
||||
return [self firstCharacter] == NSBackTabCharacter;
|
||||
}
|
||||
|
||||
- (BOOL)isSpace
|
||||
{
|
||||
return ([self firstCharacter] == 0x20) && (![self flags]);
|
||||
}
|
||||
|
||||
- (BOOL)isUp
|
||||
{
|
||||
return [self firstCharacter] == NSUpArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isDown
|
||||
{
|
||||
return [self firstCharacter] == NSDownArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isLeft
|
||||
{
|
||||
return [self firstCharacter] == NSLeftArrowFunctionKey;
|
||||
}
|
||||
|
||||
- (BOOL)isRight
|
||||
{
|
||||
return [self firstCharacter] == NSRightArrowFunctionKey;
|
||||
}
|
||||
|
||||
@end
|
@ -1,21 +0,0 @@
|
||||
// Created by Scott Stevenson on 9/28/07.
|
||||
//
|
||||
// Personal site: http://theocacao.com/
|
||||
// Post for this sample: http://theocacao.com/document.page/497
|
||||
//
|
||||
// The code in this project is intended to be used as a learning
|
||||
// tool for Cocoa programmers. You may freely use the code in
|
||||
// your own programs, but please do not use the code as-is in
|
||||
// other tutorials.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface NSImage (Extras)
|
||||
|
||||
// creates a copy of the current image while maintaining
|
||||
// proportions. also centers image, if necessary
|
||||
|
||||
- (NSImage*)imageByScalingProportionallyToSize:(NSSize)aSize;
|
||||
|
||||
@end
|
@ -1,114 +0,0 @@
|
||||
// Created by Scott Stevenson on 9/28/07.
|
||||
//
|
||||
// Personal site: http://theocacao.com/
|
||||
// Post for this sample: http://theocacao.com/document.page/497
|
||||
//
|
||||
// The code in this project is intended to be used as a learning
|
||||
// tool for Cocoa programmers. You may freely use the code in
|
||||
// your own programs, but please do not use the code as-is in
|
||||
// other tutorials.
|
||||
|
||||
#import "NSImageAdditions.h"
|
||||
|
||||
|
||||
@implementation NSImage (Extras)
|
||||
|
||||
- (NSImage*)imageByScalingProportionallyToSize:(NSSize)targetSize
|
||||
{
|
||||
NSImage* sourceImage = self;
|
||||
NSImage* newImage = nil;
|
||||
|
||||
if ([sourceImage isValid])
|
||||
{
|
||||
NSSize imageSize = [sourceImage size];
|
||||
CGFloat width = imageSize.width;
|
||||
CGFloat height = imageSize.height;
|
||||
|
||||
CGFloat targetWidth = targetSize.width;
|
||||
CGFloat targetHeight = targetSize.height;
|
||||
|
||||
// scaleFactor will be the fraction that we'll
|
||||
// use to adjust the size. For example, if we shrink
|
||||
// an image by half, scaleFactor will be 0.5. the
|
||||
// scaledWidth and scaledHeight will be the original,
|
||||
// multiplied by the scaleFactor.
|
||||
//
|
||||
// IMPORTANT: the "targetHeight" is the size of the space
|
||||
// we're drawing into. The "scaledHeight" is the height that
|
||||
// the image actually is drawn at, once we take into
|
||||
// account the ideal of maintaining proportions
|
||||
|
||||
CGFloat scaleFactor = 0.0;
|
||||
CGFloat scaledWidth = targetWidth;
|
||||
CGFloat scaledHeight = targetHeight;
|
||||
|
||||
NSPoint thumbnailPoint = NSMakePoint(0,0);
|
||||
|
||||
// since not all images are square, we want to scale
|
||||
// proportionately. To do this, we find the longest
|
||||
// edge and use that as a guide.
|
||||
|
||||
if ( NSEqualSizes( imageSize, targetSize ) == NO )
|
||||
{
|
||||
// use the longeset edge as a guide. if the
|
||||
// image is wider than tall, we'll figure out
|
||||
// the scale factor by dividing it by the
|
||||
// intended width. Otherwise, we'll use the
|
||||
// height.
|
||||
|
||||
CGFloat widthFactor = targetWidth / width;
|
||||
CGFloat heightFactor = targetHeight / height;
|
||||
|
||||
if ( widthFactor < heightFactor )
|
||||
scaleFactor = widthFactor;
|
||||
else
|
||||
scaleFactor = heightFactor;
|
||||
|
||||
// ex: 500 * 0.5 = 250 (newWidth)
|
||||
|
||||
scaledWidth = width * scaleFactor;
|
||||
scaledHeight = height * scaleFactor;
|
||||
|
||||
// center the thumbnail in the frame. if
|
||||
// wider than tall, we need to adjust the
|
||||
// vertical drawing point (y axis)
|
||||
|
||||
if ( widthFactor < heightFactor )
|
||||
thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
|
||||
|
||||
else if ( widthFactor > heightFactor )
|
||||
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
|
||||
}
|
||||
|
||||
|
||||
// create a new image to draw into
|
||||
newImage = [[NSImage alloc] initWithSize:targetSize];
|
||||
|
||||
// once focus is locked, all drawing goes into this NSImage instance
|
||||
// directly, not to the screen. It also receives its own graphics
|
||||
// context.
|
||||
//
|
||||
// Also, keep in mind that we're doing this in a background thread.
|
||||
// You only want to draw to the screen in the main thread, but
|
||||
// drawing to an offscreen image is (apparently) okay.
|
||||
|
||||
[newImage lockFocus];
|
||||
|
||||
NSRect thumbnailRect;
|
||||
thumbnailRect.origin = thumbnailPoint;
|
||||
thumbnailRect.size.width = scaledWidth;
|
||||
thumbnailRect.size.height = scaledHeight;
|
||||
|
||||
[sourceImage drawInRect: thumbnailRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
|
||||
[newImage unlockFocus];
|
||||
|
||||
}
|
||||
|
||||
return [newImage autorelease];
|
||||
}
|
||||
|
||||
@end
|
@ -1,10 +0,0 @@
|
||||
// from http://www.cocoadev.com/index.pl?NotificationsAcrossThreads
|
||||
#import <Cocoa/Cocoa.h>
|
||||
@interface NSNotificationCenter (NSNotificationCenterAdditions)
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification;
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait;
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object;
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo;
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait;
|
||||
@end
|
@ -1,48 +0,0 @@
|
||||
#import "NSNotificationAdditions.h"
|
||||
#import <pthread.h>
|
||||
|
||||
@implementation NSNotificationCenter (NSNotificationCenterAdditions)
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification {
|
||||
if( pthread_main_np() ) return [self postNotification:notification];
|
||||
[self postNotificationOnMainThread:notification waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait {
|
||||
if( pthread_main_np() ) return [self postNotification:notification];
|
||||
[[self class] performSelectorOnMainThread:@selector( _postNotification: ) withObject:notification waitUntilDone:wait];
|
||||
}
|
||||
|
||||
+ (void) _postNotification:(NSNotification *) notification {
|
||||
[[self defaultCenter] postNotification:notification];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:nil];
|
||||
[self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo];
|
||||
[self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait {
|
||||
if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo];
|
||||
|
||||
NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] init];
|
||||
[info setObject:name forKey:@"name"];
|
||||
if( object ) [info setObject:object forKey:@"object"];
|
||||
if( userInfo ) [info setObject:userInfo forKey:@"userInfo"];
|
||||
|
||||
[[self class] performSelectorOnMainThread:@selector( _postNotificationName: ) withObject:info waitUntilDone:wait];
|
||||
[info release];
|
||||
}
|
||||
|
||||
+ (void) _postNotificationName:(NSDictionary *) info {
|
||||
NSString *name = [info objectForKey:@"name"];
|
||||
id object = [info objectForKey:@"object"];
|
||||
NSDictionary *userInfo = [info objectForKey:@"userInfo"];
|
||||
|
||||
[[self defaultCenter] postNotificationName:name object:object userInfo:userInfo];
|
||||
}
|
||||
@end
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "Worker.h"
|
||||
|
||||
extern NSString *JobCompletedNotification;
|
||||
extern NSString *JobCancelledNotification;
|
||||
|
||||
@interface ProgressController : NSWindowController <NSWindowDelegate>
|
||||
{
|
||||
NSButton *cancelButton;
|
||||
NSProgressIndicator *progressBar;
|
||||
NSTextField *statusText;
|
||||
NSTextField *descText;
|
||||
|
||||
id _jobId;
|
||||
BOOL _running;
|
||||
NSObject<Worker> *_worker;
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSButton *cancelButton;
|
||||
@property (readwrite, retain) NSProgressIndicator *progressBar;
|
||||
@property (readwrite, retain) NSTextField *statusText;
|
||||
@property (readwrite, retain) NSTextField *descText;
|
||||
|
||||
+ (ProgressController *)mainProgressController;
|
||||
|
||||
- (id)init;
|
||||
|
||||
- (void)cancel;
|
||||
|
||||
- (void)hide;
|
||||
- (void)show;
|
||||
- (void)showWithCancelButton:(BOOL)cancelEnabled;
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow;
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow withCancelButton:(BOOL)cancelEnabled;
|
||||
|
||||
/* Properties */
|
||||
- (BOOL)isShown;
|
||||
- (id)jobId;
|
||||
- (void)setJobId:(id)jobId;
|
||||
- (void)setJobDesc:(NSString *)desc;
|
||||
- (void)setWorker:(NSObject<Worker> *)worker;
|
||||
@end
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "ProgressController.h"
|
||||
#import "Utils.h"
|
||||
#import "ProgressController_UI.h"
|
||||
|
||||
NSString *JobCompletedNotification = @"JobCompletedNotification";
|
||||
NSString *JobCancelledNotification = @"JobCancelledNotification";
|
||||
static ProgressController *_mainPC = nil;
|
||||
|
||||
@implementation ProgressController
|
||||
|
||||
@synthesize cancelButton;
|
||||
@synthesize progressBar;
|
||||
@synthesize statusText;
|
||||
@synthesize descText;
|
||||
|
||||
+ (ProgressController *)mainProgressController
|
||||
{
|
||||
if (_mainPC == nil)
|
||||
_mainPC = [[ProgressController alloc] init];
|
||||
return _mainPC;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super initWithWindow:nil];
|
||||
[self setWindow:createProgressController_UI(self)];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||
_worker = nil;
|
||||
_running = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
{
|
||||
[self hide];
|
||||
}
|
||||
|
||||
- (void)hide
|
||||
{
|
||||
if (_worker != nil)
|
||||
[_worker cancelJob];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JobCancelledNotification object:self];
|
||||
_running = NO;
|
||||
[NSApp endSheet:[self window] returnCode:NSRunAbortedResponse];
|
||||
/* There's this really strange thing where when the app is inactive at the point we want to hide
|
||||
the progress dialog, it becomes impossible to close it. I guess it's due to some strange
|
||||
thread-related crap. Anyway, *DO NOT HIDE THE SHEET WHILE THE APP IS INACTIVE*. Do it later,
|
||||
when the app becomes active again.
|
||||
*/
|
||||
if ([NSApp isActive]) {
|
||||
[[self window] orderOut:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
[self showWithCancelButton:YES];
|
||||
}
|
||||
|
||||
- (void)showWithCancelButton:(BOOL)cancelEnabled
|
||||
{
|
||||
[progressBar setIndeterminate:YES];
|
||||
[[self window] makeKeyAndOrderFront:nil];
|
||||
[progressBar setUsesThreadedAnimation:YES];
|
||||
[progressBar startAnimation:nil];
|
||||
[cancelButton setEnabled:cancelEnabled];
|
||||
_running = YES;
|
||||
[NSThread detachNewThreadSelector:@selector(threadedWorkerProbe) toTarget:self withObject:nil];
|
||||
}
|
||||
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow
|
||||
{
|
||||
[self showSheetForParent:parentWindow withCancelButton:YES];
|
||||
}
|
||||
|
||||
- (void)showSheetForParent:(NSWindow *) parentWindow withCancelButton:(BOOL)cancelEnabled
|
||||
{
|
||||
[progressBar setIndeterminate:YES];
|
||||
[progressBar startAnimation:nil];
|
||||
[cancelButton setEnabled:cancelEnabled];
|
||||
_running = YES;
|
||||
[NSThread detachNewThreadSelector:@selector(threadedWorkerProbe) toTarget:self withObject:nil];
|
||||
[NSApp beginSheet:[self window] modalForWindow:parentWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
|
||||
}
|
||||
|
||||
- (void)updateProgress
|
||||
{
|
||||
if (!_running)
|
||||
return;
|
||||
NSNumber *progress = [_worker getJobProgress];
|
||||
NSString *status = [_worker getJobDesc];
|
||||
if ((status != nil) && ([status length] > 0))
|
||||
{
|
||||
[statusText setStringValue:status];
|
||||
}
|
||||
if (progress != nil)
|
||||
{
|
||||
[progressBar setDoubleValue:n2i(progress)];
|
||||
[progressBar setIndeterminate: n2i(progress) < 0];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self hide];
|
||||
[_worker jobCompleted:_jobId];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JobCompletedNotification object:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)threadedWorkerProbe
|
||||
{
|
||||
while (_running && (_worker != nil))
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
||||
[self performSelectorOnMainThread:@selector(updateProgress) withObject:nil waitUntilDone:YES];
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
- (BOOL)isShown
|
||||
{
|
||||
return _running;
|
||||
}
|
||||
|
||||
- (id)jobId {return _jobId;}
|
||||
- (void)setJobId:(id)jobId
|
||||
{
|
||||
[_jobId autorelease];
|
||||
_jobId = [jobId retain];
|
||||
}
|
||||
|
||||
- (void)setJobDesc:(NSString *)desc
|
||||
{
|
||||
[descText setStringValue:desc];
|
||||
[statusText setStringValue:NSLocalizedStringFromTable(@"Please wait...", @"cocoalib", @"")];
|
||||
}
|
||||
|
||||
- (void)setWorker:(NSObject<Worker> *)worker
|
||||
{
|
||||
_worker = worker;
|
||||
}
|
||||
|
||||
/* Delegate and Notifs */
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
||||
{
|
||||
if (!_running) {
|
||||
[[self window] orderOut:nil];
|
||||
}
|
||||
}
|
||||
@end
|
@ -1 +0,0 @@
|
||||
Versions/Current/Headers
|
@ -1 +0,0 @@
|
||||
Versions/Current/Resources
|
@ -1 +0,0 @@
|
||||
Versions/Current/Sparkle
|
@ -1,33 +0,0 @@
|
||||
//
|
||||
// SUAppcast.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
@class SUAppcastItem;
|
||||
@interface SUAppcast : NSObject {
|
||||
NSArray *items;
|
||||
NSString *userAgentString;
|
||||
id delegate;
|
||||
NSMutableData *incrementalData;
|
||||
}
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url;
|
||||
- (void)setDelegate:delegate;
|
||||
- (void)setUserAgentString:(NSString *)userAgentString;
|
||||
|
||||
- (NSArray *)items;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUAppcastDelegate)
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
|
||||
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
#endif
|
@ -1,47 +0,0 @@
|
||||
//
|
||||
// SUAppcastItem.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
@interface SUAppcastItem : NSObject {
|
||||
NSString *title;
|
||||
NSDate *date;
|
||||
NSString *itemDescription;
|
||||
|
||||
NSURL *releaseNotesURL;
|
||||
|
||||
NSString *DSASignature;
|
||||
NSString *minimumSystemVersion;
|
||||
|
||||
NSURL *fileURL;
|
||||
NSString *versionString;
|
||||
NSString *displayVersionString;
|
||||
|
||||
NSDictionary *propertiesDictionary;
|
||||
}
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- initWithDictionary:(NSDictionary *)dict;
|
||||
|
||||
- (NSString *)title;
|
||||
- (NSString *)versionString;
|
||||
- (NSString *)displayVersionString;
|
||||
- (NSDate *)date;
|
||||
- (NSString *)itemDescription;
|
||||
- (NSURL *)releaseNotesURL;
|
||||
- (NSURL *)fileURL;
|
||||
- (NSString *)DSASignature;
|
||||
- (NSString *)minimumSystemVersion;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
- (NSDictionary *)propertiesDictionary;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
@ -1,118 +0,0 @@
|
||||
//
|
||||
// SUUpdater.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUUPDATER_H
|
||||
#define SUUPDATER_H
|
||||
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
|
||||
@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
|
||||
@interface SUUpdater : NSObject {
|
||||
NSTimer *checkTimer;
|
||||
SUUpdateDriver *driver;
|
||||
|
||||
SUHost *host;
|
||||
IBOutlet id delegate;
|
||||
}
|
||||
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
- (NSBundle *)hostBundle;
|
||||
|
||||
- (void)setDelegate:(id)delegate;
|
||||
- delegate;
|
||||
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
|
||||
- (BOOL)automaticallyChecksForUpdates;
|
||||
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)interval;
|
||||
- (NSTimeInterval)updateCheckInterval;
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL;
|
||||
- (NSURL *)feedURL;
|
||||
|
||||
- (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
|
||||
- (BOOL)sendsSystemProfile;
|
||||
|
||||
- (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
|
||||
- (BOOL)automaticallyDownloadsUpdates;
|
||||
|
||||
// This IBAction is meant for a main menu item. Hook up any menu item to this action,
|
||||
// and Sparkle will check for updates and report back its findings verbosely.
|
||||
- (IBAction)checkForUpdates:sender;
|
||||
|
||||
// This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
|
||||
// in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
|
||||
// update is found, it will be downloaded and prepped for installation.
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
// Date of last update check. Returns null if no check has been performed.
|
||||
- (NSDate*)lastUpdateCheckDate;
|
||||
|
||||
// This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
|
||||
// (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
- (BOOL)updateInProgress;
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUpdaterDelegateInformalProtocol)
|
||||
// This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
// Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
|
||||
|
||||
// Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
// If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
|
||||
// a valid update, if any, in the given appcast.
|
||||
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
|
||||
|
||||
// Sent when a valid update is found by the update driver.
|
||||
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Sent when a valid update is not found.
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)update;
|
||||
|
||||
// Sent immediately before installing the specified update.
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
|
||||
|
||||
// Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
|
||||
|
||||
// Called immediately before relaunching.
|
||||
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
// This method allows you to provide a custom version comparator.
|
||||