1 /*****************************************************************************
2 * fileinfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: fileinfo.cpp,v 1.10 2003/04/21 16:55:53 anil 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 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
34 #ifdef WIN32 /* mingw32 hack */
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
42 #include <wx/wxprec.h>
44 #include <wx/treectrl.h>
48 #if defined MODULE_NAME_IS_skins
49 # include "../skins/src/skin_common.h"
50 # include "../skins/src/wxdialogs.h"
52 # include "wxwindows.h"
56 /*****************************************************************************
58 *****************************************************************************/
60 /* IDs for the controls and the menu commands */
66 BEGIN_EVENT_TABLE(FileInfo, wxFrame)
68 EVT_BUTTON(wxID_OK, FileInfo::OnClose)
70 /* Hide the window when the user closes the window */
71 EVT_CLOSE(FileInfo::OnClose)
75 /*****************************************************************************
77 *****************************************************************************/
78 FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
79 wxFrame( _p_main_interface, -1, "FileInfo", wxDefaultPosition,
80 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
84 SetIcon( *p_intf->p_sys->p_icon );
85 SetAutoLayout( TRUE );
87 /* Create a panel to put everything in */
88 wxPanel *panel = new wxPanel( this, -1 );
89 panel->SetAutoLayout( TRUE );
92 new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize( 350, 350 ),
93 wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
95 fileinfo_root_label = "";
97 /* Create the OK button */
98 wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
99 ok_button->SetDefault();
101 /* Place everything in sizers */
102 wxBoxSizer *ok_button_sizer = new wxBoxSizer( wxHORIZONTAL );
103 ok_button_sizer->Add( ok_button, 0, wxALL, 5 );
104 ok_button_sizer->Layout();
105 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
106 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
107 panel_sizer->Add( fileinfo_tree, 1, wxEXPAND | wxALL, 5 );
108 panel_sizer->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
109 panel_sizer->Layout();
110 panel->SetSizerAndFit( panel_sizer );
111 main_sizer->Add( panel, 1, wxEXPAND, 0 );
112 main_sizer->Layout();
113 SetSizerAndFit( main_sizer );
118 void FileInfo::UpdateFileInfo()
120 input_thread_t *p_input = p_intf->p_sys->p_input;
122 if( !p_input || p_input->b_dead )
126 fileinfo_tree->SetItemText ( fileinfo_root , "");
127 fileinfo_root_label = "";
128 fileinfo_tree->DeleteChildren ( fileinfo_root );
133 wxString inputinfo = p_input->psz_name;
137 fileinfo_root = fileinfo_tree->AddRoot( p_input->psz_name );
138 fileinfo_root_label = p_input->psz_name;
140 else if( fileinfo_root_label == inputinfo )
145 fileinfo_tree->DeleteChildren( fileinfo_root );
147 vlc_mutex_lock( &p_input->stream.stream_lock );
149 fileinfo_tree->SetItemText( fileinfo_root , p_input->psz_name );
150 fileinfo_root_label = p_input->psz_name;
152 input_info_category_t *p_cat = p_input->stream.p_info;
156 wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
158 input_info_t *p_info = p_cat->p_info;
161 fileinfo_tree->AppendItem( cat, wxString(p_info->psz_name) + ": "
162 + p_info->psz_value );
163 p_info = p_info->p_next;
165 p_cat = p_cat->p_next;
166 fileinfo_tree->Expand( cat );
169 vlc_mutex_unlock( &p_input->stream.stream_lock );
174 FileInfo::~FileInfo()
178 void FileInfo::OnClose( wxCommandEvent& event )