/*****************************************************************************
* fileinfo.cpp : wxWindows plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: fileinfo.cpp,v 1.4 2003/03/13 22:45:32 sigmunau Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-#include <errno.h> /* ENOMEM */
-#include <string.h> /* strerror() */
-#include <stdio.h>
-
#include <vlc/vlc.h>
-
-#ifdef WIN32 /* mingw32 hack */
-#undef Yield
-#undef CreateDialog
-#endif
-
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-
-#include <wx/wxprec.h>
-#include <wx/wx.h>
-#include <wx/treectrl.h>
-
#include <vlc/intf.h>
#include "wxwindows.h"
/* Button events */
EVT_BUTTON(wxID_OK, FileInfo::OnClose)
- /* Special events : we don't want to destroy the window when the user
- * clicks on (X) */
+ /* Hide the window when the user closes the window */
EVT_CLOSE(FileInfo::OnClose)
+
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
-FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
- wxFrame( _p_main_interface, -1, "FileInfo", wxDefaultPosition,
+FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ):
+ wxFrame( p_parent, -1, wxU(_("Stream and media info")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
/* Initializations */
- intf_thread_t *p_intf = _p_intf;
- input_thread_t *p_input;
+ p_intf = _p_intf;
+ SetIcon( *p_intf->p_sys->p_icon );
+ SetAutoLayout( TRUE );
- wxTreeCtrl *tree = new wxTreeCtrl( this, -1, wxDefaultPosition, wxSize(350,350),
- wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT );
- p_input = p_intf->p_sys->p_input;
- /* Create the OK button */
- wxButton *ok_button = new wxButton( this, wxID_OK, _("OK") );
- ok_button->SetDefault();
+ /* Create a panel to put everything in */
+ wxPanel *panel = new wxPanel( this, -1 );
+ panel->SetAutoLayout( TRUE );
+
+ fileinfo_tree =
+ new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize( 350, 350 ),
+ wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
+
+ fileinfo_root_label = wxT("");
/* Place everything in sizers */
- wxBoxSizer *ok_button_sizer = new wxBoxSizer( wxHORIZONTAL );
- ok_button_sizer->Add( ok_button, 0, wxALL, 5 );
- ok_button_sizer->Layout();
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
- main_sizer->Add( tree, 1, wxGROW|wxEXPAND | wxALL, 5 );
- main_sizer->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
+ wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
+ panel_sizer->Add( fileinfo_tree, 1, wxEXPAND | wxALL, 5 );
+ panel_sizer->Layout();
+ panel->SetSizerAndFit( panel_sizer );
+ main_sizer->Add( panel, 1, wxEXPAND, 0 );
main_sizer->Layout();
- SetAutoLayout(TRUE);
SetSizerAndFit( main_sizer );
- if ( !p_intf->p_sys->p_input ) {
+
+ UpdateFileInfo();
+}
+
+void FileInfo::UpdateFileInfo()
+{
+ input_thread_t *p_input = p_intf->p_sys->p_input;
+
+ if( !p_input || p_input->b_dead || !p_input->psz_name )
+ {
+ if( fileinfo_root )
+ {
+ fileinfo_root_label = wxT("");
+ fileinfo_tree->DeleteChildren( fileinfo_root );
+ }
+ return;
+ }
+
+ if( !fileinfo_root )
+ {
+ /* On linux, the first argument of wxTreeCtrl::AddRoot() can be
+ * retrieved with the GetItemText() method, but it doesn't work on
+ * Windows when the wxTR_HIDE_ROOT style is set. That's why we need to
+ * use the fileinfo_root_label variable... */
+ fileinfo_root = fileinfo_tree->AddRoot( wxL2U(p_input->psz_name) );
+ fileinfo_root_label = wxL2U(p_input->psz_name);
+ }
+ else if( fileinfo_root_label == wxL2U(p_input->psz_name) )
+ {
return;
}
- vlc_mutex_lock( &p_input->stream.stream_lock );
- wxTreeItemId root = tree->AddRoot( p_input->psz_name );
- tree->Expand( root );
- input_info_category_t *p_cat = p_input->stream.p_info;
-
- while ( p_cat ) {
- wxTreeItemId cat = tree->AppendItem( root, p_cat->psz_name );
- input_info_t *p_info = p_cat->p_info;
- while ( p_info ) {
- tree->AppendItem( cat, wxString(p_info->psz_name) + ": " + p_info->psz_value );
- p_info = p_info->p_next;
+
+ /* We rebuild the tree from scratch */
+ fileinfo_tree->DeleteChildren( fileinfo_root );
+ fileinfo_root_label = wxL2U(p_input->psz_name);
+
+ vlc_mutex_lock( &p_input->p_item->lock );
+ for( int i = 0; i < p_input->p_item->i_categories; i++ )
+ {
+ info_category_t *p_cat = p_input->p_item->pp_categories[i];
+
+ wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
+ wxL2U(p_cat->psz_name) );
+ for( int j = 0; j < p_cat->i_infos; j++ )
+ {
+ info_t *p_info = p_cat->pp_infos[j];
+
+ fileinfo_tree->AppendItem( cat, (wxString)wxL2U(p_info->psz_name) +
+ wxT(": ") + wxL2U(p_info->psz_value) );
}
- p_cat = p_cat->p_next;
+ fileinfo_tree->Expand( cat );
}
- vlc_mutex_unlock( &p_input->stream.stream_lock );
+ vlc_mutex_unlock( &p_input->p_item->lock );
+
+ return;
}
FileInfo::~FileInfo()
void FileInfo::OnClose( wxCommandEvent& event )
{
- Destroy();
+ Hide();
}