diff options
author | dynaflash <[email protected]> | 2007-04-25 17:24:58 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-04-25 17:24:58 +0000 |
commit | cdcdac58032b929a7edea0459047a9cb56da767d (patch) | |
tree | c0aad497331fe94fb7f6b13b9600283f9350cf59 /macosx/ChapterTitles.m | |
parent | e1f55561971a286170d003d20eff51c9a5563f43 (diff) |
Fix Previous Bad commit for Cyanders Chapter Markers
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@548 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/ChapterTitles.m')
-rw-r--r-- | macosx/ChapterTitles.m | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/macosx/ChapterTitles.m b/macosx/ChapterTitles.m new file mode 100644 index 000000000..26f71913d --- /dev/null +++ b/macosx/ChapterTitles.m @@ -0,0 +1,99 @@ +/* ChapterTitles.m $ + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.m0k.org/>. + It may be used under the terms of the GNU General Public License. */ + +#include "ChapterTitles.h" +#include "hb.h" + +@implementation ChapterTitles +- (id)init +{ + self = [super init]; + if( self != nil ) + { + fTitle = NULL; + } + + return self; +} + +- (void)resetWithTitle:(hb_title_t *)title +{ + int i; + NSString *chapterString; + int count = hb_list_count( title->list_chapter ); + + for( i = 0; i < count; i++ ) + { + hb_chapter_t *chapter = hb_list_item( title->list_chapter, i ); + + if( chapter != NULL && chapter->title[0] == '\0' ) + { + chapterString = [NSString stringWithFormat:@"Chapter %2d",(i+1)]; + + strncpy( chapter->title, [chapterString UTF8String], 1023); + chapter->title[1023] = '\0'; + } + } + + fTitle = title; +} + +- (int)numberOfRowsInTableView:(NSTableView *)aTableView +{ + if( fTitle == NULL ) + { + return 0; + } + else + { + return hb_list_count( fTitle->list_chapter ); + } +} + +- (void)tableView:(NSTableView *)aTableView + setObjectValue:(id)anObject + forTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex +{ + if(aTableColumn != nil && [[aTableColumn identifier] intValue] == 2) + { + hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); + + if( chapter != NULL ) + { + strncpy( chapter->title, [anObject UTF8String], 1023); + chapter->title[1023] = '\0'; + } + } +} + +- (id)tableView:(NSTableView *)aTableView + objectValueForTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex +{ + NSString *cellEntry; + + if([[aTableColumn identifier] intValue] == 1) + { + cellEntry = [NSString stringWithFormat:@"%d",rowIndex+1]; + } + else + { + hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex ); + + if( chapter != NULL ) + { + cellEntry = [NSString stringWithUTF8String:chapter->title]; + } + else + { + cellEntry = @"__DATA ERROR__"; + } + } + + return cellEntry; +} +@end |