mirror of
https://github.com/TermiT/Flycut.git
synced 2025-02-20 22:13:14 +08:00
Add 'source' and 'timestamp' to clipping objects so that it can be displayed in the bezel along with the clipping.
This commit is contained in:
parent
d1cd8508c2
commit
f068db6b03
5 changed files with 113 additions and 37 deletions
|
@ -597,7 +597,7 @@
|
|||
{
|
||||
// Check to see if they want a little help figuring out what types to enter.
|
||||
if ( [[DBUserDefaults standardUserDefaults] boolForKey:@"revealPasteboardTypes"] )
|
||||
[clippingStore addClipping:type ofType:type];
|
||||
[clippingStore addClipping:type ofType:type fromAppLocalizedName:@"Flycut" fromAppBundleURL:nil atTimestamp:0];
|
||||
|
||||
__block bool skipClipping = NO;
|
||||
|
||||
|
@ -665,11 +665,11 @@
|
|||
[pbCount release];
|
||||
pbCount = [[NSNumber numberWithInt:[jcPasteboard changeCount]] retain];
|
||||
if ( type != nil ) {
|
||||
NSString *currRunningApp = @"";
|
||||
NSRunningApplication *currRunningApp = nil;
|
||||
for (NSRunningApplication *currApp in [[NSWorkspace sharedWorkspace] runningApplications])
|
||||
if ([currApp isActive])
|
||||
currRunningApp = [currApp localizedName];
|
||||
bool largeCopyRisk = [currRunningApp rangeOfString:@"Remote Desktop Connection"].location != NSNotFound;
|
||||
currRunningApp = currApp;
|
||||
bool largeCopyRisk = nil != currRunningApp && [[currRunningApp localizedName] rangeOfString:@"Remote Desktop Connection"].location != NSNotFound;
|
||||
|
||||
// Microsoft's Remote Desktop Connection has an issue with large copy actions, which appears to be in the time it takes to transer them over the network. The copy starts being registered with OS X prior to completion of the transfer, and if the active application changes during the transfer the copy will be lost. Indicate this time period by toggling the menu icon at the beginning of all RDC trasfers and back at the end. Apple's Screen Sharing does not demonstrate this problem.
|
||||
if (largeCopyRisk)
|
||||
|
@ -704,7 +704,10 @@
|
|||
}
|
||||
|
||||
[clippingStore addClipping:contents
|
||||
ofType:type ];
|
||||
ofType:type
|
||||
fromAppLocalizedName:[currRunningApp localizedName]
|
||||
fromAppBundleURL:currRunningApp.bundleURL.path
|
||||
atTimestamp:[[NSDate date] timeIntervalSince1970]];
|
||||
// The below tracks our position down down down... Maybe as an option?
|
||||
// if ( [clippingStore jcListCount] > 1 ) stackPosition++;
|
||||
stackPosition = 0;
|
||||
|
@ -1063,7 +1066,10 @@
|
|||
NSArray *toBeRestoredClips = [[[savedJCList subarrayWithRange:loadRange] reverseObjectEnumerator] allObjects];
|
||||
for( NSDictionary *aSavedClipping in toBeRestoredClips)
|
||||
[clippingStore addClipping:[aSavedClipping objectForKey:@"Contents"]
|
||||
ofType:[aSavedClipping objectForKey:@"Type"]];
|
||||
ofType:[aSavedClipping objectForKey:@"Type"]
|
||||
fromAppLocalizedName:[aSavedClipping objectForKey:@"AppLocalizedName"]
|
||||
fromAppBundleURL:[aSavedClipping objectForKey:@"AppBundleURL"]
|
||||
atTimestamp:[[aSavedClipping objectForKey:@"Timestamp"] integerValue]];
|
||||
|
||||
// Now for the favorites, same thing.
|
||||
savedJCList =[loadDict objectForKey:@"favoritesList"];
|
||||
|
@ -1075,7 +1081,10 @@
|
|||
toBeRestoredClips = [[[savedJCList subarrayWithRange:loadRange] reverseObjectEnumerator] allObjects];
|
||||
for( NSDictionary *aSavedClipping in toBeRestoredClips)
|
||||
[favoritesStore addClipping:[aSavedClipping objectForKey:@"Contents"]
|
||||
ofType:[aSavedClipping objectForKey:@"Type"]];
|
||||
ofType:[aSavedClipping objectForKey:@"Type"]
|
||||
fromAppLocalizedName:[aSavedClipping objectForKey:@"AppLocalizedName"]
|
||||
fromAppBundleURL:[aSavedClipping objectForKey:@"AppBundleURL"]
|
||||
atTimestamp:[[aSavedClipping objectForKey:@"Timestamp"] integerValue]];
|
||||
}
|
||||
} else NSLog(@"Not array");
|
||||
[self updateMenu];
|
||||
|
@ -1102,7 +1111,7 @@
|
|||
-(void) fillBezel
|
||||
{
|
||||
JumpcutClipping* clipping = [clippingStore clippingAtPosition:stackPosition];
|
||||
[bezel setText:[clipping source]];
|
||||
[bezel setText:[NSString stringWithFormat:@"%@ - %@\n%@" , [clipping source],[NSDate dateWithTimeIntervalSince1970: [clipping timestamp]], [clipping contents]]];
|
||||
[bezel setCharString:[NSString stringWithFormat:@"%d of %d", stackPosition + 1, [clippingStore jcListCount]]];
|
||||
}
|
||||
|
||||
|
@ -1122,9 +1131,35 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)saveStore:(JumpcutStore *)store toKey:(NSString *)key onDict:(NSMutableDictionary *)saveDict {
|
||||
NSMutableArray *jcListArray = [NSMutableArray array];
|
||||
for ( int i = 0 ; i < [store jcListCount] ; i++ )
|
||||
{
|
||||
JumpcutClipping *clipping = [store clippingAtPosition:i];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[clipping contents], @"Contents",
|
||||
[clipping type], @"Type",
|
||||
[NSNumber numberWithInt:i], @"Position",nil];
|
||||
|
||||
NSString *val = [clipping appLocalizedName];
|
||||
if ( nil != val )
|
||||
[dict setObject:val forKey:@"AppLocalizedName"];
|
||||
|
||||
val = [clipping appBundleURL];
|
||||
if ( nil != val )
|
||||
[dict setObject:val forKey:@"AppBundleURL"];
|
||||
|
||||
int timestamp = [clipping timestamp];
|
||||
if ( timestamp > 0 )
|
||||
[dict setObject:[NSNumber numberWithInt:timestamp] forKey:@"Timestamp"];
|
||||
|
||||
[jcListArray addObject:dict];
|
||||
}
|
||||
[saveDict setObject:jcListArray forKey:key];
|
||||
}
|
||||
|
||||
-(void) saveEngine {
|
||||
NSMutableDictionary *saveDict;
|
||||
NSMutableArray *jcListArray = [NSMutableArray array];
|
||||
saveDict = [NSMutableDictionary dictionaryWithCapacity:3];
|
||||
[saveDict setObject:@"0.7" forKey:@"version"];
|
||||
[saveDict setObject:[NSNumber numberWithInt:[[DBUserDefaults standardUserDefaults] integerForKey:@"rememberNum"]]
|
||||
|
@ -1135,25 +1170,10 @@
|
|||
forKey:@"displayLen"];
|
||||
[saveDict setObject:[NSNumber numberWithInt:[[DBUserDefaults standardUserDefaults] integerForKey:@"displayNum"]]
|
||||
forKey:@"displayNum"];
|
||||
for (int i = 0 ; i < [clippingStore jcListCount]; i++)
|
||||
{
|
||||
JumpcutClipping* clipping = [clippingStore clippingAtPosition:i];
|
||||
[jcListArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[clipping contents], @"Contents",
|
||||
[clipping type], @"Type",
|
||||
[NSNumber numberWithInt:i], @"Position",nil]];
|
||||
}
|
||||
[saveDict setObject:jcListArray forKey:@"jcList"];
|
||||
jcListArray = [NSMutableArray array];
|
||||
for (int i = 0 ; i < [favoritesStore jcListCount]; i++)
|
||||
{
|
||||
JumpcutClipping* clipping = [favoritesStore clippingAtPosition:i];
|
||||
[jcListArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[clipping contents], @"Contents",
|
||||
[clipping type], @"Type",
|
||||
[NSNumber numberWithInt:i], @"Position",nil]];
|
||||
}
|
||||
[saveDict setObject:jcListArray forKey:@"favoritesList"];
|
||||
|
||||
[self saveStore:clippingStore toKey:@"jcList" onDict:saveDict];
|
||||
[self saveStore:favoritesStore toKey:@"favoritesList" onDict:saveDict];
|
||||
|
||||
[[DBUserDefaults standardUserDefaults] setObject:saveDict forKey:@"store"];
|
||||
[[DBUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
|
|
@ -38,9 +38,15 @@
|
|||
NSString * clipDisplayString;
|
||||
// Does it have a name?
|
||||
BOOL clipHasName;
|
||||
// The app name it came from
|
||||
NSString * appLocalizedName;
|
||||
// The the bunle URL of the app it came from
|
||||
NSString * appBundleURL;
|
||||
// The time
|
||||
int clipTimestamp;
|
||||
}
|
||||
|
||||
-(id) initWithContents:(NSString *)contents withType:(NSString *)type withDisplayLength:(int)displayLength;
|
||||
-(id) initWithContents:(NSString *)contents withType:(NSString *)type withDisplayLength:(int)displayLength withAppLocalizedName:(NSString *)localizedName withAppBundleURL:(NSString *)bundleURL withTimestamp:(int)timestamp;
|
||||
/* -(id) initWithCoder:(NSCoder *)coder;
|
||||
-(void) decodeWithCoder:(NSCoder *)coder; */
|
||||
-(NSString *) description;
|
||||
|
@ -58,6 +64,9 @@
|
|||
-(int) displayLength;
|
||||
-(NSString *) displayString;
|
||||
-(NSString *) type;
|
||||
-(NSString *) appLocalizedName;
|
||||
-(NSString *) appBundleURL;
|
||||
-(int) timestamp;
|
||||
-(BOOL) hasName;
|
||||
|
||||
// Additional functions
|
||||
|
|
|
@ -31,12 +31,15 @@
|
|||
-(id) init
|
||||
{
|
||||
[self initWithContents:@""
|
||||
withType:@""
|
||||
withDisplayLength:40];
|
||||
withType:@""
|
||||
withDisplayLength:40
|
||||
withAppLocalizedName:@""
|
||||
withAppBundleURL:nil
|
||||
withTimestamp:0];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initWithContents:(NSString *)contents withType:(NSString *)type withDisplayLength:(int)displayLength
|
||||
-(id) initWithContents:(NSString *)contents withType:(NSString *)type withDisplayLength:(int)displayLength withAppLocalizedName:(NSString *)localizedName withAppBundleURL:(NSString*)bundleURL withTimestamp:(int)timestamp
|
||||
{
|
||||
[super init];
|
||||
clipContents = [[[NSString alloc] init] retain];
|
||||
|
@ -45,6 +48,9 @@
|
|||
|
||||
[self setContents:contents setDisplayLength:displayLength];
|
||||
[self setType:type];
|
||||
[self setAppLocalizedName:localizedName];
|
||||
[self setAppBundleURL:bundleURL];
|
||||
[self setTimestamp:timestamp];
|
||||
[self setHasName:false];
|
||||
|
||||
return self;
|
||||
|
@ -116,6 +122,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
-(void) setAppLocalizedName:(NSString *)new
|
||||
{
|
||||
id old = appLocalizedName;
|
||||
[new retain];
|
||||
appLocalizedName = new;
|
||||
[old release];
|
||||
}
|
||||
|
||||
-(void) setAppBundleURL:(NSString *)new
|
||||
{
|
||||
id old = appBundleURL;
|
||||
[new retain];
|
||||
appBundleURL = new;
|
||||
[old release];
|
||||
}
|
||||
|
||||
-(void) setTimestamp:(NSString *)newTimestamp
|
||||
{
|
||||
clipTimestamp = newTimestamp;
|
||||
}
|
||||
|
||||
-(void) setHasName:(BOOL)newHasName
|
||||
{
|
||||
clipHasName = newHasName;
|
||||
|
@ -163,6 +190,21 @@
|
|||
return clipContents;
|
||||
}
|
||||
|
||||
-(NSString *) appLocalizedName
|
||||
{
|
||||
return appLocalizedName;
|
||||
}
|
||||
|
||||
-(NSString *) appBundleURL
|
||||
{
|
||||
return appBundleURL;
|
||||
}
|
||||
|
||||
-(int) timestamp
|
||||
{
|
||||
return clipTimestamp;
|
||||
}
|
||||
|
||||
-(int) displayLength
|
||||
{
|
||||
return clipDisplayLength;
|
||||
|
@ -206,6 +248,8 @@
|
|||
{
|
||||
[clipContents release];
|
||||
[clipType release];
|
||||
[appLocalizedName release];
|
||||
[appBundleURL release];
|
||||
clipDisplayLength = 0;
|
||||
[clipDisplayString release];
|
||||
clipHasName = 0;
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
-(NSArray *) previousIndexes:(int)howMany containing:(NSString*)search; // This method is in newest-first order.
|
||||
|
||||
// Add a clipping
|
||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type;
|
||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type fromAppLocalizedName:(NSString *)appLocalizedName fromAppBundleURL:(NSString *)bundleURL atTimestamp:(int) timestamp;
|
||||
-(void) addClipping:(JumpcutClipping*) clipping;
|
||||
|
||||
// Delete a clipping
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
}
|
||||
|
||||
// Add a clipping
|
||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type{
|
||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type fromAppLocalizedName:(NSString *)appLocalizedName fromAppBundleURL:(NSString *)bundleURL atTimestamp:(int) timestamp{
|
||||
if ([clipping length] == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -59,7 +59,10 @@
|
|||
// Create clipping
|
||||
newClipping = [[JumpcutClipping alloc] initWithContents:clipping
|
||||
withType:type
|
||||
withDisplayLength:[self displayLen]];
|
||||
withDisplayLength:[self displayLen]
|
||||
withAppLocalizedName:appLocalizedName
|
||||
withAppBundleURL:bundleURL
|
||||
withTimestamp:timestamp];
|
||||
|
||||
[self addClipping:newClipping];
|
||||
|
||||
|
@ -80,7 +83,7 @@
|
|||
|
||||
-(void) addClipping:(NSString *)clipping ofType:(NSString *)type withPBCount:(int *)pbCount
|
||||
{
|
||||
[self addClipping:clipping ofType:type];
|
||||
[self addClipping:clipping ofType:type fromAppLocalizedName:@"PBCount" fromAppBundleURL:nil atTimestamp:0];
|
||||
}
|
||||
|
||||
// Clear remembered and listed
|
||||
|
@ -93,7 +96,7 @@
|
|||
|
||||
-(void) mergeList {
|
||||
NSString *merge = [[[[jcList reverseObjectEnumerator] allObjects] valueForKey:@"clipContents"] componentsJoinedByString:@"\n"];
|
||||
[self addClipping:merge ofType:NSStringFromClass([merge class])];
|
||||
[self addClipping:merge ofType:NSStringFromClass([merge class]) fromAppLocalizedName:@"Merge" fromAppBundleURL:nil atTimestamp:0];
|
||||
}
|
||||
|
||||
-(void) clearItem:(int)index
|
||||
|
|
Loading…
Reference in a new issue