]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/fileinfo.cpp
* added preferences, file info and stream output dialogs to the skins
[vlc] / modules / gui / wxwindows / fileinfo.cpp
index f4e12d3960e31d0438f811ae9c012f6be4164f7e..8f716fdd3c2a8587ee06df87c411424a70a79892 100644 (file)
@@ -2,7 +2,7 @@
  * fileinfo.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: fileinfo.cpp,v 1.3 2003/02/20 01:52:46 sigmunau Exp $
+ * $Id: fileinfo.cpp,v 1.9 2003/04/21 00:54:26 ipkiss 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,9 +67,9 @@ BEGIN_EVENT_TABLE(FileInfo, wxFrame)
     /* 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()
 
 /*****************************************************************************
@@ -74,13 +80,20 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
              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 );
+
+    /* 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 );
 
-    wxTreeCtrl *tree = new wxTreeCtrl( this, -1, wxDefaultPosition, wxDefaultSize, 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") );
+    wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
     ok_button->SetDefault();
 
     /* Place everything in sizers */
@@ -88,29 +101,66 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
     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->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
+    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 )
+    {
+        if( fileinfo_root )
+        {
+            fileinfo_tree->SetItemText ( fileinfo_root , "" );
+            fileinfo_tree->DeleteChildren ( fileinfo_root );
+        }
         return;
     }
+
+    if( !fileinfo_root )
+    {
+        fileinfo_root = fileinfo_tree->AddRoot( p_input->psz_name );
+    }
+    else if( fileinfo_tree->GetItemText( fileinfo_root ) == p_input->psz_name )
+    {
+        return;
+    }
+
+    fileinfo_tree->DeleteChildren( fileinfo_root );
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    wxTreeItemId root = tree->AddRoot( p_input->psz_name );
-    tree->Expand( root );
+
+    fileinfo_tree->SetItemText( fileinfo_root , 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,
+                                                      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(p_info->psz_name) + ": "
+                                            + p_info->psz_value );
             p_info = p_info->p_next;
         }
         p_cat = p_cat->p_next;
+        fileinfo_tree->Expand( cat );
     }
+
     vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    return;
 }
 
 FileInfo::~FileInfo()
@@ -119,5 +169,5 @@ FileInfo::~FileInfo()
 
 void FileInfo::OnClose( wxCommandEvent& event )
 {
-    Destroy();
+    Hide();
 }