]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/fileinfo.cpp
* configure.ac.in: fixed the wx-config detection by the skins plugin.
[vlc] / modules / gui / wxwindows / fileinfo.cpp
index fffdf1b9aed0796c2c8536392c6ca960a8e91ed6..1b85330e84165029ff9f6d198372ba493c504c0d 100644 (file)
@@ -2,7 +2,7 @@
  * fileinfo.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: fileinfo.cpp,v 1.7 2003/04/06 13:18:26 sigmunau Exp $
+ * $Id: fileinfo.cpp,v 1.13 2003/05/11 13:45:21 gbazin Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
 
 #include <vlc/intf.h>
 
-#include "wxwindows.h"
+#if defined MODULE_NAME_IS_skins
+#   include "../skins/src/skin_common.h"
+#   include "../skins/src/wxdialogs.h"
+#else
+#   include "wxwindows.h"
+#endif
+
 
 /*****************************************************************************
  * Event Table.
@@ -61,7 +67,7 @@ BEGIN_EVENT_TABLE(FileInfo, wxFrame)
     /* Button events */
     EVT_BUTTON(wxID_OK, FileInfo::OnClose)
 
-    /* Destroy the window when the user closes the window */
+    /* Hide the window when the user closes the window */
     EVT_CLOSE(FileInfo::OnClose)
 
 END_EVENT_TABLE()
@@ -70,25 +76,26 @@ END_EVENT_TABLE()
  * Constructor.
  *****************************************************************************/
 FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
-    wxFrame( _p_main_interface, -1, "FileInfo", wxDefaultPosition,
+    wxFrame( _p_main_interface, -1, wxU(_("FileInfo")), wxDefaultPosition,
              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
-    intf_thread_t *p_intf = _p_intf;
-    input_thread_t *p_input = p_intf->p_sys->p_input;
+    p_intf = _p_intf;
     SetIcon( *p_intf->p_sys->p_icon );
-    SetAutoLayout(TRUE);
+    SetAutoLayout( TRUE );
 
     /* Create a panel to put everything in */
     wxPanel *panel = new wxPanel( this, -1 );
     panel->SetAutoLayout( TRUE );
 
-    wxTreeCtrl *tree =
-        new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize(350,350),
+    fileinfo_tree =
+        new wxTreeCtrl( panel, -1, wxDefaultPosition, wxSize( 350, 350 ),
                         wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
 
+    fileinfo_root_label = wxT("");
+
     /* Create the OK button */
-    wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
+    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
     ok_button->SetDefault();
 
     /* Place everything in sizers */
@@ -97,7 +104,7 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
     ok_button_sizer->Layout();
     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
-    panel_sizer->Add( tree, 1, wxEXPAND | wxALL, 5 );
+    panel_sizer->Add( fileinfo_tree, 1, wxEXPAND | wxALL, 5 );
     panel_sizer->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
     panel_sizer->Layout();
     panel->SetSizerAndFit( panel_sizer );
@@ -105,31 +112,63 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
     main_sizer->Layout();
     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 )
     {
-        /* Nothing to show, but hey... */
-        Show( true );
+        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( wxU(p_input->psz_name) );
+        fileinfo_root_label = wxU(p_input->psz_name);
+    }
+    else if( fileinfo_root_label == wxU(p_input->psz_name) )
+    {
+        return;
+    }
+
+    /* We rebuild the tree from scratch */
+    fileinfo_tree->DeleteChildren( fileinfo_root );
+    fileinfo_root_label = wxU(p_input->psz_name);
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    wxTreeItemId root = tree->AddRoot( p_input->psz_name );
+
     input_info_category_t *p_cat = p_input->stream.p_info;
-    
-    while ( p_cat ) {
-        wxTreeItemId cat = tree->AppendItem( root, p_cat->psz_name );
+
+    while( p_cat )
+    {
+        wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
+                                                      wxU(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 );
+        while( p_info )
+        {
+            fileinfo_tree->AppendItem( cat, (wxString)wxU(p_info->psz_name) +
+                                       wxT(": ") + wxU(p_info->psz_value) );
             p_info = p_info->p_next;
         }
         p_cat = p_cat->p_next;
-        tree->Expand( cat );
+        fileinfo_tree->Expand( cat );
     }
+
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    Show( true );
+    return;
 }
 
 FileInfo::~FileInfo()
@@ -138,5 +177,5 @@ FileInfo::~FileInfo()
 
 void FileInfo::OnClose( wxCommandEvent& event )
 {
-    Destroy();
+    Hide();
 }