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