Commit ba02e3b2 authored by Eric Petit's avatar Eric Petit

beos/*: update the playlist properly

parent db913e1c
...@@ -174,6 +174,14 @@ collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, ...@@ -174,6 +174,14 @@ collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked,
} }
} }
static int PlaylistChanged( vlc_object_t *p_this, const char * psz_variable,
vlc_value_t old_val, vlc_value_t new_val,
void * param )
{
InterfaceWindow * w = (InterfaceWindow *) param;
w->UpdatePlaylist();
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* InterfaceWindow * InterfaceWindow
...@@ -193,6 +201,15 @@ InterfaceWindow::InterfaceWindow( intf_thread_t * _p_intf, BRect frame, ...@@ -193,6 +201,15 @@ InterfaceWindow::InterfaceWindow( intf_thread_t * _p_intf, BRect frame,
fLastUpdateTime( system_time() ), fLastUpdateTime( system_time() ),
fSettings( new BMessage( 'sett' ) ) fSettings( new BMessage( 'sett' ) )
{ {
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
var_AddCallback( p_playlist, "item-change", PlaylistChanged, this );
var_AddCallback( p_playlist, "item-append", PlaylistChanged, this );
var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, this );
var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, this );
char psz_tmp[1024]; char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \ #define ADD_ELLIPSIS( a ) \
memset( psz_tmp, 0, 1024 ); \ memset( psz_tmp, 0, 1024 ); \
...@@ -416,7 +433,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -416,7 +433,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
playlist_Add( p_playlist, psz_uri, psz_device, playlist_Add( p_playlist, psz_uri, psz_device,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
} }
_UpdatePlaylist(); UpdatePlaylist();
} }
break; break;
...@@ -731,7 +748,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -731,7 +748,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
} }
} }
_UpdatePlaylist(); UpdatePlaylist();
break; break;
} }
...@@ -792,12 +809,6 @@ bool InterfaceWindow::QuitRequested() ...@@ -792,12 +809,6 @@ bool InterfaceWindow::QuitRequested()
*****************************************************************************/ *****************************************************************************/
void InterfaceWindow::UpdateInterface() void InterfaceWindow::UpdateInterface()
{ {
/* Manage the input part */
if( !p_playlist )
{
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
}
if( !p_input ) if( !p_input )
{ {
p_input = (input_thread_t *) p_input = (input_thread_t *)
...@@ -815,6 +826,17 @@ void InterfaceWindow::UpdateInterface() ...@@ -815,6 +826,17 @@ void InterfaceWindow::UpdateInterface()
return; return;
} }
if( b_playlist_update )
{
if( fPlaylistWindow->Lock() )
{
fPlaylistWindow->UpdatePlaylist( true );
fPlaylistWindow->Unlock();
b_playlist_update = false;
}
p_mediaControl->SetEnabled( p_playlist->i_size );
}
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
...@@ -840,13 +862,6 @@ void InterfaceWindow::UpdateInterface() ...@@ -840,13 +862,6 @@ void InterfaceWindow::UpdateInterface()
aout_VolumeGet( p_intf, &i_volume ); aout_VolumeGet( p_intf, &i_volume );
p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetAudioEnabled( true );
p_mediaControl->SetMuted( i_volume ); p_mediaControl->SetMuted( i_volume );
// update playlist as well
if( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK )
{
fPlaylistWindow->UpdatePlaylist();
fPlaylistWindow->Unlock();
}
} }
else else
{ {
...@@ -877,26 +892,21 @@ void InterfaceWindow::UpdateInterface() ...@@ -877,26 +892,21 @@ void InterfaceWindow::UpdateInterface()
} }
/***************************************************************************** /*****************************************************************************
* InterfaceWindow::IsStopped * InterfaceWindow::UpdatePlaylist
*****************************************************************************/ *****************************************************************************/
bool void
InterfaceWindow::IsStopped() const InterfaceWindow::UpdatePlaylist()
{ {
return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT); b_playlist_update = true;
} }
/***************************************************************************** /*****************************************************************************
* InterfaceWindow::_UpdatePlaylist * InterfaceWindow::IsStopped
*****************************************************************************/ *****************************************************************************/
void bool
InterfaceWindow::_UpdatePlaylist() InterfaceWindow::IsStopped() const
{ {
if( fPlaylistWindow->Lock() ) return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
{
fPlaylistWindow->UpdatePlaylist( true );
fPlaylistWindow->Unlock();
}
p_mediaControl->SetEnabled( p_playlist->i_size );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -102,26 +102,28 @@ class InterfaceWindow : public BWindow ...@@ -102,26 +102,28 @@ class InterfaceWindow : public BWindow
// InterfaceWindow // InterfaceWindow
void UpdateInterface(); void UpdateInterface();
void UpdatePlaylist();
bool IsStopped() const; bool IsStopped() const;
MediaControlView* p_mediaControl; MediaControlView* p_mediaControl;
MessagesWindow* fMessagesWindow; MessagesWindow* fMessagesWindow;
private: private:
void _UpdatePlaylist();
void _SetMenusEnabled( bool hasFile, void _SetMenusEnabled( bool hasFile,
bool hasChapters = false, bool hasChapters = false,
bool hasTitles = false ); bool hasTitles = false );
void _UpdateSpeedMenu( int rate ); void _UpdateSpeedMenu( int rate );
void _ShowFilePanel( uint32 command, void _ShowFilePanel( uint32 command,
const char* windowTitle ); const char* windowTitle );
void _RestoreSettings(); void _RestoreSettings();
void _StoreSettings(); void _StoreSettings();
intf_thread_t * p_intf; intf_thread_t * p_intf;
input_thread_t * p_input; input_thread_t * p_input;
playlist_t * p_playlist; playlist_t * p_playlist;
es_descriptor_t * p_spu_es; es_descriptor_t * p_spu_es;
bool b_playlist_update;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
PlayListWindow* fPlaylistWindow; PlayListWindow* fPlaylistWindow;
...@@ -149,19 +151,19 @@ class InterfaceWindow : public BWindow ...@@ -149,19 +151,19 @@ class InterfaceWindow : public BWindow
BMenu* fSpeedMenu; BMenu* fSpeedMenu;
BMenu* fShowMenu; BMenu* fShowMenu;
bigtime_t fLastUpdateTime; bigtime_t fLastUpdateTime;
BMessage* fSettings; // we keep the message arround BMessage* fSettings; // we keep the message arround
// for forward compatibility // for forward compatibility
}; };
// some global support functions // some global support functions
status_t load_settings( BMessage* message, status_t load_settings( BMessage* message,
const char* fileName, const char* fileName,
const char* folder = NULL ); const char* folder = NULL );
status_t save_settings( BMessage* message, status_t save_settings( BMessage* message,
const char* fileName, const char* fileName,
const char* folder = NULL ); const char* folder = NULL );
#endif // BEOS_INTERFACE_WINDOW_H #endif // BEOS_INTERFACE_WINDOW_H
...@@ -42,17 +42,17 @@ ...@@ -42,17 +42,17 @@
enum enum
{ {
MSG_SELECT_ALL = 'sall', MSG_SELECT_ALL = 'sall',
MSG_SELECT_NONE = 'none', MSG_SELECT_NONE = 'none',
MSG_RANDOMIZE = 'rndm', MSG_RANDOMIZE = 'rndm',
MSG_SORT_REVERSE = 'srtr', MSG_SORT_REVERSE = 'srtr',
MSG_SORT_NAME = 'srtn', MSG_SORT_NAME = 'srtn',
MSG_SORT_PATH = 'srtp', MSG_SORT_PATH = 'srtp',
MSG_REMOVE = 'rmov', MSG_REMOVE = 'rmov',
MSG_REMOVE_ALL = 'rmal', MSG_REMOVE_ALL = 'rmal',
MSG_SELECTION_CHANGED = 'slch', MSG_SELECTION_CHANGED = 'slch',
MSG_SET_DISPLAY = 'stds', MSG_SET_DISPLAY = 'stds',
}; };
...@@ -60,122 +60,122 @@ enum ...@@ -60,122 +60,122 @@ enum
* PlayListWindow::PlayListWindow * PlayListWindow::PlayListWindow
*****************************************************************************/ *****************************************************************************/
PlayListWindow::PlayListWindow( BRect frame, const char* name, PlayListWindow::PlayListWindow( BRect frame, const char* name,
InterfaceWindow* mainWindow, InterfaceWindow* mainWindow,
intf_thread_t *p_interface ) intf_thread_t *p_interface )
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ), B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
fMainWindow( mainWindow ) fMainWindow( mainWindow )
{ {
char psz_tmp[1024]; char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \ #define ADD_ELLIPSIS( a ) \
memset( psz_tmp, 0, 1024 ); \ memset( psz_tmp, 0, 1024 ); \
snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS ); snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS );
p_intf = p_interface; p_intf = p_interface;
SetName( _("playlist") ); SetName( _("playlist") );
// set up the main menu bar // set up the main menu bar
fMenuBar = new BMenuBar( BRect(0.0, 0.0, frame.Width(), 15.0), "main menu", fMenuBar = new BMenuBar( BRect(0.0, 0.0, frame.Width(), 15.0), "main menu",
B_FOLLOW_NONE, B_ITEMS_IN_ROW, false ); B_FOLLOW_NONE, B_ITEMS_IN_ROW, false );
AddChild( fMenuBar ); AddChild( fMenuBar );
// Add the File menu // Add the File menu
BMenu *fileMenu = new BMenu( _("File") ); BMenu *fileMenu = new BMenu( _("File") );
fMenuBar->AddItem( fileMenu ); fMenuBar->AddItem( fileMenu );
ADD_ELLIPSIS( _("Open File") ); ADD_ELLIPSIS( _("Open File") );
BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O' ); BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O' );
item->SetTarget( fMainWindow ); item->SetTarget( fMainWindow );
fileMenu->AddItem( item ); fileMenu->AddItem( item );
CDMenu* cd_menu = new CDMenu( _("Open Disc") ); CDMenu* cd_menu = new CDMenu( _("Open Disc") );
fileMenu->AddItem( cd_menu ); fileMenu->AddItem( cd_menu );
fileMenu->AddSeparatorItem(); fileMenu->AddSeparatorItem();
item = new BMenuItem( _("Close"), item = new BMenuItem( _("Close"),
new BMessage( B_QUIT_REQUESTED ), 'W' ); new BMessage( B_QUIT_REQUESTED ), 'W' );
fileMenu->AddItem( item ); fileMenu->AddItem( item );
// Add the Edit menu // Add the Edit menu
BMenu *editMenu = new BMenu( _("Edit") ); BMenu *editMenu = new BMenu( _("Edit") );
fMenuBar->AddItem( editMenu ); fMenuBar->AddItem( editMenu );
fSelectAllMI = new BMenuItem( _("Select All"), fSelectAllMI = new BMenuItem( _("Select All"),
new BMessage( MSG_SELECT_ALL ), 'A' ); new BMessage( MSG_SELECT_ALL ), 'A' );
editMenu->AddItem( fSelectAllMI ); editMenu->AddItem( fSelectAllMI );
fSelectNoneMI = new BMenuItem( _("Select None"), fSelectNoneMI = new BMenuItem( _("Select None"),
new BMessage( MSG_SELECT_NONE ), 'A', B_SHIFT_KEY ); new BMessage( MSG_SELECT_NONE ), 'A', B_SHIFT_KEY );
editMenu->AddItem( fSelectNoneMI ); editMenu->AddItem( fSelectNoneMI );
editMenu->AddSeparatorItem(); editMenu->AddSeparatorItem();
fSortReverseMI = new BMenuItem( _("Sort Reverse"), fSortReverseMI = new BMenuItem( _("Sort Reverse"),
new BMessage( MSG_SORT_REVERSE ), 'F' ); new BMessage( MSG_SORT_REVERSE ), 'F' );
editMenu->AddItem( fSortReverseMI ); editMenu->AddItem( fSortReverseMI );
fSortNameMI = new BMenuItem( _("Sort by Name"), fSortNameMI = new BMenuItem( _("Sort by Name"),
new BMessage( MSG_SORT_NAME ), 'N' ); new BMessage( MSG_SORT_NAME ), 'N' );
fSortNameMI->SetEnabled( false ); fSortNameMI->SetEnabled( false );
editMenu->AddItem( fSortNameMI ); editMenu->AddItem( fSortNameMI );
fSortPathMI = new BMenuItem( _("Sort by Path"), fSortPathMI = new BMenuItem( _("Sort by Path"),
new BMessage( MSG_SORT_PATH ), 'P' ); new BMessage( MSG_SORT_PATH ), 'P' );
fSortPathMI->SetEnabled( false ); fSortPathMI->SetEnabled( false );
editMenu->AddItem( fSortPathMI ); editMenu->AddItem( fSortPathMI );
fRandomizeMI = new BMenuItem( _("Randomize"), fRandomizeMI = new BMenuItem( _("Randomize"),
new BMessage( MSG_RANDOMIZE ), 'R' ); new BMessage( MSG_RANDOMIZE ), 'R' );
fRandomizeMI->SetEnabled( false ); fRandomizeMI->SetEnabled( false );
editMenu->AddItem( fRandomizeMI ); editMenu->AddItem( fRandomizeMI );
editMenu->AddSeparatorItem(); editMenu->AddSeparatorItem();
fRemoveMI = new BMenuItem( _("Remove"), fRemoveMI = new BMenuItem( _("Remove"),
new BMessage( MSG_REMOVE ) ); new BMessage( MSG_REMOVE ) );
editMenu->AddItem( fRemoveMI ); editMenu->AddItem( fRemoveMI );
fRemoveAllMI = new BMenuItem( _("Remove All"), fRemoveAllMI = new BMenuItem( _("Remove All"),
new BMessage( MSG_REMOVE_ALL ) ); new BMessage( MSG_REMOVE_ALL ) );
editMenu->AddItem( fRemoveAllMI ); editMenu->AddItem( fRemoveAllMI );
// Add View menu // Add View menu
fViewMenu = new BMenu( _("View") ); fViewMenu = new BMenu( _("View") );
fMenuBar->AddItem( fViewMenu ); fMenuBar->AddItem( fViewMenu );
fViewMenu->SetRadioMode( true ); fViewMenu->SetRadioMode( true );
BMessage* message = new BMessage( MSG_SET_DISPLAY ); BMessage* message = new BMessage( MSG_SET_DISPLAY );
message->AddInt32( "mode", DISPLAY_PATH ); message->AddInt32( "mode", DISPLAY_PATH );
item = new BMenuItem( _("Path"), message ); item = new BMenuItem( _("Path"), message );
item->SetMarked( true ); item->SetMarked( true );
fViewMenu->AddItem( item ); fViewMenu->AddItem( item );
message = new BMessage( MSG_SET_DISPLAY ); message = new BMessage( MSG_SET_DISPLAY );
message->AddInt32( "mode", DISPLAY_NAME ); message->AddInt32( "mode", DISPLAY_NAME );
item = new BMenuItem( _("Name"), message ); item = new BMenuItem( _("Name"), message );
fViewMenu->AddItem( item ); fViewMenu->AddItem( item );
// make menu bar resize to correct height // make menu bar resize to correct height
float menuWidth, menuHeight; float menuWidth, menuHeight;
fMenuBar->GetPreferredSize( &menuWidth, &menuHeight ); fMenuBar->GetPreferredSize( &menuWidth, &menuHeight );
// don't change next line! it's a workarround! // don't change next line! it's a workarround!
fMenuBar->ResizeTo( frame.Width(), menuHeight ); fMenuBar->ResizeTo( frame.Width(), menuHeight );
frame = Bounds(); frame = Bounds();
frame.top += fMenuBar->Bounds().IntegerHeight() + 1; frame.top += fMenuBar->Bounds().IntegerHeight() + 1;
frame.right -= B_V_SCROLL_BAR_WIDTH; frame.right -= B_V_SCROLL_BAR_WIDTH;
fListView = new PlaylistView( p_intf, frame, fMainWindow, fListView = new PlaylistView( p_intf, frame, fMainWindow,
new BMessage( MSG_SELECTION_CHANGED ) ); new BMessage( MSG_SELECTION_CHANGED ) );
fBackgroundView = new BScrollView( "playlist scrollview", fBackgroundView = new BScrollView( "playlist scrollview",
fListView, B_FOLLOW_ALL_SIDES, fListView, B_FOLLOW_ALL_SIDES,
0, false, true, 0, false, true,
B_NO_BORDER ); B_NO_BORDER );
AddChild( fBackgroundView ); AddChild( fBackgroundView );
// be up to date // be up to date
UpdatePlaylist(); UpdatePlaylist();
FrameResized( Bounds().Width(), Bounds().Height() ); FrameResized( Bounds().Width(), Bounds().Height() );
SetSizeLimits( menuWidth * 1.5, menuWidth * 8.0, SetSizeLimits( menuWidth * 1.5, menuWidth * 8.0,
menuHeight * 5.0, menuHeight * 50.0 ); menuHeight * 5.0, menuHeight * 50.0 );
UpdatePlaylist( true ); UpdatePlaylist( true );
// start window thread in hidden state // start window thread in hidden state
Hide(); Hide();
Show(); Show();
} }
/***************************************************************************** /*****************************************************************************
...@@ -191,8 +191,8 @@ PlayListWindow::~PlayListWindow() ...@@ -191,8 +191,8 @@ PlayListWindow::~PlayListWindow()
bool bool
PlayListWindow::QuitRequested() PlayListWindow::QuitRequested()
{ {
Hide(); Hide();
return false; return false;
} }
/***************************************************************************** /*****************************************************************************
...@@ -201,53 +201,53 @@ PlayListWindow::QuitRequested() ...@@ -201,53 +201,53 @@ PlayListWindow::QuitRequested()
void void
PlayListWindow::MessageReceived( BMessage * p_message ) PlayListWindow::MessageReceived( BMessage * p_message )
{ {
switch ( p_message->what ) switch ( p_message->what )
{ {
case OPEN_DVD: case OPEN_DVD:
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
// forward to interface window // forward to interface window
fMainWindow->PostMessage( p_message ); fMainWindow->PostMessage( p_message );
break; break;
case MSG_SELECT_ALL: case MSG_SELECT_ALL:
fListView->Select( 0, fListView->CountItems() - 1 ); fListView->Select( 0, fListView->CountItems() - 1 );
break; break;
case MSG_SELECT_NONE: case MSG_SELECT_NONE:
fListView->DeselectAll(); fListView->DeselectAll();
break; break;
case MSG_RANDOMIZE: case MSG_RANDOMIZE:
break; break;
case MSG_SORT_REVERSE: case MSG_SORT_REVERSE:
fListView->SortReverse(); fListView->SortReverse();
break; break;
case MSG_SORT_NAME: case MSG_SORT_NAME:
break; break;
case MSG_SORT_PATH: case MSG_SORT_PATH:
break; break;
case MSG_REMOVE: case MSG_REMOVE:
fListView->RemoveSelected(); fListView->RemoveSelected();
break; break;
case MSG_REMOVE_ALL: case MSG_REMOVE_ALL:
fListView->Select( 0, fListView->CountItems() - 1 ); fListView->Select( 0, fListView->CountItems() - 1 );
fListView->RemoveSelected(); fListView->RemoveSelected();
break; break;
case MSG_SELECTION_CHANGED: case MSG_SELECTION_CHANGED:
_CheckItemsEnableState(); _CheckItemsEnableState();
break; break;
case MSG_SET_DISPLAY: case MSG_SET_DISPLAY:
{ {
uint32 mode; uint32 mode;
if ( p_message->FindInt32( "mode", (int32*)&mode ) == B_OK ) if ( p_message->FindInt32( "mode", (int32*)&mode ) == B_OK )
SetDisplayMode( mode ); SetDisplayMode( mode );
break; break;
} }
case B_MODIFIERS_CHANGED: case B_MODIFIERS_CHANGED:
fListView->ModifiersChanged(); fListView->ModifiersChanged();
break; break;
default: default:
BWindow::MessageReceived( p_message ); BWindow::MessageReceived( p_message );
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -256,14 +256,14 @@ PlayListWindow::MessageReceived( BMessage * p_message ) ...@@ -256,14 +256,14 @@ PlayListWindow::MessageReceived( BMessage * p_message )
void void
PlayListWindow::FrameResized(float width, float height) PlayListWindow::FrameResized(float width, float height)
{ {
BRect r(Bounds()); BRect r(Bounds());
fMenuBar->MoveTo(r.LeftTop()); fMenuBar->MoveTo(r.LeftTop());
fMenuBar->ResizeTo(r.Width(), fMenuBar->Bounds().Height()); fMenuBar->ResizeTo(r.Width(), fMenuBar->Bounds().Height());
r.top += fMenuBar->Bounds().Height() + 1.0; r.top += fMenuBar->Bounds().Height() + 1.0;
fBackgroundView->MoveTo(r.LeftTop()); fBackgroundView->MoveTo(r.LeftTop());
// the "+ 1.0" is to make the scrollbar // the "+ 1.0" is to make the scrollbar
// be partly covered by the window border // be partly covered by the window border
fBackgroundView->ResizeTo(r.Width() + 1.0, r.Height() + 1.0); fBackgroundView->ResizeTo(r.Width() + 1.0, r.Height() + 1.0);
} }
/***************************************************************************** /*****************************************************************************
...@@ -283,13 +283,18 @@ PlayListWindow::ReallyQuit() ...@@ -283,13 +283,18 @@ PlayListWindow::ReallyQuit()
void void
PlayListWindow::UpdatePlaylist( bool rebuild ) PlayListWindow::UpdatePlaylist( bool rebuild )
{ {
if ( rebuild ) playlist_t * p_playlist;
fListView->RebuildList();
#if 0 if( rebuild )
fListView->SetCurrent( p_wrapper->PlaylistCurrent() ); fListView->RebuildList();
fListView->SetPlaying( p_wrapper->IsPlaying() );
#endif p_playlist = (playlist_t *)
_CheckItemsEnableState(); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
fListView->SetCurrent( p_playlist->i_index );
fListView->SetPlaying( p_playlist->status.i_status == PLAYLIST_RUNNING );
vlc_object_release( p_playlist );
_CheckItemsEnableState();
} }
/***************************************************************************** /*****************************************************************************
...@@ -298,25 +303,25 @@ PlayListWindow::UpdatePlaylist( bool rebuild ) ...@@ -298,25 +303,25 @@ PlayListWindow::UpdatePlaylist( bool rebuild )
void void
PlayListWindow::SetDisplayMode( uint32 mode ) PlayListWindow::SetDisplayMode( uint32 mode )
{ {
if ( Lock() ) if ( Lock() )
{ {
// propagate to list view // propagate to list view
fListView->SetDisplayMode( mode ); fListView->SetDisplayMode( mode );
// mark correct menu item // mark correct menu item
for ( int32 i = 0; BMenuItem* item = fViewMenu->ItemAt( i ); i++ ) for ( int32 i = 0; BMenuItem* item = fViewMenu->ItemAt( i ); i++ )
{ {
BMessage* message = item->Message(); BMessage* message = item->Message();
uint32 itemMode; uint32 itemMode;
if ( message if ( message
&& message->FindInt32( "mode", (int32*)&itemMode ) == B_OK && message->FindInt32( "mode", (int32*)&itemMode ) == B_OK
&& itemMode == mode ) && itemMode == mode )
{ {
item->SetMarked( true ); item->SetMarked( true );
break; break;
} }
} }
Unlock(); Unlock();
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -325,7 +330,7 @@ PlayListWindow::SetDisplayMode( uint32 mode ) ...@@ -325,7 +330,7 @@ PlayListWindow::SetDisplayMode( uint32 mode )
uint32 uint32
PlayListWindow::DisplayMode() const PlayListWindow::DisplayMode() const
{ {
return fListView->DisplayMode(); return fListView->DisplayMode();
} }
/***************************************************************************** /*****************************************************************************
...@@ -334,21 +339,21 @@ PlayListWindow::DisplayMode() const ...@@ -334,21 +339,21 @@ PlayListWindow::DisplayMode() const
void void
PlayListWindow::_CheckItemsEnableState() const PlayListWindow::_CheckItemsEnableState() const
{ {
// check if one item selected // check if one item selected
int32 test = fListView->CurrentSelection( 0 ); int32 test = fListView->CurrentSelection( 0 );
bool enable1 = test >= 0; bool enable1 = test >= 0;
// check if at least two items selected // check if at least two items selected
test = fListView->CurrentSelection( 1 ); test = fListView->CurrentSelection( 1 );
bool enable2 = test >= 0; bool enable2 = test >= 0;
bool notEmpty = fListView->CountItems() > 0; bool notEmpty = fListView->CountItems() > 0;
_SetMenuItemEnabled( fSelectAllMI, notEmpty ); _SetMenuItemEnabled( fSelectAllMI, notEmpty );
_SetMenuItemEnabled( fSelectNoneMI, enable1 ); _SetMenuItemEnabled( fSelectNoneMI, enable1 );
_SetMenuItemEnabled( fSortReverseMI, enable2 ); _SetMenuItemEnabled( fSortReverseMI, enable2 );
// _SetMenuItemEnabled( fSortNameMI, enable2 ); // _SetMenuItemEnabled( fSortNameMI, enable2 );
// _SetMenuItemEnabled( fSortPathMI, enable2 ); // _SetMenuItemEnabled( fSortPathMI, enable2 );
// _SetMenuItemEnabled( fRandomizeMI, enable2 ); // _SetMenuItemEnabled( fRandomizeMI, enable2 );
_SetMenuItemEnabled( fRemoveMI, enable1 ); _SetMenuItemEnabled( fRemoveMI, enable1 );
_SetMenuItemEnabled( fRemoveAllMI, notEmpty ); _SetMenuItemEnabled( fRemoveAllMI, notEmpty );
} }
/***************************************************************************** /*****************************************************************************
...@@ -357,7 +362,7 @@ PlayListWindow::_CheckItemsEnableState() const ...@@ -357,7 +362,7 @@ PlayListWindow::_CheckItemsEnableState() const
void void
PlayListWindow::_SetMenuItemEnabled( BMenuItem* item, bool enabled ) const PlayListWindow::_SetMenuItemEnabled( BMenuItem* item, bool enabled ) const
{ {
// this check should actally be done in BMenuItem::SetEnabled(), but it is not... // this check should actally be done in BMenuItem::SetEnabled(), but it is not...
if ( item->IsEnabled() != enabled ) if ( item->IsEnabled() != enabled )
item->SetEnabled( enabled ); item->SetEnabled( enabled );
} }
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