1 /*****************************************************************************
2 * info.m: MacOS X info panel
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: info.m,v 1.7 2003/09/20 13:46:00 hartman 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 input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
90 if ( p_input == NULL )
95 [o_strings removeAllObjects];
96 [o_selector removeAllItems];
98 vlc_mutex_lock( &p_input->stream.stream_lock );
99 input_info_category_t * p_category = p_input->stream.p_info;
103 [self createInfoView: p_category];
104 p_category = p_category->p_next;
107 vlc_mutex_unlock( &p_input->stream.stream_lock );
108 vlc_object_release( p_input );
110 int i_select = [o_selector indexOfItemWithTitle:o_selectedPane];
115 [o_selector selectItemAtIndex: i_select ];
116 [self showCategory: o_selector];
119 - (void)createInfoView:(input_info_category_t *)p_category
122 NSMutableString * o_content;
123 input_info_t * p_info;
126 o_title = [NSString stringWithUTF8String: p_category->psz_name];
127 [o_selector addItemWithTitle: o_title];
129 /* Create empty content string */
130 o_content = [NSMutableString string];
133 p_info = p_category->p_info;
137 [o_content appendFormat: @"%@: %@\n\n", [NSApp localizedString: p_info->psz_name],
138 [NSApp localizedString: p_info->psz_value]];
139 p_info = p_info->p_next;
142 [o_strings setObject: o_content forKey: o_title];
147 @implementation VLCInfo (NSMenuValidation)
149 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
151 BOOL bEnabled = TRUE;
153 intf_thread_t * p_intf = [NSApp getIntf];
154 input_thread_t * p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
157 if( [[o_mi title] isEqualToString: _NS("Info")] )
159 if( p_input == NULL )
165 vlc_object_release( p_input );