From 484e5279b3596f4ee28fd7a5f6899c9ca3c4ad54 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sat, 20 Aug 2011 04:51:51 +0200 Subject: [PATCH] Set title for movie panel --- Medianno/MADocWindow.h | 1 + Medianno/MADocWindow.mm | 16 ++++++++++++---- Medianno/MAMovieWindow.h | 2 +- Medianno/MAMovieWindow.m | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Medianno/MADocWindow.h b/Medianno/MADocWindow.h index 82fbe16..1e5af8b 100644 --- a/Medianno/MADocWindow.h +++ b/Medianno/MADocWindow.h @@ -20,6 +20,7 @@ IBOutlet NSView * textExportAccessoryView; IBOutlet MAMovieWindow * moviePanel; QTMovie * currentMovie; + NSString * currentMovieTitle; QTTime lastMovieTime; } diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index 6b598d8..43a2d57 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -29,6 +29,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; self = [super initWithWindow:window]; exportAnnotations = YES; + currentMovieTitle = @""; return self; } @@ -40,6 +41,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; [annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]]; [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateMovieTime:) userInfo:nil repeats:YES]; [mediaController addObserver:self forKeyPath:@"selection.media" options:0 context:&kMADocWindowObserver]; + [mediaController addObserver:self forKeyPath:@"selection.name" options:0 context:&kMADocWindowObserver]; } - (MAMovieWindow *)moviePanel @@ -50,7 +52,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; - (void)moviePanelDidAppear { [movieView setMovie:nil]; - if (![[self moviePanel] shouldDisplayMovie:currentMovie]) + if (![[self moviePanel] shouldDisplayMovie:currentMovie withTitle:currentMovieTitle]) [movieView setMovie:currentMovie]; } @@ -61,7 +63,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; - (void)moviePanelDidClose { - [[self moviePanel] shouldDisplayMovie:nil]; + [[self moviePanel] shouldDisplayMovie:nil withTitle:@""]; [movieView setMovie:currentMovie]; } @@ -77,8 +79,14 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; // // Current movie changed // - MAMedia * currentMedia = [mediaController selection]; - currentMovie = [[QTMovie alloc] initWithFile:[currentMedia valueForKey:@"media"] error:nil]; + if ([[mediaController selectionIndexes] count] > 0) { + MAMedia * currentMedia = [[mediaController selectedObjects] objectAtIndex:0]; + currentMovie = [[QTMovie alloc] initWithFile:[currentMedia media] error:nil]; + currentMovieTitle = [currentMedia name]; + } else { + currentMovie = nil; + currentMovieTitle = @""; + } } [self moviePanelDidAppear]; } diff --git a/Medianno/MAMovieWindow.h b/Medianno/MAMovieWindow.h index d2c088d..966569e 100644 --- a/Medianno/MAMovieWindow.h +++ b/Medianno/MAMovieWindow.h @@ -13,7 +13,7 @@ IBOutlet QTMovieView * panelMovieView; } -- (BOOL)shouldDisplayMovie:(QTMovie *)movie; +- (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title; - (IBAction)toggleWindow:(id)sender; @end diff --git a/Medianno/MAMovieWindow.m b/Medianno/MAMovieWindow.m index abd7dae..26dfc09 100644 --- a/Medianno/MAMovieWindow.m +++ b/Medianno/MAMovieWindow.m @@ -23,13 +23,15 @@ [super windowDidLoad]; } -- (BOOL)shouldDisplayMovie:(QTMovie *)movie +- (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title { if ([self isWindowLoaded] && [[self window] isVisible]) { [panelMovieView setMovie:movie]; + [[self window] setTitle:title]; return YES; } else { [panelMovieView setMovie:nil]; + [[self window] setTitle:@""]; return NO; } }