00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vlc/vlc.h>
00028 #include <vlc/intf.h>
00029
00030 #include "wxwidgets.h"
00031
00032
00033
00034
00035
00036 static int ItemChanged( vlc_object_t *, const char *,
00037 vlc_value_t, vlc_value_t, void * );
00038
00039
00040
00041 enum
00042 {
00043 Close_Event
00044 };
00045
00046 BEGIN_EVENT_TABLE(FileInfo, wxFrame)
00047
00048 EVT_BUTTON(wxID_OK, FileInfo::OnButtonClose)
00049
00050
00051 EVT_CLOSE(FileInfo::OnClose)
00052
00053 END_EVENT_TABLE()
00054
00055
00056
00057
00058 FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ):
00059 wxFrame( p_parent, -1, wxU(_("Stream and media info")), wxDefaultPosition,
00060 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
00061 {
00062 playlist_t *p_playlist;
00063
00064
00065 p_intf = _p_intf;
00066 SetIcon( *p_intf->p_sys->p_icon );
00067 SetAutoLayout( TRUE );
00068
00069
00070 wxPanel *panel = new wxPanel( this, -1 );
00071 panel->SetAutoLayout( TRUE );
00072
00073 fileinfo_tree =
00074 new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize( 350, 350 ),
00075 wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
00076
00077 fileinfo_root_label = wxT("");
00078
00079
00080 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
00081 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
00082 panel_sizer->Add( fileinfo_tree, 1, wxEXPAND | wxALL, 5 );
00083 panel_sizer->Layout();
00084 panel->SetSizerAndFit( panel_sizer );
00085 main_sizer->Add( panel, 1, wxEXPAND, 0 );
00086 main_sizer->Layout();
00087 SetSizerAndFit( main_sizer );
00088
00089 p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00090 FIND_ANYWHERE );
00091
00092 if( p_playlist )
00093 {
00094 var_AddCallback( p_playlist, "item-change", ItemChanged, this );
00095 vlc_object_release( p_playlist );
00096 }
00097
00098 b_need_update = VLC_TRUE;
00099 UpdateFileInfo();
00100 }
00101
00102 void FileInfo::UpdateFileInfo()
00103 {
00104 input_thread_t *p_input =
00105 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
00106 FIND_ANYWHERE );
00107
00108 if( !p_input || p_input->b_dead || !p_input->input.p_item->psz_name )
00109 {
00110 if( fileinfo_root )
00111 {
00112 fileinfo_root_label = wxT("");
00113 fileinfo_tree->DeleteChildren( fileinfo_root );
00114 }
00115 if (p_input)
00116 {
00117 vlc_object_release(p_input);
00118 }
00119 return;
00120 }
00121
00122 if( !fileinfo_root )
00123 {
00124
00125
00126
00127
00128 fileinfo_root =
00129 fileinfo_tree->AddRoot( wxL2U(p_input->input.p_item->psz_name) );
00130 fileinfo_root_label = wxL2U(p_input->input.p_item->psz_name);
00131 }
00132 else if( fileinfo_root_label == wxL2U(p_input->input.p_item->psz_name) &&
00133 b_need_update == VLC_FALSE )
00134 {
00135 vlc_object_release(p_input);
00136 return;
00137 }
00138
00139
00140 fileinfo_tree->DeleteChildren( fileinfo_root );
00141 fileinfo_root_label = wxL2U(p_input->input.p_item->psz_name);
00142
00143 vlc_mutex_lock( &p_input->input.p_item->lock );
00144 for( int i = 0; i < p_input->input.p_item->i_categories; i++ )
00145 {
00146 info_category_t *p_cat = p_input->input.p_item->pp_categories[i];
00147
00148 wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
00149 wxU(p_cat->psz_name) );
00150 for( int j = 0; j < p_cat->i_infos; j++ )
00151 {
00152 info_t *p_info = p_cat->pp_infos[j];
00153
00154 if( p_info->psz_value[0] != 0 )
00155
00156 {
00157 fileinfo_tree->AppendItem( cat, (wxString)wxU(p_info->psz_name)
00158 + wxT(": ") + wxU(p_info->psz_value) );
00159 }
00160 }
00161 fileinfo_tree->Expand( cat );
00162 }
00163 vlc_mutex_unlock( &p_input->input.p_item->lock );
00164
00165 b_need_update = VLC_FALSE;
00166
00167 vlc_object_release(p_input);
00168 return;
00169 }
00170
00171 FileInfo::~FileInfo()
00172 {
00173 }
00174
00175 void FileInfo::OnButtonClose( wxCommandEvent& event )
00176 {
00177 wxCloseEvent cevent;
00178 OnClose(cevent);
00179 }
00180
00181 void FileInfo::OnClose( wxCloseEvent& WXUNUSED(event) )
00182 {
00183 Hide();
00184 }
00185
00186 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
00187 vlc_value_t oldval, vlc_value_t newval, void *param )
00188 {
00189 FileInfo *p_fileinfo = (FileInfo *)param;
00190 p_fileinfo->b_need_update = VLC_TRUE;
00191 return VLC_SUCCESS;
00192 }