OSDN Git Service

Don't drop subtitles when crossing PTS discontinuities by using buffer sequence numbe...
[handbrake-jp/handbrake-jp-git.git] / macosx / ChapterTitles.m
1 /*  ChapterTitles.m $
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.m0k.org/>.
5    It may be used under the terms of the GNU General Public License. */
6    
7 #include "ChapterTitles.h"
8 #include "hb.h"
9
10 @implementation ChapterTitles
11 - (id)init 
12 {
13     self = [super init];
14     if( self != nil )
15     {
16         fTitle = NULL;
17     }
18     
19     return self;
20 }
21
22 - (void)resetWithTitle:(hb_title_t *)title
23 {
24     int i;
25     NSString *chapterString;
26     int count = hb_list_count( title->list_chapter );
27
28     for( i = 0; i < count; i++ )
29     {
30         hb_chapter_t *chapter = hb_list_item( title->list_chapter, i );
31         
32         if( chapter != NULL && chapter->title[0] == '\0' )
33         {
34             chapterString = [NSString stringWithFormat:@"Chapter %2d",(i+1)];
35     
36             strncpy( chapter->title, [chapterString UTF8String], 1023);
37             chapter->title[1023] = '\0';
38         }
39     }
40     
41     fTitle = title;
42 }
43
44 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
45 {
46     if( fTitle == NULL )
47     {
48         return 0;
49     }
50     else
51     {
52         return hb_list_count( fTitle->list_chapter );
53     }
54 }
55
56 - (void)tableView:(NSTableView *)aTableView
57         setObjectValue:(id)anObject
58         forTableColumn:(NSTableColumn *)aTableColumn
59         row:(int)rowIndex
60 {
61     if(aTableColumn != nil && [[aTableColumn identifier] intValue] == 2)
62     {
63         hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex );
64         
65         if( chapter != NULL )
66         {
67             strncpy( chapter->title, [anObject UTF8String], 1023);
68             chapter->title[1023] = '\0';
69         }
70     }
71 }
72
73 - (id)tableView:(NSTableView *)aTableView
74       objectValueForTableColumn:(NSTableColumn *)aTableColumn
75       row:(int)rowIndex
76 {
77     NSString *cellEntry;
78
79     if([[aTableColumn identifier] intValue] == 1)
80     {
81         cellEntry = [NSString stringWithFormat:@"%d",rowIndex+1];
82     }
83     else
84     {
85         hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex );
86         
87         if( chapter != NULL )
88         {
89             cellEntry = [NSString stringWithUTF8String:chapter->title];
90         }
91         else
92         {
93             cellEntry = @"__DATA ERROR__";
94         }
95     }
96     
97     return cellEntry;
98 }
99 @end