Subversion Repositories TruePreview

Compare Revisions

Ignore whitespace Rev 17 → Rev 23

/trunk/Source/TruePreview.m
73,6 → 73,16
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(forwardAsAttachment:)
withMethod:@selector(truePreviewForwardAsAttachment:)
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(forwardMessage:)
withMethod:@selector(truePreviewForwardMessage:)
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(markAsRead:)
withMethod:@selector(truePreviewMarkAsRead:)
isClassMethod:NO
83,15 → 93,25
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(messageNoLongerDisplayedInTextView:)
withMethod:@selector(truePreviewMessageNoLongerDisplayedInTextView:)
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(messageWasDisplayedInTextView:)
withMethod:@selector(truePreviewMessageWasDisplayedInTextView:)
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(messageNoLongerDisplayedInTextView:)
withMethod:@selector(truePreviewMessageNoLongerDisplayedInTextView:)
truePreviewSwizzleMethod:@selector(replyAllMessage:)
withMethod:@selector(truePreviewReplyAllMessage:)
isClassMethod:NO
];
[NSClassFromString(@"MessageViewer")
truePreviewSwizzleMethod:@selector(replyMessage:)
withMethod:@selector(truePreviewReplyMessage:)
isClassMethod:NO
];
[NSClassFromString(@"NSPreferences")
truePreviewSwizzleMethod:@selector(sharedPreferences)
withMethod:@selector(truePreviewSharedPreferences)
102,6 → 122,8
[[NSUserDefaults standardUserDefaults]
registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_IMMEDIATE], @"TruePreviewDelay",
[NSNumber numberWithInt:NSOnState], @"TruePreviewReply",
[NSNumber numberWithInt:NSOnState], @"TruePreviewForward",
[NSNumber numberWithInt:NSOnState], @"TruePreviewWindow",
[NSNumber numberWithInt:NSOffState], @"TruePreviewScroll",
nil
/trunk/Source/TruePreviewMessageViewer.h
72,6 → 72,22
- (void)truePreviewDealloc;
 
/*!
* Marks the currently-displayed message as read if configured to do so when
* forwarding.
* @param inSender
* Unused.
*/
- (void)truePreviewForwardAsAttachment:(id)inSender;
 
/*!
* Marks the currently-displayed message as read if configured to do so when
* forwarding.
* @param inSender
* Unused.
*/
- (void)truePreviewForwardMessage:(id)inSender;
 
/*!
* Invalidates this instance's timer and stops observing scroll changes when a
* message is explicitly marked as read.
* @param inSender
88,6 → 104,13
- (void)truePreviewMarkAsUnread:(id)inSender;
 
/*!
* Invalidates this instance's timer and stops observing scroll changes.
* @param inNotification
* The <code>NSNotification</code> describing the event.
*/
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification;
 
/*!
* Marks the displayed message as viewed, sets a timer to mark the displayed
* message as viewed, and/or adds a notification observer to mark the message as
* viewed when it is scrolled as appropriate.
97,12 → 120,21
- (void)truePreviewMessageWasDisplayedInTextView:(id)inNotification;
 
/*!
* Invalidates this instance's timer and stops observing scroll changes.
* @param inNotification
* The <code>NSNotification</code> describing the event.
* Marks the currently-displayed message as read if configured to do so when
* replying.
* @param inSender
* Unused.
*/
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification;
- (void)truePreviewReplyAllMessage:(id)inSender;
 
/*!
* Marks the currently-displayed message as read if configured to do so when
* replying.
* @param inSender
* Unused.
*/
- (void)truePreviewReplyMessage:(id)inSender;
 
#pragma mark Accessors
/*! @group Accessors */
 
/trunk/Source/TruePreviewMessageViewer.m
55,6 → 55,36
[self truePreviewDealloc];
}
 
- (void)truePreviewForwardAsAttachment:(id)inSender {
id theMessage = [self currentDisplayedMessage];
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) {
NSDictionary* theSettings = [theMessage truePreviewSettings];
if ([[theSettings objectForKey:@"forward"] boolValue]) {
[self truePreviewReset];
[theMessage truePreviewMarkAsViewed];
}
}
[self truePreviewForwardAsAttachment:inSender];
}
 
- (void)truePreviewForwardMessage:(id)inSender {
id theMessage = [self currentDisplayedMessage];
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) {
NSDictionary* theSettings = [theMessage truePreviewSettings];
if ([[theSettings objectForKey:@"forward"] boolValue]) {
[self truePreviewReset];
[theMessage truePreviewMarkAsViewed];
}
}
[self truePreviewForwardMessage:inSender];
}
 
- (void)truePreviewMarkAsRead:(id)inSender {
[self truePreviewReset];
[self truePreviewMarkAsRead:inSender];
65,9 → 95,25
[self truePreviewMarkAsUnread:inSender];
}
 
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification {
[self truePreviewMessageNoLongerDisplayedInTextView:inNotification];
 
// we receive notifications from all MessageContentControllers
if ([inNotification object] != object_getIvar(self, class_getInstanceVariable([self class], "_contentController"))) {
return;
}
[self truePreviewReset];
}
 
- (void)truePreviewMessageWasDisplayedInTextView:(NSNotification*)inNotification {
[self truePreviewMessageWasDisplayedInTextView:inNotification];
// we receive notifications from all MessageContentControllers
if ([inNotification object] != object_getIvar(self, class_getInstanceVariable([self class], "_contentController"))) {
return;
}
id theMessage = [[inNotification userInfo] objectForKey:@"MessageKey"];
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) {
101,23 → 147,51
];
}
if ([[theSettings objectForKey:@"scroll"] boolValue]) {
if (
![self isKindOfClass:NSClassFromString(@"SingleMessageViewer")]
&& [[theSettings objectForKey:@"scroll"] boolValue]
) {
// listen for bounds change notification on the message's clip view
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(truePreviewBoundsDidChange:)
name:NSViewBoundsDidChangeNotification
object:[[[[object_getIvar(self, class_getInstanceVariable([self class], "_contentController")) currentDisplay] contentView] enclosingScrollView] contentView]
];
addObserver:self
selector:@selector(truePreviewBoundsDidChange:)
name:NSViewBoundsDidChangeNotification
object:[[[[object_getIvar(self, class_getInstanceVariable([self class], "_contentController")) currentDisplay] contentView] enclosingScrollView] contentView]
];
}
}
}
 
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification {
[self truePreviewMessageNoLongerDisplayedInTextView:inNotification];
[self truePreviewReset];
- (void)truePreviewReplyAllMessage:(id)inSender {
id theMessage = [self currentDisplayedMessage];
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) {
NSDictionary* theSettings = [theMessage truePreviewSettings];
if ([[theSettings objectForKey:@"reply"] boolValue]) {
[self truePreviewReset];
[theMessage truePreviewMarkAsViewed];
}
}
[self truePreviewReplyAllMessage:inSender];
}
 
- (void)truePreviewReplyMessage:(id)inSender {
id theMessage = [self currentDisplayedMessage];
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) {
NSDictionary* theSettings = [theMessage truePreviewSettings];
 
if ([[theSettings objectForKey:@"reply"] boolValue]) {
[self truePreviewReset];
[theMessage truePreviewMarkAsViewed];
}
}
[self truePreviewReplyMessage:inSender];
}
 
#pragma mark Accessors
 
- (NSTimer*)truePreviewTimer {
/trunk/Source/TruePreviewPreferencesModule.m
52,6 → 52,8
NSMutableDictionary* theAccount = [NSMutableDictionary dictionaryWithObjectsAndKeys:
theDisplayName, @"displayName",
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"delay",
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"reply",
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"forward",
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"window",
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"scroll",
nil
72,6 → 74,20
[theAccounts
addObserver:self
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
forKeyPath:@"reply"
options:0
context:theAccounts
];
[theAccounts
addObserver:self
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
forKeyPath:@"forward"
options:0
context:theAccounts
];
[theAccounts
addObserver:self
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
forKeyPath:@"window"
options:0
context:theAccounts
94,11 → 110,9
change:(NSDictionary*)inChange
context:(void*)inContext {
NSMutableDictionary* theAccountDict = [NSMutableDictionary dictionary];
NSEnumerator* theAccountEnum = [(NSArray*)inContext objectEnumerator];
NSDictionary* theAccount = nil;
// build the account settings dictionary to save in the user defaults
while (theAccount = [theAccountEnum nextObject]) {
for (NSDictionary* theAccount in (NSArray*)inContext) {
[theAccountDict setObject:theAccount forKey:[theAccount objectForKey:@"displayName"]];
}
/trunk/Source/TruePreviewLibraryMessage.m
44,6 → 44,8
- (NSMutableDictionary*)truePreviewSettings {
NSMutableDictionary* theSettings = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewDelay"], @"delay",
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewReply"], @"reply",
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewForward"], @"forward",
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewWindow"], @"window",
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewScroll"], @"scroll",
nil
54,7 → 56,7
];
if (theAccountSettings != nil) {
for (id theKey in [NSArray arrayWithObjects:@"delay", @"window", @"scroll", nil]) {
for (id theKey in [NSArray arrayWithObjects:@"delay", @"reply", @"forward", @"window", @"scroll", nil]) {
id theValue = [theAccountSettings objectForKey:theKey];
if ((theValue != nil) && ([theValue intValue] != TRUEPREVIEW_DELAY_DEFAULT)) {