]> git.sesse.net Git - vlc/blob - modules/gui/macosx/SideBarItem.m
macosx: implemented the sidebar completely to support switching between the playlist...
[vlc] / modules / gui / macosx / SideBarItem.m
1 //
2 //  SideBarItem.m
3 //  PXSourceList
4 //
5 //  Created by Alex Rozanski on 08/01/2010.
6 //  Copyright 2010 Alex Rozanski http://perspx.com
7 //
8 //  GC-enabled code revised by Stefan Vogt http://byteproject.net
9 //
10 //  Adapted to VLC media player by Felix Paul Kühne
11
12
13 #import "SideBarItem.h"
14
15
16 @implementation SideBarItem
17
18 @synthesize title;
19 @synthesize untranslatedTitle;
20 @synthesize identifier;
21 @synthesize icon;
22 @synthesize badgeValue;
23 @synthesize children;
24 @synthesize sdtype;
25
26 #pragma mark -
27 #pragma mark Init/Dealloc/Finalize
28
29 - (id)init
30 {
31         if(self=[super init])
32         {
33                 badgeValue = -1;        //We don't want a badge value by default
34         sdtype = -1; //no sd type set
35         }
36
37         return self;
38 }
39
40
41 + (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier
42 {
43         SideBarItem *item = [SideBarItem itemWithTitle:aTitle identifier:anIdentifier icon:nil];
44
45         return item;
46 }
47
48
49 + (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier icon:(NSImage*)anIcon
50 {
51         SideBarItem *item = [[[SideBarItem alloc] init] autorelease];
52
53         [item setTitle:aTitle];
54         [item setIdentifier:anIdentifier];
55         [item setIcon:anIcon];
56
57         return item;
58 }
59
60 - (void)dealloc
61 {
62         [title release];
63         [identifier release];
64         [icon release];
65         [children release];
66
67         [super dealloc];
68 }
69
70 - (void)finalize
71 {
72         title = nil;
73         identifier = nil;
74         icon = nil;
75         children = nil;
76
77         [super finalize];
78 }
79
80 #pragma mark -
81 #pragma mark Custom Accessors
82
83 - (BOOL)hasBadge
84 {
85         return badgeValue!=-1;
86 }
87
88 - (BOOL)hasChildren
89 {
90         return [children count]>0;
91 }
92
93 - (BOOL)hasIcon
94 {
95         return icon!=nil;
96 }
97
98 @end