]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/fileinfo.cpp
* include/configuration.h: added the add_directory() config macro.
[vlc] / modules / gui / wxwindows / fileinfo.cpp
1 /*****************************************************************************
2  * fileinfo.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: fileinfo.cpp,v 1.5 2003/03/26 00:56:22 gbazin Exp $
6  *
7  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44 #include <wx/treectrl.h>
45
46 #include <vlc/intf.h>
47
48 #include "wxwindows.h"
49
50 /*****************************************************************************
51  * Event Table.
52  *****************************************************************************/
53
54 /* IDs for the controls and the menu commands */
55 enum
56 {
57     Close_Event
58 };
59
60 BEGIN_EVENT_TABLE(FileInfo, wxFrame)
61     /* Button events */
62     EVT_BUTTON(wxID_OK, FileInfo::OnClose)
63
64     /* Special events : we don't want to destroy the window when the user
65      * clicks on (X) */
66     EVT_CLOSE(FileInfo::OnClose)
67 END_EVENT_TABLE()
68
69 /*****************************************************************************
70  * Constructor.
71  *****************************************************************************/
72 FileInfo::FileInfo( intf_thread_t *_p_intf, Interface *_p_main_interface ):
73     wxFrame( _p_main_interface, -1, "FileInfo", wxDefaultPosition,
74              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
75 {
76     /* Initializations */
77     intf_thread_t *p_intf = _p_intf;
78     input_thread_t *p_input = p_intf->p_sys->p_input;
79
80     wxTreeCtrl *tree =
81         new wxTreeCtrl( this, -1, wxDefaultPosition, wxSize(350,350),
82                         wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | wxSUNKEN_BORDER );
83
84     /* Create the OK button */
85     wxButton *ok_button = new wxButton( this, wxID_OK, _("OK") );
86     ok_button->SetDefault();
87
88     /* Place everything in sizers */
89     wxBoxSizer *ok_button_sizer = new wxBoxSizer( wxHORIZONTAL );
90     ok_button_sizer->Add( ok_button, 0, wxALL, 5 );
91     ok_button_sizer->Layout();
92     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
93     main_sizer->Add( tree, 1, wxGROW|wxEXPAND | wxALL, 5 );
94     main_sizer->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
95     main_sizer->Layout();
96     SetAutoLayout(TRUE);
97     SetSizerAndFit( main_sizer );
98     if ( !p_intf->p_sys->p_input ) {
99         return;
100     }
101     vlc_mutex_lock( &p_input->stream.stream_lock );
102     wxTreeItemId root = tree->AddRoot( p_input->psz_name );
103     tree->Expand( root );
104     input_info_category_t *p_cat = p_input->stream.p_info;
105     
106     while ( p_cat ) {
107         wxTreeItemId cat = tree->AppendItem( root, p_cat->psz_name );
108         input_info_t *p_info = p_cat->p_info;
109         while ( p_info ) {
110             tree->AppendItem( cat, wxString(p_info->psz_name) + ": " + p_info->psz_value );
111             p_info = p_info->p_next;
112         }
113         p_cat = p_cat->p_next;
114     }
115     vlc_mutex_unlock( &p_input->stream.stream_lock );
116 }
117
118 FileInfo::~FileInfo()
119 {
120 }
121
122 void FileInfo::OnClose( wxCommandEvent& event )
123 {
124     Destroy();
125 }