Skip to content

Commit

Permalink
Show unread count for all items.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdherbemont committed Jun 22, 2010
1 parent 466a5d9 commit bca88b9
Show file tree
Hide file tree
Showing 24 changed files with 1,837 additions and 1,715 deletions.
20 changes: 18 additions & 2 deletions Lunettes.xcodeproj/project.pbxproj
Expand Up @@ -140,6 +140,10 @@
63311C21118B3F9200C21FD6 /* shelf.png in Resources */ = {isa = PBXBuildFile; fileRef = 63311C20118B3F9200C21FD6 /* shelf.png */; };
6336ACD411AC7F9300433523 /* VLCTVShowEpisodesInfoGrabber.m in Sources */ = {isa = PBXBuildFile; fileRef = 6336ACD311AC7F9300433523 /* VLCTVShowEpisodesInfoGrabber.m */; };
63374C7310EAF38A0072A0D9 /* noartwork.png in Resources */ = {isa = PBXBuildFile; fileRef = 63374C7210EAF3890072A0D9 /* noartwork.png */; };
635972AD11CCF5340008BCE2 /* splash-label.js in Resources */ = {isa = PBXBuildFile; fileRef = 635972AA11CCF5240008BCE2 /* splash-label.js */; };
635972AE11CCF5340008BCE2 /* splash-media-db.js in Resources */ = {isa = PBXBuildFile; fileRef = 635972AB11CCF5240008BCE2 /* splash-media-db.js */; };
635972AF11CCF5340008BCE2 /* splash-tvshow.js in Resources */ = {isa = PBXBuildFile; fileRef = 635972AC11CCF5240008BCE2 /* splash-tvshow.js */; };
635972B111CCF6450008BCE2 /* splash-screen.css in Resources */ = {isa = PBXBuildFile; fileRef = 635972B011CCF6450008BCE2 /* splash-screen.css */; };
635D1124104A844000D34A87 /* AboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 635D1123104A844000D34A87 /* AboutWindow.xib */; };
635D112A104A846400D34A87 /* OpenURLWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 635D1129104A846400D34A87 /* OpenURLWindow.xib */; };
635D112C104A846400D34A87 /* PreferencesWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 635D112B104A846400D34A87 /* PreferencesWindow.xib */; };
Expand Down Expand Up @@ -699,6 +703,10 @@
6336ACD311AC7F9300433523 /* VLCTVShowEpisodesInfoGrabber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCTVShowEpisodesInfoGrabber.m; path = Sources/VLCTVShowEpisodesInfoGrabber.m; sourceTree = "<group>"; };
63374A6E10EACFEE0072A0D9 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
63374C7210EAF3890072A0D9 /* noartwork.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = noartwork.png; path = Style/Default/noartwork.png; sourceTree = "<group>"; };
635972AA11CCF5240008BCE2 /* splash-label.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "splash-label.js"; path = "Style/Default/splash-label.js"; sourceTree = "<group>"; };
635972AB11CCF5240008BCE2 /* splash-media-db.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "splash-media-db.js"; path = "Style/Default/splash-media-db.js"; sourceTree = "<group>"; };
635972AC11CCF5240008BCE2 /* splash-tvshow.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "splash-tvshow.js"; path = "Style/Default/splash-tvshow.js"; sourceTree = "<group>"; };
635972B011CCF6450008BCE2 /* splash-screen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = "splash-screen.css"; path = "Style/Default/splash-screen.css"; sourceTree = "<group>"; };
635D1121104A843D00D34A87 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/AboutWindow.xib; sourceTree = "<group>"; };
635D1125104A846000D34A87 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/OpenURLWindow.xib; sourceTree = "<group>"; };
635D1126104A846000D34A87 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PreferencesWindow.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -980,6 +988,10 @@
isa = PBXGroup;
children = (
63161BEF10CAC3EF0091974E /* default.css */,
635972AA11CCF5240008BCE2 /* splash-label.js */,
635972AB11CCF5240008BCE2 /* splash-media-db.js */,
635972AC11CCF5240008BCE2 /* splash-tvshow.js */,
635972B011CCF6450008BCE2 /* splash-screen.css */,
639FDAF8111787B1007EE416 /* splash-screen.html */,
63161BF010CAC3EF0091974E /* hud.css */,
63161BF210CAC3EF0091974E /* hud.js */,
Expand Down Expand Up @@ -1598,11 +1610,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
635972AD11CCF5340008BCE2 /* splash-label.js in Resources */,
635972AE11CCF5340008BCE2 /* splash-media-db.js in Resources */,
635972AF11CCF5340008BCE2 /* splash-tvshow.js in Resources */,
63161CB910CAC68A0091974E /* hud.js in Resources */,
63161CBA10CAC68A0091974E /* PlaylistController.js in Resources */,
63161BF510CAC3EF0091974E /* default.css in Resources */,
63161BF610CAC3EF0091974E /* hud.css in Resources */,
63161BF710CAC3EF0091974E /* hud.html in Resources */,
639FDAF9111787B1007EE416 /* splash-screen.html in Resources */,
63161BF810CAC3EF0091974E /* video-window.html in Resources */,
63161C1210CAC4190091974E /* fs_exit_fullscreen_highlight.png in Resources */,
63161C1310CAC4190091974E /* fs_exit_fullscreen.png in Resources */,
Expand All @@ -1629,7 +1645,6 @@
63161C3110CAC48B0091974E /* Info.plist in Resources */,
6314289D10D96B3200363AB7 /* volume_high.png in Resources */,
63374C7310EAF38A0072A0D9 /* noartwork.png in Resources */,
639FDAF9111787B1007EE416 /* splash-screen.html in Resources */,
63E3F0201144E79500A62577 /* not-played.png in Resources */,
63E3F0291144EAAE00A62577 /* remove-on.png in Resources */,
63E3F02A1144EAAE00A62577 /* remove.png in Resources */,
Expand All @@ -1645,6 +1660,7 @@
63311C21118B3F9200C21FD6 /* shelf.png in Resources */,
63635DC81192E84E00A348A6 /* clips.png in Resources */,
6370D0E711AF265600FB3965 /* action-button.png in Resources */,
635972B111CCF6450008BCE2 /* splash-screen.css in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1888,7 +1904,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd $SRCROOT/Style\nIFS=$'\\n'\nfiles=`find . -name \"*.js\"`;\ncmd=\"\";\n\nprettyfiles=\"\"\nfor i in $files; do\n\t# Only process changed files\n\tchangeFile=\"$BUILT_PRODUCTS_DIR/Style/$i.change\"\n\tdir=`dirname \"$changeFile\"`;\n\tmkdir -p \"$dir\"\n\n\tif test -e \"$i\" && ((! test -e \"${changeFile}\") || test \"$i\" -nt \"${changeFile}\" ); then\n \thasChangedFiles=true;\n\t\ttouch \"$changeFile\";\n\tfi\n\tcmd=\"$cmd --js $i\";\n prettyfiles=\"$i $prettyfiles\"\ndone;\n\nunset IFS\n\nif [ $hasChangedFiles ]; then\n\techo \"Analyzing $prettyfiles\";\n\tjava -jar $SRCROOT/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE $cmd --js_output_file /tmp/js.js;\n\terror=$?;\n\tif [ $error -ne 0 ]; then\n\t\t# Remove one touch file so that we will re-run this\n\t\trm \"$changeFile\";\n\t\techo \"Error - aborting\";\n\t\texit 1;\n\tfi\nfi\n\n";
shellScript = "#Disabled\nexit 0;\n\ncd $SRCROOT/Style\nIFS=$'\\n'\nfiles=`find . -name \"*.js\"`;\ncmd=\"\";\n\n\nprettyfiles=\"\"\nfor i in $files; do\n\t# Only process changed files\n\tchangeFile=\"$BUILT_PRODUCTS_DIR/Style/$i.change\"\n\tdir=`dirname \"$changeFile\"`;\n\tmkdir -p \"$dir\"\n\n\tif test -e \"$i\" && ((! test -e \"${changeFile}\") || test \"$i\" -nt \"${changeFile}\" ); then\n \thasChangedFiles=true;\n\t\ttouch \"$changeFile\";\n\tfi\n\tcmd=\"$cmd --js $i\";\n prettyfiles=\"$i $prettyfiles\"\ndone;\n\nunset IFS\n\nif [ $hasChangedFiles ]; then\n\techo \"Analyzing $prettyfiles\";\n\tjava -jar $SRCROOT/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE $cmd --js_output_file /tmp/js.js;\n\terror=$?;\n\tif [ $error -ne 0 ]; then\n\t\t# Remove one touch file so that we will re-run this\n\t\trm \"$changeFile\";\n\t\techo \"Error - aborting\";\n\t\texit 1;\n\tfi\nfi\n\n";
};
CC29B3F811529E4500BD4CA1 /* Set Git Version */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
Binary file modified MediaLibrary.xcdatamodel/elements
Binary file not shown.
Binary file modified MediaLibrary.xcdatamodel/layout
Binary file not shown.
64 changes: 12 additions & 52 deletions Resources/English.lproj/NewSplashScreenWindow.xib
Expand Up @@ -275,31 +275,7 @@
<bool key="NSEditable">YES</bool>
<bool key="NSAutomaticallyPreparesContent">YES</bool>
<object class="_NSManagedProxy" key="_NSManagedProxy">
<string key="NSEntityName">File</string>
<object class="NSComparisonPredicate" key="NSFetchPredicate">
<object class="NSKeyPathExpression" key="NSLeftExpression">
<int key="NSExpressionType">3</int>
<string key="NSSelectorName">valueForKey:</string>
<reference key="NSOperand" ref="1072345023"/>
<object class="NSMutableArray" key="NSArguments">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSKeyPathSpecifierExpression">
<int key="NSExpressionType">10</int>
<string key="NSKeyPath">type</string>
</object>
</object>
</object>
<object class="NSConstantValueExpression" key="NSRightExpression">
<int key="NSExpressionType">0</int>
<string key="NSConstantValue">tvShowEpisode</string>
</object>
<object class="NSEqualityPredicateOperator" key="NSPredicateOperator">
<int key="NSOperatorType">4</int>
<int key="NSModifier">0</int>
<bool key="NSNegate">NO</bool>
<int key="NSOptions">0</int>
</object>
</object>
<string key="NSEntityName">ShowEpisode</string>
</object>
<bool key="_NSIsUsingManagedProxy">YES</bool>
<bool key="NSAvoidsEmptySelection">YES</bool>
Expand Down Expand Up @@ -429,14 +405,6 @@
</object>
<int key="connectionID">587</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_orphanedTVShowEpisodeArrayController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="234345303"/>
</object>
<int key="connectionID">588</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">sortDescriptors: sortDescriptor</string>
Expand All @@ -453,22 +421,6 @@
</object>
<int key="connectionID">590</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">sortDescriptors: sortDescriptor</string>
<reference key="source" ref="234345303"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="234345303"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">sortDescriptors: sortDescriptor</string>
<string key="NSBinding">sortDescriptors</string>
<string key="NSKeyPath">sortDescriptor</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">592</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">sortDescriptors: sortDescriptorsForTVShows</string>
Expand Down Expand Up @@ -565,6 +517,14 @@
</object>
<int key="connectionID">600</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_tvShowEpisodesArrayController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="234345303"/>
</object>
<int key="connectionID">601</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -679,7 +639,7 @@
<int key="objectID">582</int>
<reference key="object" ref="234345303"/>
<reference key="parent" ref="0"/>
<string key="objectName">Orphaned TV Show Episode Array Controller</string>
<string key="objectName">TV Show Episodes Array Controller</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">585</int>
Expand Down Expand Up @@ -764,7 +724,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">600</int>
<int key="maxID">601</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -828,7 +788,7 @@
<string>_mediaDiscoverCollection</string>
<string>_mediaDiscovererArrayController</string>
<string>_moviesArrayController</string>
<string>_orphanedTVShowEpisodeArrayController</string>
<string>_tvShowEpisodesArrayController</string>
<string>_tvShowsArrayController</string>
<string>_unfinishedItemsCollection</string>
</object>
Expand Down
31 changes: 16 additions & 15 deletions Sources/Show.m
Expand Up @@ -18,20 +18,21 @@ @implementation Show
@dynamic lastSyncDate;
@dynamic releaseYear;
@dynamic episodes;
@dynamic unreadEpisodes;

- (NSSet *)unreadEpisodes
{
NSSet *episodes = [self episodes];
NSMutableSet *set = [NSMutableSet set];
for(id episode in set) {
NSSet *files = [episode valueForKey:@"files"];
for(id file in files) {
if ([[file valueForKey:@"unread"] boolValue]) {
[set addObject:episode];
break;
}
}
}
return set;
}
//- (NSSet *)unreadEpisodes
//{
// NSSet *episodes = [self episodes];
// NSMutableSet *set = [NSMutableSet set];
// for(id episode in set) {
// NSSet *files = [episode valueForKey:@"files"];
// for(id file in files) {
// if ([[file valueForKey:@"unread"] boolValue]) {
// [set addObject:episode];
// break;
// }
// }
// }
// return set;
//}
@end
17 changes: 17 additions & 0 deletions Sources/ShowEpisode.m
Expand Up @@ -6,13 +6,30 @@
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "VLCMediaLibrary.h"
#import "ShowEpisode.h"

#import "Show.h"

@interface ShowEpisode ()
@property (nonatomic, retain) NSNumber *primitiveUnread;
@end

@implementation ShowEpisode
@dynamic primitiveUnread;

@dynamic unread;


- (void)setUnread:(NSNumber *)unread
{
NSLog(@"Setting unread %@", unread);
[self willChangeValueForKey:@"unread"];
[self setPrimitiveUnread:unread];
[self didChangeValueForKey:@"unread"];
[[[VLCLMediaLibrary sharedMediaLibrary] managedObjectContext] refreshObject:[self show] mergeChanges:YES];
}

@dynamic theTVDBID;
@dynamic shortSummary;
@dynamic shouldBeDisplayed;
Expand Down
14 changes: 8 additions & 6 deletions Sources/VLCApplication.m
Expand Up @@ -50,6 +50,8 @@ @implementation VLCApplication

- (void)awakeFromNib
{
[[VLCExceptionHandler sharedHandler] setup];

// FIXME: -awakeFromNib is certainly not the right place to do the following
WebPreferences *preferences = [WebPreferences standardPreferences];
[preferences setCacheModel:WebCacheModelDocumentViewer];
Expand Down Expand Up @@ -113,12 +115,12 @@ - (void)dealloc
[super dealloc];
}

- (void)reportException:(NSException *)anException
{
// Make sure our VLCExceptionHandler get this exception
[[VLCExceptionHandler sharedHandler] handleUncaughtException:anException];
}

//- (void)reportException:(NSException *)anException
//{
// // Make sure our VLCExceptionHandler get this exception
// [[VLCExceptionHandler sharedHandler] handleUncaughtException:anException];
//}
//
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
/* handle existing crash reports and send if needed */
Expand Down
1 change: 1 addition & 0 deletions Sources/VLCExceptionHandler.h
Expand Up @@ -27,6 +27,7 @@

@interface VLCExceptionHandler : NSObject
+ (VLCExceptionHandler *)sharedHandler;
- (void)setup;
- (void)handleUncaughtException:(NSException *)exception;
- (void)printStackTrace:(NSException *)exception;
@end
20 changes: 16 additions & 4 deletions Sources/VLCExceptionHandler.m
Expand Up @@ -38,22 +38,26 @@ + (void)load
NSExceptionHandler *handler = [NSExceptionHandler defaultExceptionHandler];
[handler setDelegate:expectionHandlerDelegate];

NSUInteger mask = NSLogUncaughtExceptionMask | NSLogTopLevelExceptionMask;
NSUInteger mask = NSLogAndHandleEveryExceptionMask;

[handler setExceptionHandlingMask:mask];
NSSetUncaughtExceptionHandler(VLCUncaughtExceptionHandler);
}

+ (VLCExceptionHandler *)sharedHandler
{
return expectionHandlerDelegate;
}

- (void)setup
{
NSSetUncaughtExceptionHandler(VLCUncaughtExceptionHandler);
}

- (void)handleUncaughtException:(NSException *)exception
{
@try {
// From now on, just log followin exception
[[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:NSLogUncaughtExceptionMask];
[[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:0];

NSLog(@"*** Exception Handled! %@: %@", [exception name], [exception reason]);
[self printStackTrace:exception];
Expand All @@ -79,8 +83,15 @@ - (void)handleUncaughtException:(NSException *)exception
/* From Apple's guide on exception */
- (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldLogException:(NSException *)exception mask:(NSUInteger)aMask
{
return NO;
}

- (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldHandleException:(NSException *)exception mask:(NSUInteger)mask
{
#ifdef DEBUG
[self handleUncaughtException:exception];
return YES;
#endif
return NO;
}

- (void)printStackTrace:(NSException *)e
Expand All @@ -106,6 +117,7 @@ - (void)printStackTrace:(NSException *)e
[ls setLaunchPath:@"/usr/bin/atos"];
[ls setArguments:args];
[ls launch];

[ls release];
}

Expand Down
1 change: 1 addition & 0 deletions Sources/VLCMediaLibrary.h
Expand Up @@ -13,6 +13,7 @@
#import "Label.h"
#import "ShowEpisode.h"

@class VLCMedia;
@interface VLCLMediaLibrary : NSObject {
NSManagedObjectContext *_managedObjectContext;
NSManagedObjectModel *_managedObjectModel;
Expand Down
14 changes: 7 additions & 7 deletions Sources/VLCSplashScreenView.m
Expand Up @@ -34,7 +34,7 @@ + (NSSet *)keyPathsForValuesAffectingMediaDiscovererArrayController
return [NSSet setWithObject:@"window.windowController.mediaDiscovererArrayController"];
}

- (NSArray *)setTvShowEpisodesSortDescriptors:(NSArray *)ignored
- (void)setTvShowEpisodesSortDescriptors:(NSArray *)ignored
{
}

Expand Down Expand Up @@ -76,14 +76,14 @@ - (NSArrayController *)moviesArrayController
DIRECTLY_RETURN_OBJECT_TO_JS([[[self window] windowController] moviesArrayController]);
}

- (NSArrayController *)orphanedTVShowEpisodeArrayController
- (NSArrayController *)tvShowsArrayController
{
DIRECTLY_RETURN_OBJECT_TO_JS([[[self window] windowController] orphanedTVShowEpisodeArrayController]);
DIRECTLY_RETURN_OBJECT_TO_JS([[[self window] windowController] tvShowsArrayController]);
}

- (NSArrayController *)tvShowsArrayController
- (NSArrayController *)tvShowEpisodesArrayController
{
DIRECTLY_RETURN_OBJECT_TO_JS([[[self window] windowController] tvShowsArrayController]);
DIRECTLY_RETURN_OBJECT_TO_JS([[[self window] windowController] tvShowEpisodesArrayController]);
}

- (NSArrayController *)labelsArrayController
Expand Down Expand Up @@ -216,12 +216,12 @@ - (void)setType:(NSString *)type forFile:(WebScriptObject *)webfile
{
FROM_JS();
File *file = [webfile valueForKey:@"backendObject"];
[file setValue:type forKey:@"type"];
if ([type isEqualToString:@"tvShowEpisode"]) {
[file setValue:type forKey:@"type"];
NSDictionary *dictionary = [VLCTitleDecrapifier tvShowEpisodeInfoFromString:file.title];
[[VLCLMediaLibrary sharedMediaLibrary] addTVShowEpisodeWithInfo:dictionary andFile:file];

}

RETURN_NOTHING_TO_JS();
}

Expand Down

0 comments on commit bca88b9

Please sign in to comment.