Commit ff5829d0 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/playlist.cpp: fixed a few segfaults + removed unused code.

parent cead4dbd
...@@ -181,12 +181,11 @@ END_EVENT_TABLE() ...@@ -181,12 +181,11 @@ END_EVENT_TABLE()
*****************************************************************************/ *****************************************************************************/
Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
wxFrame( p_parent, -1, wxU(_("Playlist")), wxDefaultPosition, wxFrame( p_parent, -1, wxU(_("Playlist")), wxDefaultPosition,
wxSize(345,400), wxDEFAULT_FRAME_STYLE ) wxSize(345,400), wxDEFAULT_FRAME_STYLE ), listview(NULL)
{ {
vlc_value_t val; vlc_value_t val;
/* Initializations */ /* Initializations */
iteminfo_dialog = NULL;
p_intf = _p_intf; p_intf = _p_intf;
i_update_counter = 0; i_update_counter = 0;
i_sort_mode = MODE_NONE; i_sort_mode = MODE_NONE;
...@@ -270,128 +269,80 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -270,128 +269,80 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
wxBitmap(shuffle_on_xpm), wxITEM_CHECK, wxBitmap(shuffle_on_xpm), wxITEM_CHECK,
wxU(_(HELP_SHUFFLE) ) ); wxU(_(HELP_SHUFFLE) ) );
var_Get( p_intf, "random", &val ); var_Get( p_intf, "random", &val );
vlc_bool_t b_random = val.b_bool; toolbar->ToggleTool( Random_Event, val.b_bool );
toolbar->ToggleTool( Random_Event , b_random );
/* Create the Loop tool */ /* Create the Loop tool */
toolbar->AddTool( Loop_Event, wxT(""), wxBitmap( loop_xpm), toolbar->AddTool( Loop_Event, wxT(""), wxBitmap( loop_xpm),
wxBitmap( loop_xpm), wxITEM_CHECK, wxBitmap( loop_xpm), wxITEM_CHECK,
wxU(_(HELP_LOOP ) ) ); wxU(_(HELP_LOOP ) ) );
var_Get( p_intf, "loop", &val ); var_Get( p_intf, "loop", &val );
int b_loop = val.b_bool ; toolbar->ToggleTool( Loop_Event, val.b_bool );
toolbar->ToggleTool( Loop_Event, b_loop );
/* Create the Repeat one checkbox */ /* Create the Repeat one checkbox */
toolbar->AddTool( Repeat_Event, wxT(""), wxBitmap( repeat_xpm), toolbar->AddTool( Repeat_Event, wxT(""), wxBitmap( repeat_xpm),
wxBitmap( repeat_xpm), wxITEM_CHECK, wxBitmap( repeat_xpm), wxITEM_CHECK,
wxU(_(HELP_REPEAT ) ) ); wxU(_(HELP_REPEAT ) ) );
var_Get( p_intf, "repeat", &val ); var_Get( p_intf, "repeat", &val );
int b_repeat = val.b_bool ; toolbar->ToggleTool( Repeat_Event, val.b_bool ) ;
toolbar->ToggleTool( Repeat_Event, b_repeat) ;
/* Create the Search Textbox */ /* Create the Search Textbox */
search_text = search_text = new wxTextCtrl( toolbar, SearchText_Event, wxT(""),
new wxTextCtrl( toolbar, SearchText_Event, wxT(""),
wxDefaultPosition, wxSize(100, -1), wxDefaultPosition, wxSize(100, -1),
wxTE_PROCESS_ENTER); wxTE_PROCESS_ENTER);
/* Create the search button */ /* Create the search button */
search_button = search_button = new wxButton( toolbar , Search_Event, wxU(_("Search")) );
new wxButton( toolbar , Search_Event, wxU(_("Search")) );
search_button->SetDefault();
wxControl *p_dummy_ctrl =
new wxControl( toolbar, -1, wxDefaultPosition,
wxSize(16, 16 ), wxBORDER_NONE );
toolbar->AddSeparator(); toolbar->AddControl( new wxControl( toolbar, -1, wxDefaultPosition,
toolbar->AddControl( p_dummy_ctrl ); wxSize(16, 16), wxBORDER_NONE ) );
toolbar->AddControl( search_text ); toolbar->AddControl( search_text );
toolbar->AddControl( new wxControl( toolbar, -1, wxDefaultPosition,
wxSize(5, 5), wxBORDER_NONE ) );
toolbar->AddControl( search_button ); toolbar->AddControl( search_button );
search_button->SetDefault();
toolbar->Realize(); toolbar->Realize();
/* Create the listview */ /* Create the listview */
/* FIXME: the given size is arbitrary, and prevents us from resizing /* FIXME: the given size is arbitrary, and prevents us from resizing
* the window to smaller dimensions. But the sizers don't seem to adjust * the window to smaller dimensions. But the sizers don't seem to adjust
* themselves to the size of a listview, and with a wxDefaultSize the * themselves to the size of a listview, and with a wxDefaultSize the
* playlist window is ridiculously small */ * playlist window is ridiculously small */
listview = new wxListView( playlist_panel, ListView_Event, listview = new wxListView( playlist_panel, ListView_Event,
wxDefaultPosition, wxDefaultSize,// wxSize(-1,50), wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxSUNKEN_BORDER ); wxLC_REPORT | wxSUNKEN_BORDER );
/* Reduce font size */
wxFont font= listview->GetFont(); wxFont font= listview->GetFont();
font.SetPointSize(8); font.SetPointSize(8);
listview->SetFont( font ); listview->SetFont( font );
listview->InsertColumn( 0, wxU(_("Name")) ); listview->InsertColumn( 0, wxU(_("Name")) );
#if 0
listview->InsertColumn( 1, wxU(_("Author")) );
#endif
listview->InsertColumn( 1, wxU(_("Duration")) );
#if 0
listview->InsertColumn( 3, wxU(_("Group")) );
#endif
listview->SetColumnWidth( 0, 250 ); listview->SetColumnWidth( 0, 250 );
listview->InsertColumn( 1, wxU(_("Duration")) );
listview->SetColumnWidth( 1, 75 ); listview->SetColumnWidth( 1, 75 );
/* Create the Up-Down buttons */ /* Create the Up-Down buttons */
wxButton *up_button = wxButton *up_button =
new wxButton( playlist_panel, Up_Event, wxU(_("Up") ) ); new wxButton( playlist_panel, Up_Event, wxU(_("Up") ) );
wxButton *down_button = wxButton *down_button =
new wxButton( playlist_panel, Down_Event, wxU(_("Down") ) ); new wxButton( playlist_panel, Down_Event, wxU(_("Down") ) );
#if 0
/* Create the iteminfo button */
wxButton *iteminfo_button =
new wxButton( playlist_panel, Infos_Event, wxU(_("Item info") ) );
/* Place everything in sizers */
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT, 5);
button_sizer->Layout();
#endif
wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL );
updown_sizer->Add( up_button, 0, wxALIGN_LEFT|wxRIGHT, 3);
updown_sizer->Add( down_button, 0, wxALIGN_LEFT|wxLEFT, 3);
updown_sizer->Layout(); updown_sizer->Layout();
/* The top and bottom sizers */ /* The top and bottom sizers */
#if 0
wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL );
top_sizer->Add( checkbox_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_LEFT, 4 );
top_sizer->Add( search_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 4 );
top_sizer->Layout();
#endif
wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
bottom_sizer->Add( updown_sizer, 0, bottom_sizer->Add( up_button, 0, wxALIGN_LEFT | wxRIGHT, 3);
wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4 ); bottom_sizer->Add( down_button, 0, wxALIGN_LEFT | wxLEFT, 3);
#if 0
bottom_sizer->Add( button_sizer, 0,
wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 );
#endif
bottom_sizer->Layout(); bottom_sizer->Layout();
#if 0
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
#endif
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
panel_sizer->Add( listview, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Add( listview, 1, wxEXPAND | wxALL, 5 );
panel_sizer->Add( bottom_sizer, 0, wxEXPAND | wxALL, 5); panel_sizer->Add( bottom_sizer, 0, wxEXPAND | wxALL, 5);
panel_sizer->Layout(); panel_sizer->Layout();
playlist_panel->SetSizerAndFit( panel_sizer ); playlist_panel->SetSizerAndFit( panel_sizer );
DoSize();
#if 0
main_sizer->Add( playlist_panel, 1, wxGROW, 0 );
main_sizer->Layout();
SetSizerAndFit( main_sizer );
#endif
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
/* Associate drop targets with the playlist */ /* Associate drop targets with the playlist */
SetDropTarget( new DragAndDrop( p_intf, VLC_TRUE ) ); SetDropTarget( new DragAndDrop( p_intf, VLC_TRUE ) );
...@@ -416,11 +367,11 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -416,11 +367,11 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
/* One item has been updated */ /* One item has been updated */
var_AddCallback( p_playlist, "item-change", ItemChanged, this ); var_AddCallback( p_playlist, "item-change", ItemChanged, this );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
/* Update the playlist */ /* Update the playlist */
Rebuild(); Rebuild();
DoSize();
} }
void Playlist::OnSize( wxSizeEvent& event) void Playlist::OnSize( wxSizeEvent& event)
...@@ -432,10 +383,9 @@ void Playlist::OnSize( wxSizeEvent& event) ...@@ -432,10 +383,9 @@ void Playlist::OnSize( wxSizeEvent& event)
void Playlist::DoSize() void Playlist::DoSize()
{ {
wxSize size = GetClientSize(); wxSize size = GetClientSize();
listview->SetSize( 0,0, size.x ,size.y * 4 / 5); if( listview ) listview->SetSize( 0,0, size.x ,size.y * 4 / 5);
} }
Playlist::~Playlist() Playlist::~Playlist()
{ {
playlist_t *p_playlist = playlist_t *p_playlist =
...@@ -446,8 +396,6 @@ Playlist::~Playlist() ...@@ -446,8 +396,6 @@ Playlist::~Playlist()
return; return;
} }
delete iteminfo_dialog;
var_DelCallback( p_playlist, "item-change", ItemChanged, this ); var_DelCallback( p_playlist, "item-change", ItemChanged, this );
var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this ); var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this ); var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
...@@ -1152,8 +1100,6 @@ void Playlist::ShowInfos( int i_item ) ...@@ -1152,8 +1100,6 @@ void Playlist::ShowInfos( int i_item )
return; return;
} }
if( iteminfo_dialog == NULL )
{
vlc_mutex_lock( &p_playlist->object_lock); vlc_mutex_lock( &p_playlist->object_lock);
playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item ); playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item );
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
...@@ -1161,12 +1107,10 @@ void Playlist::ShowInfos( int i_item ) ...@@ -1161,12 +1107,10 @@ void Playlist::ShowInfos( int i_item )
if( p_item ) if( p_item )
{ {
iteminfo_dialog = new ItemInfoDialog( p_intf, p_item, this ); iteminfo_dialog = new ItemInfoDialog( p_intf, p_item, this );
if( iteminfo_dialog->ShowModal() == wxID_OK ) if( iteminfo_dialog->ShowModal() == wxID_OK ) UpdateItem( i_item );
UpdateItem( i_item );
delete iteminfo_dialog; delete iteminfo_dialog;
iteminfo_dialog = NULL;
}
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment