1 /*****************************************************************************
2 * fileinfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001,2003 VideoLAN
5 * $Id: fileinfo.cpp,v 1.21 2003/12/22 02:24:52 sam Exp $
7 * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
30 #include "wxwindows.h"
31 #include <wx/treectrl.h>
33 /*****************************************************************************
35 *****************************************************************************/
37 /* IDs for the controls and the menu commands */
43 BEGIN_EVENT_TABLE(FileInfo, wxFrame)
45 EVT_BUTTON(wxID_OK, FileInfo::OnClose)
47 /* Hide the window when the user closes the window */
48 EVT_CLOSE(FileInfo::OnClose)
52 /*****************************************************************************
54 *****************************************************************************/
55 FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ):
56 wxFrame( p_parent, -1, wxU(_("Stream and media info")), wxDefaultPosition,
57 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
61 SetIcon( *p_intf->p_sys->p_icon );
62 SetAutoLayout( TRUE );
64 /* Create a panel to put everything in */
65 wxPanel *panel = new wxPanel( this, -1 );
66 panel->SetAutoLayout( TRUE );
69 new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize( 350, 350 ),
70 wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
72 fileinfo_root_label = wxT("");
74 /* Place everything in sizers */
75 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
76 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
77 panel_sizer->Add( fileinfo_tree, 1, wxEXPAND | wxALL, 5 );
78 panel_sizer->Layout();
79 panel->SetSizerAndFit( panel_sizer );
80 main_sizer->Add( panel, 1, wxEXPAND, 0 );
82 SetSizerAndFit( main_sizer );
87 void FileInfo::UpdateFileInfo()
89 input_thread_t *p_input = p_intf->p_sys->p_input;
91 if( !p_input || p_input->b_dead || !p_input->psz_name )
95 fileinfo_root_label = wxT("");
96 fileinfo_tree->DeleteChildren( fileinfo_root );
103 /* On linux, the first argument of wxTreeCtrl::AddRoot() can be
104 * retrieved with the GetItemText() method, but it doesn't work on
105 * Windows when the wxTR_HIDE_ROOT style is set. That's why we need to
106 * use the fileinfo_root_label variable... */
107 fileinfo_root = fileinfo_tree->AddRoot( wxU(p_input->psz_name) );
108 fileinfo_root_label = wxU(p_input->psz_name);
110 else if( fileinfo_root_label == wxU(p_input->psz_name) )
115 /* We rebuild the tree from scratch */
116 fileinfo_tree->DeleteChildren( fileinfo_root );
117 fileinfo_root_label = wxU(p_input->psz_name);
119 vlc_mutex_lock( &p_input->stream.stream_lock );
121 input_info_category_t *p_cat = p_input->stream.p_info;
125 wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
126 wxU(p_cat->psz_name) );
127 input_info_t *p_info = p_cat->p_info;
130 fileinfo_tree->AppendItem( cat, (wxString)wxU(p_info->psz_name) +
131 wxT(": ") + wxU(p_info->psz_value) );
132 p_info = p_info->p_next;
134 p_cat = p_cat->p_next;
135 fileinfo_tree->Expand( cat );
138 vlc_mutex_unlock( &p_input->stream.stream_lock );
143 FileInfo::~FileInfo()
147 void FileInfo::OnClose( wxCommandEvent& event )