Commit eebed017 authored by Olivier Teulière's avatar Olivier Teulière

* modules/gui/wxwindows/playlist.cpp: fixed a refcount problem + minor coding

   style fixes
parent 9bf538c5
...@@ -310,7 +310,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -310,7 +310,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
/* Place everything in sizers */ /* Place everything in sizers */
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT , 5); button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT, 5);
button_sizer->Layout(); button_sizer->Layout();
wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL );
...@@ -341,7 +341,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -341,7 +341,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
bottom_sizer->Add( updown_sizer, 0, bottom_sizer->Add( updown_sizer, 0,
wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4 ); wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4 );
bottom_sizer->Add( button_sizer , 0, bottom_sizer->Add( button_sizer, 0,
wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 ); wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 );
bottom_sizer->Layout(); bottom_sizer->Layout();
...@@ -350,7 +350,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): ...@@ -350,7 +350,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
panel_sizer->Add( top_sizer, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( top_sizer, 0, wxEXPAND | wxALL, 5 );
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 );
...@@ -433,7 +433,7 @@ void Playlist::UpdateItem( int i ) ...@@ -433,7 +433,7 @@ void Playlist::UpdateItem( int i )
listview->SetItem( i, 0, wxL2U(p_item->input.psz_name) ); listview->SetItem( i, 0, wxL2U(p_item->input.psz_name) );
listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item, listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item,
_("General") , _("Author") ) ) ); _("General"), _("Author") ) ) );
char *psz_group = playlist_FindGroup(p_playlist, char *psz_group = playlist_FindGroup(p_playlist,
p_item->i_group); p_item->i_group);
listview->SetItem( i, 3, listview->SetItem( i, 3,
...@@ -449,8 +449,10 @@ void Playlist::UpdateItem( int i ) ...@@ -449,8 +449,10 @@ void Playlist::UpdateItem( int i )
char psz_duration[MSTRTIME_MAX_SIZE]; char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = p_item->input.i_duration; mtime_t dur = p_item->input.i_duration;
if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 ); if( dur != -1 )
else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") ); secstotimestr( psz_duration, dur/1000000 );
else
memcpy( psz_duration, "-:--:--", sizeof("-:--:--") );
listview->SetItem( i, 2, wxU(psz_duration) ); listview->SetItem( i, 2, wxU(psz_duration) );
/* Change the colour for the currenty played stream */ /* Change the colour for the currenty played stream */
...@@ -695,7 +697,6 @@ void Playlist::OnUp( wxCommandEvent& event ) ...@@ -695,7 +697,6 @@ void Playlist::OnUp( wxCommandEvent& event )
listview->Focus( i_item - 1 ); listview->Focus( i_item - 1 );
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
return;
} }
void Playlist::OnDown( wxCommandEvent& event ) void Playlist::OnDown( wxCommandEvent& event )
...@@ -713,11 +714,10 @@ void Playlist::OnDown( wxCommandEvent& event ) ...@@ -713,11 +714,10 @@ void Playlist::OnDown( wxCommandEvent& event )
wxLIST_STATE_SELECTED ); wxLIST_STATE_SELECTED );
if( i_item >= 0 && i_item < p_playlist->i_size - 1 ) if( i_item >= 0 && i_item < p_playlist->i_size - 1 )
{ {
playlist_Move( p_playlist , i_item, i_item + 2 ); playlist_Move( p_playlist, i_item, i_item + 2 );
listview->Focus( i_item + 1 ); listview->Focus( i_item + 1 );
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
return;
} }
/******************************************************************** /********************************************************************
...@@ -735,32 +735,30 @@ void Playlist::OnSort( wxCommandEvent& event ) ...@@ -735,32 +735,30 @@ void Playlist::OnSort( wxCommandEvent& event )
switch( event.GetId() ) switch( event.GetId() )
{ {
case SortTitle_Event: case SortTitle_Event:
playlist_SortTitle( p_playlist , ORDER_NORMAL ); playlist_SortTitle( p_playlist, ORDER_NORMAL );
break; break;
case RSortTitle_Event: case RSortTitle_Event:
playlist_SortTitle( p_playlist , ORDER_REVERSE ); playlist_SortTitle( p_playlist, ORDER_REVERSE );
break; break;
case SortAuthor_Event: case SortAuthor_Event:
playlist_SortAuthor(p_playlist , ORDER_NORMAL ); playlist_SortAuthor(p_playlist, ORDER_NORMAL );
break; break;
case RSortAuthor_Event: case RSortAuthor_Event:
playlist_SortAuthor( p_playlist , ORDER_REVERSE ); playlist_SortAuthor( p_playlist, ORDER_REVERSE );
break; break;
case SortGroup_Event: case SortGroup_Event:
playlist_SortGroup( p_playlist , ORDER_NORMAL ); playlist_SortGroup( p_playlist, ORDER_NORMAL );
break; break;
case RSortGroup_Event: case RSortGroup_Event:
playlist_SortGroup( p_playlist , ORDER_REVERSE ); playlist_SortGroup( p_playlist, ORDER_REVERSE );
break; break;
case Randomize_Event: case Randomize_Event:
playlist_Sort( p_playlist , SORT_RANDOM, ORDER_NORMAL ); playlist_Sort( p_playlist, SORT_RANDOM, ORDER_NORMAL );
break; break;
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
Rebuild(); Rebuild();
return;
} }
void Playlist::OnColSelect( wxListEvent& event ) void Playlist::OnColSelect( wxListEvent& event )
...@@ -828,8 +826,6 @@ void Playlist::OnColSelect( wxListEvent& event ) ...@@ -828,8 +826,6 @@ void Playlist::OnColSelect( wxListEvent& event )
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
Rebuild(); Rebuild();
return;
} }
/********************************************************************** /**********************************************************************
...@@ -910,7 +906,10 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) ...@@ -910,7 +906,10 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) )
} }
} }
if( i_item < 0 || i_item >= listview->GetItemCount() ) return; if( i_item < 0 || i_item >= listview->GetItemCount() )
{
return;
}
for( long item = 0; item < listview->GetItemCount(); item++ ) for( long item = 0; item < listview->GetItemCount(); item++ )
{ {
...@@ -922,7 +921,6 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) ...@@ -922,7 +921,6 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) )
listitem.m_state = wxLIST_STATE_SELECTED; listitem.m_state = wxLIST_STATE_SELECTED;
listview->Select( i_item, TRUE ); listview->Select( i_item, TRUE );
listview->Focus( i_item ); listview->Focus( i_item );
} }
/********************************************************************** /**********************************************************************
...@@ -1016,11 +1014,11 @@ void Playlist::OnRandom( wxCommandEvent& event ) ...@@ -1016,11 +1014,11 @@ void Playlist::OnRandom( wxCommandEvent& event )
{ {
return; return;
} }
var_Set( p_playlist , "random", val); var_Set( p_playlist, "random", val);
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
void Playlist::OnLoop ( wxCommandEvent& event ) void Playlist::OnLoop( wxCommandEvent& event )
{ {
vlc_value_t val; vlc_value_t val;
val.b_bool = event.IsChecked(); val.b_bool = event.IsChecked();
...@@ -1031,11 +1029,11 @@ void Playlist::OnLoop ( wxCommandEvent& event ) ...@@ -1031,11 +1029,11 @@ void Playlist::OnLoop ( wxCommandEvent& event )
{ {
return; return;
} }
var_Set( p_playlist , "loop", val); var_Set( p_playlist, "loop", val);
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
void Playlist::OnRepeat ( wxCommandEvent& event ) void Playlist::OnRepeat( wxCommandEvent& event )
{ {
vlc_value_t val; vlc_value_t val;
val.b_bool = event.IsChecked(); val.b_bool = event.IsChecked();
...@@ -1046,7 +1044,7 @@ void Playlist::OnRepeat ( wxCommandEvent& event ) ...@@ -1046,7 +1044,7 @@ void Playlist::OnRepeat ( wxCommandEvent& event )
{ {
return; return;
} }
var_Set( p_playlist , "repeat", val); var_Set( p_playlist, "repeat", val);
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
...@@ -1080,15 +1078,15 @@ void Playlist::OnKeyDown( wxListEvent& event ) ...@@ -1080,15 +1078,15 @@ void Playlist::OnKeyDown( wxListEvent& event )
void Playlist::ShowInfos( int i_item ) void Playlist::ShowInfos( int i_item )
{ {
playlist_t *p_playlist = if( i_item == -1 )
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{ {
return; return;
} }
if( i_item == -1 ) playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{ {
return; return;
} }
...@@ -1101,8 +1099,7 @@ void Playlist::ShowInfos( int i_item ) ...@@ -1101,8 +1099,7 @@ void Playlist::ShowInfos( int i_item )
if( p_item ) if( p_item )
{ {
iteminfo_dialog = new ItemInfoDialog( iteminfo_dialog = new ItemInfoDialog( p_intf, p_item, this );
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;
...@@ -1115,7 +1112,7 @@ void Playlist::ShowInfos( int i_item ) ...@@ -1115,7 +1112,7 @@ void Playlist::ShowInfos( int i_item )
void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) ) void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) )
{ {
/* We use the first selected item, so find it */ /* We use the first selected item, so find it */
long i_item = listview->GetNextItem( -1 , wxLIST_NEXT_ALL, long i_item = listview->GetNextItem( -1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED ); wxLIST_STATE_SELECTED );
ShowInfos( i_item ); ShowInfos( i_item );
} }
...@@ -1139,11 +1136,11 @@ void Playlist::OnEnDis( wxCommandEvent& event ) ...@@ -1139,11 +1136,11 @@ void Playlist::OnEnDis( wxCommandEvent& event )
{ {
case EnableGroup_Event: case EnableGroup_Event:
/*XXX*/ /*XXX*/
playlist_EnableGroup( p_playlist , playlist_EnableGroup( p_playlist,
p_playlist->pp_items[i_item]->i_group ); p_playlist->pp_items[i_item]->i_group );
break; break;
case DisableGroup_Event: case DisableGroup_Event:
playlist_DisableGroup( p_playlist , playlist_DisableGroup( p_playlist,
p_playlist->pp_items[i_item]->i_group ); p_playlist->pp_items[i_item]->i_group );
break; break;
} }
...@@ -1159,7 +1156,7 @@ void Playlist::OnEnDis( wxCommandEvent& event ) ...@@ -1159,7 +1156,7 @@ void Playlist::OnEnDis( wxCommandEvent& event )
void Playlist::OnPopup( wxListEvent& event ) void Playlist::OnPopup( wxListEvent& event )
{ {
i_popup_item = event.GetIndex(); i_popup_item = event.GetIndex();
Playlist::PopupMenu( popup_menu , ScreenToClient( wxGetMousePosition() ) ); Playlist::PopupMenu( popup_menu, ScreenToClient( wxGetMousePosition() ) );
} }
void Playlist::OnPopupPlay( wxMenuEvent& event ) void Playlist::OnPopupPlay( wxMenuEvent& event )
...@@ -1286,11 +1283,11 @@ NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ): ...@@ -1286,11 +1283,11 @@ NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ):
panel->SetAutoLayout( TRUE ); panel->SetAutoLayout( TRUE );
wxStaticText *group_label = wxStaticText *group_label =
new wxStaticText( panel , -1, new wxStaticText( panel, -1,
wxU(_("Enter a name for the new group:"))); wxU(_("Enter a name for the new group:")));
groupname = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition, groupname = new wxTextCtrl(panel, -1, wxU(""), wxDefaultPosition,
wxSize(100,27),wxTE_PROCESS_ENTER); wxSize(100, 27), wxTE_PROCESS_ENTER);
wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) ); wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) );
ok_button->SetDefault(); ok_button->SetDefault();
......
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