first shot at a file info dialog for the wxwindows interface. It still
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Sat, 21 Dec 2002 11:20:30 +0000 (11:20 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Sat, 21 Dec 2002 11:20:30 +0000 (11:20 +0000)
needs to get a sane default size and some cleanups of the code, but I commit
now in case anyone wants it during cristmas

modules/gui/wxwindows/Modules.am
modules/gui/wxwindows/fileinfo.cpp [new file with mode: 0644]
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/wxwindows.h

index 81f0332..92def6a 100644 (file)
@@ -6,6 +6,7 @@ SOURCES_wxwindows = \
        modules/gui/wxwindows/playlist.cpp \
        modules/gui/wxwindows/popup.cpp \
        modules/gui/wxwindows/timer.cpp \
+       modules/gui/wxwindows/fileinfo.cpp \
        $(NULL)
 
 EXTRA_DIST += \
diff --git a/modules/gui/wxwindows/fileinfo.cpp b/modules/gui/wxwindows/fileinfo.cpp
new file mode 100644 (file)
index 0000000..1d31ea7
--- /dev/null
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * fileinfo.cpp : wxWindows plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000-2001 VideoLAN
+ * $Id: fileinfo.cpp,v 1.1 2002/12/21 11:20:30 sigmunau Exp $
+ *
+ * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * 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"
+
+/*****************************************************************************
+ * Event Table.
+ *****************************************************************************/
+
+/* IDs for the controls and the menu commands */
+enum
+{
+    Close_Event
+};
+
+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) */
+    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,
+             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
+{
+    /* Initializations */
+    intf_thread_t *p_intf = _p_intf;
+    input_thread_t *p_input;
+    Interface *p_main_interface = _p_main_interface;
+
+    wxTreeCtrl *tree = new wxTreeCtrl( this, -1 );
+    p_input = p_intf->p_sys->p_input;
+    /* Create the OK button */
+    wxButton *ok_button = new wxButton( this, wxID_OK, _("OK") );
+    ok_button->SetDefault();
+
+    /* 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 );
+    main_sizer->Layout();
+    SetAutoLayout(TRUE);
+    SetSizerAndFit( main_sizer );
+    if ( !p_intf->p_sys->p_input ) {
+        return;
+    }
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+    wxTreeItemId root = tree->AddRoot( p_input->psz_name );
+    tree->Expand( root );
+    tree->EnsureVisible( 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;
+        }
+        p_cat = p_cat->p_next;
+    }
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+}
+
+FileInfo::~FileInfo()
+{
+}
+
+void FileInfo::OnClose( wxCommandEvent& event )
+{
+    Destroy();
+}
index bd3856f..7202cd8 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.11 2002/12/15 18:37:39 ipkiss Exp $
+ * $Id: interface.cpp,v 1.12 2002/12/21 11:20:30 sigmunau Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -86,6 +86,7 @@ enum
 
     Playlist_Event,
     Logs_Event,
+    FileInfo_Event,
 
     Audio_Event,
     Subtitles_Event,
@@ -110,6 +111,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(About_Event, Interface::OnAbout)
     EVT_MENU(Playlist_Event, Interface::OnPlaylist)
     EVT_MENU(Logs_Event, Interface::OnLogs)
+    EVT_MENU(FileInfo_Event, Interface::OnFileInfo)
     EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
     /* Toolbar events */
     EVT_MENU(OpenFile_Event, Interface::OnOpenFile)
@@ -189,6 +191,7 @@ void Interface::CreateOurMenuBar()
 
 #define HELP_PLAYLIST   N_("Open the playlist")
 #define HELP_LOGS       N_("Show the program logs")
+#define HELP_FILEINFO       N_("Show information about the file being played")
 
 #define HELP_AUDIO N_("Change the current audio track")
 #define HELP_SUBS  N_("Change the current subtitles stream")
@@ -213,6 +216,7 @@ void Interface::CreateOurMenuBar()
     wxMenu *view_menu = new wxMenu;
     view_menu->Append( Playlist_Event, _("&Playlist..."), HELP_PLAYLIST );
     view_menu->Append( Logs_Event, _("&Logs..."), HELP_LOGS );
+    view_menu->Append( FileInfo_Event, _("&File info..."), HELP_FILEINFO );
 
     /* Create the "Settings" menu */
     wxMenu *settings_menu = new wxMenu;
@@ -358,6 +362,16 @@ void Interface::OnLogs( wxCommandEvent& WXUNUSED(event) )
     }
 }
 
+void Interface::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
+{
+    /* Show/hide the fileinfo window */
+    wxFrame *p_fileinfo_window = new FileInfo( p_intf, this );
+    if( p_fileinfo_window )
+    {
+        p_fileinfo_window->Show( true );//! p_messages_window->IsShown() );
+    }
+}
+
 void Interface::OnOpenFile( wxCommandEvent& WXUNUSED(event) )
 {
     wxFileDialog dialog( this, _("Open file"), _(""), _(""), _("*.*") );
index 54a54ed..b1d9540 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.6 2002/12/15 18:37:39 ipkiss Exp $
+ * $Id: wxwindows.h,v 1.7 2002/12/21 11:20:30 sigmunau Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -127,6 +127,7 @@ private:
     void OnMessages( wxCommandEvent& event );
     void OnPlaylist( wxCommandEvent& event );
     void OnLogs( wxCommandEvent& event );
+    void OnFileInfo( wxCommandEvent& event );
     void OnOpenFile( wxCommandEvent& event );
     void OnPlayStream( wxCommandEvent& event );
     void OnStopStream( wxCommandEvent& event );
@@ -197,6 +198,20 @@ private:
     wxButton *ok_button;
 };
 
+/* File Info */
+class FileInfo: public wxFrame
+{
+public:
+    /* Constructor */
+    FileInfo( intf_thread_t *p_intf, Interface *p_main_interface );
+    virtual ~FileInfo();
+
+private:
+    void OnClose( wxCommandEvent& event );
+    DECLARE_EVENT_TABLE();
+    
+};
+
 #if !defined(__WXX11__)
 /* Drag and Drop class */
 class DragAndDrop: public wxFileDropTarget