1 /*****************************************************************************
2 * iteminfo.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
34 #include <wx/combobox.h>
35 #include <wx/statline.h>
39 #include "wxwindows.h"
42 # define wxRB_SINGLE 0
45 /*****************************************************************************
47 *****************************************************************************/
49 /* IDs for the controls and the menu commands */
58 BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog)
60 EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk)
61 EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel)
65 /*****************************************************************************
67 *****************************************************************************/
68 ItemInfoDialog::ItemInfoDialog( intf_thread_t *_p_intf,
69 playlist_item_t *_p_item,
70 wxWindow* _p_parent ):
71 wxDialog( _p_parent, -1, wxU(_("Playlist item info")),
72 wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
78 SetIcon( *p_intf->p_sys->p_icon );
80 /* Create a panel to put everything in */
81 wxPanel *panel = new wxPanel( this, -1 );
82 panel->SetAutoLayout( TRUE );
84 /* Create the standard info panel */
85 wxPanel *info_panel = InfoPanel( panel );
88 wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
90 /* Create the buttons */
91 wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
92 ok_button->SetDefault();
93 wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
96 /* Place everything in sizers */
97 wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
98 button_sizer->Add( ok_button, 0, wxALL, 5 );
99 button_sizer->Add( cancel_button, 0, wxALL, 5 );
100 button_sizer->Layout();
101 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
102 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
103 panel_sizer->Add( info_panel, 0, wxEXPAND | wxALL, 5 );
104 panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
105 panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM |
107 panel_sizer->Layout();
108 panel->SetSizerAndFit( panel_sizer );
109 main_sizer->Add( panel, 1, wxGROW, 0 );
110 main_sizer->Layout();
111 SetSizerAndFit( main_sizer );
114 ItemInfoDialog::~ItemInfoDialog()
118 /*****************************************************************************
120 *****************************************************************************/
121 wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
123 wxPanel *info_panel = new wxPanel( parent, -1, wxDefaultPosition,
125 info_panel->SetAutoLayout( TRUE );
126 wxBoxSizer *info_sizer = new wxBoxSizer( wxHORIZONTAL );
128 /* Create a box to surround the controls */
129 wxStaticBox *panel_box = new wxStaticBox( info_panel, -1,
130 wxU(_("Item Info")) );
132 wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( panel_box,
135 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,3,20);
137 wxStaticText *uri_label =
138 new wxStaticText( info_panel, -1, wxU(_("URI")) );
140 uri_text = new wxTextCtrl( info_panel, Uri_Event,
141 wxU(p_item->input.psz_uri), wxDefaultPosition, wxSize( 300, -1 ),
142 wxTE_PROCESS_ENTER );
144 sizer->Add( uri_label, 0 , wxALIGN_LEFT |wxALL , 5 );
145 sizer->Add( uri_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
148 wxStaticText *name_label =
149 new wxStaticText( info_panel, -1, wxU(_("Name")) );
151 name_text = new wxTextCtrl( info_panel, Uri_Event,
152 wxU(p_item->input.psz_name), wxDefaultPosition, wxSize( 300, -1 ),
153 wxTE_PROCESS_ENTER );
155 sizer->Add( name_label, 0 , wxALIGN_LEFT |wxALL , 5 );
156 sizer->Add( name_text, 1 , wxALIGN_RIGHT | wxALL , 5 );
159 wxStaticText *author_label =
160 new wxStaticText( info_panel, -1, wxU(_("Author")) );
162 author_text = new wxTextCtrl( info_panel, Uri_Event,
163 wxU( playlist_ItemGetInfo( p_item,
164 _("General"), _("Author") ) ),
165 wxDefaultPosition, wxSize( 300, -1 ),
168 sizer->Add( author_label, 0 , wxALIGN_LEFT | wxALL , 5 );
169 sizer->Add( author_text, 1 , wxALIGN_RIGHT | wxALL , 5);
172 info_tree = new wxTreeCtrl( info_panel, -1, wxDefaultPosition,
174 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
178 box_sizer->Add( sizer, 0, wxEXPAND, 5 );
179 box_sizer->Add( info_tree, 0, wxEXPAND, 5 );
180 info_sizer->Add( box_sizer, 1, wxBOTTOM, 5 );
182 info_panel->SetSizer( info_sizer );
183 info_sizer->Layout();
184 info_sizer->SetSizeHints( info_panel );
191 void ItemInfoDialog::UpdateInfo()
195 info_root = info_tree->AddRoot( wxU( p_item->input.psz_name) );
198 /* Rebuild the tree */
199 for( int i = 0; i< p_item->input.i_categories ; i++)
201 wxTreeItemId cat = info_tree->AppendItem( info_root,
202 wxU( p_item->input.pp_categories[i]->psz_name) );
204 for( int j = 0 ; j < p_item->input.pp_categories[i]->i_infos ; j++ )
206 info_tree->AppendItem( cat , (wxString)
207 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_name) +
209 wxU(p_item->input.pp_categories[i]->pp_infos[j]->psz_value) );
212 info_tree->Expand( cat );
216 /*****************************************************************************
218 *****************************************************************************/
219 void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
221 vlc_mutex_lock( &p_item->input.lock );
222 p_item->input.psz_name = strdup( name_text->GetLineText(0).mb_str() );
223 p_item->input.psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
224 playlist_ItemAddInfo( p_item,"General","Author",
225 author_text->GetLineText(0).mb_str() );
226 vlc_mutex_unlock( &p_item->input.lock );
230 void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
232 EndModal( wxID_CANCEL );