1/*
2   Project: MPDCon
3
4   Copyright (C) 2012
5
6   Author: sebastian Reitenbach
7
8   Created: 2012-09-02
9
10   Lyrics Inspector
11
12   This application is free software; you can redistribute it and/or
13   modify it under the terms of the GNU General Public
14   License as published by the Free Software Foundation; either
15   version 2 of the License, or (at your option) any later version.
16
17   This application is distributed in the hope that it will be useful,
18   but WITHOUT ANY WARRANTY; without even the implied warranty of
19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20   Library General Public License for more details.
21
22   You should have received a copy of the GNU General Public
23   License along with this library; if not, write to the Free
24   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
25*/
26
27#include <AppKit/AppKit.h>
28#include "SongInspector.h"
29#include "PlaylistItem.h"
30
31@implementation SongInspector
32+ (id) sharedSongInspector
33{
34  static SongInspector *_sharedSongInspector = nil;
35
36  if (! _sharedSongInspector) {
37      _sharedSongInspector = [[SongInspector allocWithZone: [self zone]] init];
38  }
39
40  return _sharedSongInspector;
41}
42
43- (id) init
44{
45  if ((self = [self initWithWindowNibName: @"SongInspector"]) != nil)
46    {
47      [self setWindowFrameAutosaveName: @"SongInspector"];
48      mpdController = [MPDController sharedMPDController];
49    }
50  return self;
51}
52
53/* GUI methods */
54- (void) awakeFromNib
55{
56  NSNotificationCenter *defCenter;
57  defCenter = [NSNotificationCenter defaultCenter];
58  [defCenter addObserver: self
59                selector: @selector(songChanged:)
60                    name: SongChangedNotification
61                  object: nil];
62
63  [self updateSongInfo];
64}
65
66/* the delegate methods */
67- (void) songChanged:(NSNotification *)aNotif
68{
69  [self updateSongInfo];
70}
71
72- (void) updateSongInfo
73{
74  PlaylistItem *currentSong;
75
76  currentSong = [mpdController getCurrentSong];
77
78  [artist setStringValue:[currentSong getArtist]];
79  [title setStringValue:[currentSong getTitle]];
80  [album setStringValue:[currentSong getAlbum]];
81  [genre setStringValue:[currentSong getGenre]];
82  [track setStringValue:[currentSong getTrackNr]];
83  [filename setStringValue:[currentSong getPath]];
84  [date setStringValue:[currentSong getDate]];
85  [composer setStringValue:[currentSong getComposer]];
86  [performer setStringValue:[currentSong getPerformer]];
87  [disc setStringValue:[currentSong getDisc]];
88  [comment setStringValue:[currentSong getComment]];
89}
90
91@end
92