1 /*****************************************************************************
2 * info.m: MacOS X info panel
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: info.m,v 1.6 2003/05/25 17:27:13 massiot Exp $
7 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
27 /*****************************************************************************
28 * VLCInfo implementation
29 *****************************************************************************/
30 @implementation VLCInfo
34 [o_window setExcludedFromWindowsMenu: YES];
43 o_strings = [[NSMutableDictionary alloc] init];
55 - (IBAction)toggleInfoPanel:(id)sender
57 if( [o_window isVisible] )
59 [o_window orderOut: sender];
63 [o_window orderFront: sender];
68 - (IBAction)showCategory:(id)sender
70 NSString * o_title = [o_selector titleOfSelectedItem];
71 [o_view setString: [o_strings objectForKey: o_title]];
72 [o_view setNeedsDisplay: YES];
77 NSString *o_selectedPane;
79 if( ![o_window isVisible] )
84 o_selectedPane = [[o_selector selectedItem] title];
86 intf_thread_t * p_intf = [NSApp getIntf];
87 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
90 if( p_playlist == NULL )
95 vlc_mutex_lock( &p_playlist->object_lock );
97 if ( p_playlist->p_input == NULL )
99 vlc_mutex_unlock( &p_playlist->object_lock );
100 vlc_object_release( p_playlist );
104 [o_strings removeAllObjects];
105 [o_selector removeAllItems];
107 vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
108 input_info_category_t * p_category = p_playlist->p_input->stream.p_info;
112 [self createInfoView: p_category];
113 p_category = p_category->p_next;
116 vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
117 vlc_mutex_unlock( &p_playlist->object_lock );
118 vlc_object_release( p_playlist );
120 int i_select = [o_selector indexOfItemWithTitle:o_selectedPane];
125 [o_selector selectItemAtIndex: i_select ];
126 [self showCategory: o_selector];
129 - (void)createInfoView:(input_info_category_t *)p_category
132 NSMutableString * o_content;
133 input_info_t * p_info;
136 o_title = [NSString stringWithUTF8String: p_category->psz_name];
137 [o_selector addItemWithTitle: o_title];
139 /* Create empty content string */
140 o_content = [NSMutableString string];
143 p_info = p_category->p_info;
147 [o_content appendFormat: @"%@: %@\n\n", [NSApp localizedString: p_info->psz_name],
148 [NSApp localizedString: p_info->psz_value]];
149 p_info = p_info->p_next;
152 [o_strings setObject: o_content forKey: o_title];
157 @implementation VLCInfo (NSMenuValidation)
159 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
161 BOOL bEnabled = TRUE;
163 intf_thread_t * p_intf = [NSApp getIntf];
164 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
167 if( p_playlist != NULL )
169 vlc_mutex_lock( &p_playlist->object_lock );
172 if( [[o_mi title] isEqualToString: _NS("Info")] )
174 if( p_playlist == NULL || p_playlist->p_input == NULL )
180 if( p_playlist != NULL )
182 vlc_mutex_unlock( &p_playlist->object_lock );
183 vlc_object_release( p_playlist );