1 /*****************************************************************************
2 * fileinfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/fileinfo.hpp"
25 #include "dialogs/infopanels.hpp"
27 /*****************************************************************************
29 *****************************************************************************/
31 static int ItemChanged( vlc_object_t *, const char *,
32 vlc_value_t, vlc_value_t, void * );
35 /* IDs for the controls and the menu commands */
41 BEGIN_EVENT_TABLE(FileInfo, wxFrame)
43 EVT_BUTTON(wxID_CLOSE, FileInfo::OnButtonClose)
45 /* Hide the window when the user closes the window */
46 EVT_CLOSE(FileInfo::OnClose)
50 /*****************************************************************************
52 *****************************************************************************/
53 FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ):
54 wxFrame( p_parent, -1, wxU(_("Stream and Media Info")), wxDefaultPosition,
55 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
58 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
61 b_stats = config_GetInt(p_intf, "stats");
63 SetIcon( *p_intf->p_sys->p_icon );
64 SetAutoLayout( TRUE );
66 /* Create a panel to put everything in */
67 wxPanel *panel = new wxPanel( this, -1 );
68 panel->SetAutoLayout( TRUE );
70 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
71 panel_sizer = new wxBoxSizer( wxVERTICAL );
73 wxNotebook *notebook = new wxNotebook( panel, -1 );
74 #if (!wxCHECK_VERSION(2,5,2))
75 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
77 item_info = new MetaDataPanel( p_intf, notebook, false );
78 advanced_info = new AdvancedInfoPanel( p_intf, notebook );
80 stats_info = new InputStatsInfoPanel( p_intf, notebook );
82 notebook->AddPage( item_info, wxU(_("General") ), true );
83 notebook->AddPage( advanced_info, wxU(_("Advanced information") ), false );
85 notebook->AddPage( stats_info, wxU(_("Statistics") ), false );
87 #if (!wxCHECK_VERSION(2,5,2))
88 panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
90 panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
93 panel_sizer->Add( new wxButton( panel, wxID_CLOSE, wxU(_("&Close")) ) ,
94 0, wxALL|wxALIGN_RIGHT, 5 );
96 panel_sizer->Layout();
97 panel->SetSizerAndFit( panel_sizer );
98 main_sizer->Add( panel, 1, wxGROW, 0 );
100 SetSizerAndFit( main_sizer );
104 var_AddCallback( p_playlist, "item-change", ItemChanged, this );
105 vlc_object_release( p_playlist );
109 b_need_update = true;
113 void FileInfo::Update()
115 if( mdate() - last_update < 400000L ) return;
116 last_update = mdate();
118 playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
121 if( !p_playlist ) return;
123 input_thread_t *p_input = p_playlist->p_input ;
125 if( !p_input || p_input->b_dead || !input_GetItem(p_input)->psz_name )
128 advanced_info->Clear();
131 vlc_object_release( p_playlist );
135 vlc_object_yield( p_input );
136 vlc_mutex_lock( &input_GetItem(p_input)->lock );
137 if( b_need_update == true )
139 vlc_mutex_unlock( &input_GetItem(p_input)->lock );
140 item_info->Update( input_GetItem(p_input) );
141 vlc_mutex_lock( &input_GetItem(p_input)->lock );
142 advanced_info->Update( input_GetItem(p_input) );
145 stats_info->Update( input_GetItem(p_input) );
146 vlc_mutex_unlock( &input_GetItem(p_input)->lock );
148 vlc_object_release(p_input);
149 vlc_object_release( p_playlist );
150 b_need_update = false;
151 panel_sizer->Layout();
156 FileInfo::~FileInfo()
160 void FileInfo::OnButtonClose( wxCommandEvent& event )
166 void FileInfo::OnClose( wxCloseEvent& WXUNUSED(event) )
171 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
172 vlc_value_t oldval, vlc_value_t newval, void *param )
174 FileInfo *p_fileinfo = (FileInfo *)param;
175 p_fileinfo->b_need_update = true;