]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/fileinfo.cpp
* modules/gui/wxwindows/*: added a "simple open" entry to the "File" menu of the...
[vlc] / modules / gui / wxwindows / fileinfo.cpp
index 8f716fdd3c2a8587ee06df87c411424a70a79892..32ee83e13cb6f28d14124d5ef7a1253dabb58ac2 100644 (file)
@@ -2,7 +2,7 @@
  * fileinfo.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: fileinfo.cpp,v 1.9 2003/04/21 00:54:26 ipkiss Exp $
+ * $Id: fileinfo.cpp,v 1.17 2003/07/12 13:33:10 gbazin Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
 
 #if defined MODULE_NAME_IS_skins
 #   include "../skins/src/skin_common.h"
-#   include "../skins/src/wxdialogs.h"
-#else
-#   include "wxwindows.h"
 #endif
 
+#include "wxwindows.h"
 
 /*****************************************************************************
  * Event Table.
@@ -75,8 +73,8 @@ 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(_("FileInfo")), wxDefaultPosition,
              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
     /* Initializations */
@@ -92,8 +90,10 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
         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(_("Close")) );
     ok_button->SetDefault();
 
     /* Place everything in sizers */
@@ -117,41 +117,47 @@ void FileInfo::UpdateFileInfo()
 {
     input_thread_t *p_input = p_intf->p_sys->p_input;
 
-    if( !p_input || p_input->b_dead )
+    if( !p_input || p_input->b_dead || !p_input->psz_name )
     {
         if( fileinfo_root )
         {
-            fileinfo_tree->SetItemText ( fileinfo_root , "" );
-            fileinfo_tree->DeleteChildren ( fileinfo_root );
+            fileinfo_root_label = wxT("");
+            fileinfo_tree->DeleteChildren( fileinfo_root );
         }
         return;
     }
 
     if( !fileinfo_root )
     {
-        fileinfo_root = fileinfo_tree->AddRoot( p_input->psz_name );
+        /* 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_tree->GetItemText( fileinfo_root ) == 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 );
 
-    fileinfo_tree->SetItemText( fileinfo_root , p_input->psz_name );
     input_info_category_t *p_cat = p_input->stream.p_info;
 
-    while ( p_cat )
+    while( p_cat )
     {
         wxTreeItemId cat = fileinfo_tree->AppendItem( fileinfo_root,
-                                                      p_cat->psz_name );
+                                                      wxU(p_cat->psz_name) );
         input_info_t *p_info = p_cat->p_info;
-        while ( p_info )
+        while( p_info )
         {
-            fileinfo_tree->AppendItem( cat, wxString(p_info->psz_name) + ": "
-                                            + p_info->psz_value );
+            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;