*Fixed a spelling mistake and added some button-shortcuts
[vlc.git] / modules / gui / macosx / playlistinfo.m
1 /*****************************************************************************
2  * playlistinfo.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2004 VideoLAN
5  * $Id: playlistinfo.m 7015 2004-03-08 15:22:58Z bigben $
6  *
7  * Authors: Benjmaib Pracht <bigben at videolan dot org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #include "intf.h"
29 #include "playlistinfo.h"
30 #include "playlist.h"
31
32 /*****************************************************************************
33  * VLCPlaylistInfo Implementation
34  *****************************************************************************/
35
36 @implementation VLCPlaylistInfo
37
38 - (void)awakeFromNib
39 {
40
41     [o_info_window setExcludedFromWindowsMenu: TRUE];
42     [o_tbv_info setOutlineTableColumn:0];
43     [o_tbv_info setDataSource: self];
44
45     [o_info_window setTitle: _NS("Properties")];
46     [o_uri_lbl setStringValue: _NS("URI")];
47     [o_title_lbl setStringValue: _NS("Title")];
48     [o_author_lbl setStringValue: _NS("Author")];
49     [o_btn_info_ok setTitle: _NS("OK")];
50     [o_btn_info_cancel setTitle: _NS("Cancel")];
51 }
52
53 - (IBAction)togglePlaylistInfoPanel:(id)sender
54 {
55     intf_thread_t * p_intf = [NSApp getIntf];
56     playlist_t * p_playlist;
57
58     if( [o_info_window isVisible] )
59     {
60         [o_info_window orderOut: sender];
61     }
62     else
63     {
64         p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
65                                           FIND_ANYWHERE );
66
67         if (p_playlist)
68         {
69             /*fill uri / title / author info */
70             int i_item = [o_vlc_playlist selectedPlaylistItem];
71             [o_uri_txt setStringValue:[NSString stringWithUTF8String: p_playlist->pp_items[i_item]->psz_uri]];
72             [o_title_txt setStringValue:[NSString stringWithUTF8String: p_playlist->pp_items[i_item]->psz_name]];
73             [o_author_txt setStringValue:[NSString stringWithUTF8String: playlist_GetInfo(p_playlist, i_item ,_("General"),_("Author") )]];
74
75             /*fill info outline*/
76 //            [o_tbv_info 
77             vlc_object_release ( p_playlist );
78         }
79         [o_info_window makeKeyAndOrderFront: sender];
80     }
81 }
82
83 - (IBAction)infoCancel:(id)sender
84 {
85     [self togglePlaylistInfoPanel:self];
86 }
87
88
89 - (IBAction)infoOk:(id)sender
90 {
91     int i_item = [o_vlc_playlist selectedPlaylistItem];
92     intf_thread_t * p_intf = [NSApp getIntf];
93     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
94                                           FIND_ANYWHERE );
95     vlc_value_t val;
96
97     if (p_playlist)                       
98     {
99         vlc_mutex_lock(&p_playlist->pp_items[i_item]->lock);
100         
101         p_playlist->pp_items[i_item]->psz_uri = strdup([[o_uri_txt stringValue] cString]);
102         p_playlist->pp_items[i_item]->psz_name = strdup([[o_title_txt stringValue] cString]);
103         playlist_ItemAddInfo(p_playlist->pp_items[i_item],_("General"),_("Author"), [[o_author_txt stringValue] cString]);
104  
105         vlc_mutex_unlock(&p_playlist->pp_items[i_item]->lock);
106         val.b_bool = VLC_TRUE;
107         var_Set( p_playlist,"int-change",val );
108         vlc_object_release ( p_playlist );
109     } 
110     [self togglePlaylistInfoPanel:self];
111     
112 }   
113
114 @end
115