X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=macosx%2FChapterTitles.m;h=893c2dc22321d1cf89b7d8ba3bca3ca42d85e361;hb=240cf3308bf21be4d1918a71a5510d07e7d6d85b;hp=26f71913d0cf662d1c22b9ad61cb955a8b7d19e4;hpb=c7d8a4c93c59999481f91333ebdebde830575dbf;p=handbrake-jp%2Fhandbrake-jp-git.git
diff --git a/macosx/ChapterTitles.m b/macosx/ChapterTitles.m
index 26f71913..893c2dc2 100644
--- a/macosx/ChapterTitles.m
+++ b/macosx/ChapterTitles.m
@@ -1,7 +1,7 @@
/* ChapterTitles.m $
This file is part of the HandBrake source code.
- Homepage: .
+ Homepage: .
It may be used under the terms of the GNU General Public License. */
#include "ChapterTitles.h"
@@ -23,6 +23,12 @@
{
int i;
NSString *chapterString;
+
+ fTitle = title;
+
+ if (!title)
+ return;
+
int count = hb_list_count( title->list_chapter );
for( i = 0; i < count; i++ )
@@ -38,7 +44,6 @@
}
}
- fTitle = title;
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
@@ -56,25 +61,28 @@
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn
- row:(int)rowIndex
+ row:(NSInteger)rowIndex
{
if(aTableColumn != nil && [[aTableColumn identifier] intValue] == 2)
{
- hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex );
-
- if( chapter != NULL )
+ if( fTitle )
{
- strncpy( chapter->title, [anObject UTF8String], 1023);
- chapter->title[1023] = '\0';
+ 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
+ row:(NSInteger)rowIndex
{
- NSString *cellEntry;
+ NSString *cellEntry = @"__DATA ERROR__";
if([[aTableColumn identifier] intValue] == 1)
{
@@ -82,18 +90,52 @@
}
else
{
- hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex );
-
- if( chapter != NULL )
- {
- cellEntry = [NSString stringWithUTF8String:chapter->title];
- }
- else
+ if( fTitle )
{
- cellEntry = @"__DATA ERROR__";
+ hb_chapter_t *chapter = hb_list_item( fTitle->list_chapter, rowIndex );
+
+ if( chapter != NULL )
+ {
+ cellEntry = [NSString stringWithUTF8String:chapter->title];
+ }
}
}
-
+
return cellEntry;
}
+
+/* Method to edit the next chapter when the user presses Return. We have to use
+a timer to avoid interfering with the chain of events that handles the edit. */
+- (void)controlTextDidEndEditing: (NSNotification *) notification
+{
+ NSTableView *chapterTable = [notification object];
+ NSInteger column = [chapterTable editedColumn];
+ NSInteger row = [chapterTable editedRow];
+ NSInteger textMovement;
+
+ // Edit the cell in the next row, same column
+ row++;
+ textMovement = [[[notification userInfo] objectForKey:@"NSTextMovement"] integerValue];
+ if( textMovement == NSReturnTextMovement && row < [chapterTable numberOfRows] )
+ {
+ NSArray *info = [NSArray arrayWithObjects:chapterTable,
+ [NSNumber numberWithInteger:column], [NSNumber numberWithInteger:row], nil];
+ /* The delay is unimportant; editNextRow: won't be called until the responder
+ chain finishes because the event loop containing the timer is on this thread */
+ [self performSelector:@selector(editNextRow:) withObject:info afterDelay:0.0];
+ }
+}
+
+- (void)editNextRow: (id) objects
+{
+ NSTableView *chapterTable = [objects objectAtIndex:0];
+ NSInteger column = [[objects objectAtIndex:1] integerValue];
+ NSInteger row = [[objects objectAtIndex:2] integerValue];
+
+ if( row >= 0 && row < [chapterTable numberOfRows] )
+ {
+ [chapterTable selectRow:row byExtendingSelection:NO];
+ [chapterTable editColumn:column row:row withEvent:nil select:YES];
+ }
+}
@end