From 12f48a5b240271496e074f36723ab8f0c95d0ace Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Sat, 13 Nov 2004 23:06:53 +0000 Subject: [PATCH] Add directory in wxWidgets Update TODO --- TODO | 3 --- include/vlc_common.h | 1 + include/vlc_interface.h | 2 ++ include/vlc_playlist.h | 10 +++++++++ modules/gui/wxwindows/dialogs.cpp | 35 ++++++++++++++++++++++++++++++ modules/gui/wxwindows/playlist.cpp | 11 +++++++++- modules/gui/wxwindows/wxwindows.h | 2 ++ src/playlist/item-ext.c | 20 +++++++++++++++++ 8 files changed, 80 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 196c96a914..f751e4ca4f 100644 --- a/TODO +++ b/TODO @@ -123,7 +123,6 @@ Todo:
- Helper modules
- ** ASX and B4S parsers (see below)
- * Rewrite SLP announce discovery
- - *** Finish new SAP parser (see above)
- ** Adapt CDDAX
- ** Fix MP4, LIVE.COM
- *** Implement in MacOS X and Skins 2 interfaces
@@ -132,11 +131,9 @@ Todo:
- ** Support item move/copy
- * Explorer view
- *** Fix search
- - *** Play Node vs Play all
- ** Clever update using i_serial
- * Playlist preferences panel
- ** Improve iteminfo dialog
- - ** Support item types
Status: Assigned to zorglub Task diff --git a/include/vlc_common.h b/include/vlc_common.h index 8172b263db..d702dfa2af 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -223,6 +223,7 @@ typedef struct playlist_view_t playlist_view_t; typedef struct playlist_export_t playlist_export_t; typedef struct services_discovery_t services_discovery_t; typedef struct services_discovery_sys_t services_discovery_sys_t; +typedef struct playlist_add_t playlist_add_t; /* Modules */ typedef struct module_bank_t module_bank_t; diff --git a/include/vlc_interface.h b/include/vlc_interface.h index cf7c019338..2626cb5773 100644 --- a/include/vlc_interface.h +++ b/include/vlc_interface.h @@ -142,6 +142,8 @@ VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) ); #define INTF_DIALOG_CAPTURE 5 #define INTF_DIALOG_SAT 6 +#define INTF_DIALOG_DIRECTORY 7 + #define INTF_DIALOG_STREAMWIZARD 8 #define INTF_DIALOG_WIZARD 9 diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index 05b49c9061..af65a0b6f9 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -194,6 +194,15 @@ struct playlist_t /*@}*/ }; +/* Helper to add an item */ +struct playlist_add_t +{ + playlist_item_t *p_parent; + playlist_item_t *p_item; + int i_view; + int i_position; +}; + #define SORT_ID 0 #define SORT_TITLE 1 #define SORT_AUTHOR 2 @@ -296,6 +305,7 @@ VLC_EXPORT( void, playlist_ItemToNode, (playlist_t *,playlist_item_t *) ); VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int) ); VLC_EXPORT( playlist_item_t *, playlist_ItemGetByPos, (playlist_t *, int) ); VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *,int ) ); +VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t * ) ); /* Info functions */ VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) ); diff --git a/modules/gui/wxwindows/dialogs.cpp b/modules/gui/wxwindows/dialogs.cpp index c96ed6b10e..7f691894c1 100644 --- a/modules/gui/wxwindows/dialogs.cpp +++ b/modules/gui/wxwindows/dialogs.cpp @@ -60,6 +60,7 @@ private: void OnOpenFileGeneric( wxCommandEvent& event ); void OnOpenFileSimple( wxCommandEvent& event ); + void OnOpenDirectory( wxCommandEvent& event ); void OnOpenFile( wxCommandEvent& event ); void OnOpenDisc( wxCommandEvent& event ); void OnOpenNet( wxCommandEvent& event ); @@ -80,6 +81,7 @@ public: /* Secondary windows */ OpenDialog *p_open_dialog; wxFileDialog *p_file_dialog; + wxDirDialog *p_dir_dialog; Playlist *p_playlist_dialog; Messages *p_messages_dialog; FileInfo *p_fileinfo_dialog; @@ -105,6 +107,8 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame) DialogsProvider::OnOpenFileSimple) EVT_COMMAND(INTF_DIALOG_FILE_GENERIC, wxEVT_DIALOG, DialogsProvider::OnOpenFileGeneric) + EVT_COMMAND(INTF_DIALOG_DIRECTORY, wxEVT_DIALOG, + DialogsProvider::OnOpenDirectory) EVT_COMMAND(INTF_DIALOG_PLAYLIST, wxEVT_DIALOG, DialogsProvider::OnPlaylist) @@ -365,6 +369,37 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event ) vlc_object_release( p_playlist ); } +void DialogsProvider::OnOpenDirectory( wxCommandEvent& event ) +{ + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist == NULL ) + { + return; + } + + if( p_dir_dialog == NULL ) + p_dir_dialog = new wxDirDialog( NULL ); + + if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK ) + { + playlist_item_t *p_item; + wxString path = p_dir_dialog->GetPath(); + + int i_id = playlist_Add( p_playlist, (const char *)path.mb_str(), + (const char *)path.mb_str(), + PLAYLIST_APPEND, PLAYLIST_END ); + p_item = playlist_ItemGetById( p_playlist, i_id ); + if( p_item ) + { + input_CreateThread( p_intf, &p_item->input ); + } + } + + vlc_object_release( p_playlist ); +} + void DialogsProvider::OnOpenFile( wxCommandEvent& event ) { Open( FILE_ACCESS, event.GetInt() ); diff --git a/modules/gui/wxwindows/playlist.cpp b/modules/gui/wxwindows/playlist.cpp index 4d83695ce0..0a5101f463 100644 --- a/modules/gui/wxwindows/playlist.cpp +++ b/modules/gui/wxwindows/playlist.cpp @@ -65,6 +65,7 @@ enum { /* menu items */ AddFile_Event = 1, + AddDir_Event, AddMRL_Event, Close_Event, Open_Event, @@ -123,6 +124,7 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame) /* Menu events */ EVT_MENU(AddFile_Event, Playlist::OnAddFile) + EVT_MENU(AddDir_Event, Playlist::OnAddDir) EVT_MENU(AddMRL_Event, Playlist::OnAddMRL) EVT_MENU(Close_Event, Playlist::OnClose) EVT_MENU(Open_Event, Playlist::OnOpen) @@ -226,7 +228,8 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): /* Create our "Manage" menu */ wxMenu *manage_menu = new wxMenu; - manage_menu->Append( AddFile_Event, wxU(_("&Simple Add...")) ); + manage_menu->Append( AddFile_Event, wxU(_("&Simple Add File...")) ); + manage_menu->Append( AddDir_Event, wxU(_("Add &Directory...")) ); manage_menu->Append( AddMRL_Event, wxU(_("&Add MRL...")) ); manage_menu->AppendSeparator(); manage_menu->Append( MenuDummy_Event, wxU(_("Services discovery")), @@ -854,6 +857,12 @@ void Playlist::OnAddFile( wxCommandEvent& WXUNUSED(event) ) } +void Playlist::OnAddDir( wxCommandEvent& WXUNUSED(event) ) +{ + p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_DIRECTORY, 0, 0 ); + +} + void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) ) { p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 ); diff --git a/modules/gui/wxwindows/wxwindows.h b/modules/gui/wxwindows/wxwindows.h index afdfb09d82..ad8edb1e07 100644 --- a/modules/gui/wxwindows/wxwindows.h +++ b/modules/gui/wxwindows/wxwindows.h @@ -326,6 +326,7 @@ private: void OnAbout( wxCommandEvent& event ); void OnOpenFileSimple( wxCommandEvent& event ); + void OnOpenDir( wxCommandEvent& event ); void OnOpenFile( wxCommandEvent& event ); void OnOpenDisc( wxCommandEvent& event ); void OnOpenNet( wxCommandEvent& event ); @@ -791,6 +792,7 @@ private: /* Menu Handlers */ void OnAddFile( wxCommandEvent& event ); + void OnAddDir( wxCommandEvent& event ); void OnAddMRL( wxCommandEvent& event ); void OnClose( wxCommandEvent& event ); void OnSearch( wxCommandEvent& event ); diff --git a/src/playlist/item-ext.c b/src/playlist/item-ext.c index 606223f306..c63b93646c 100644 --- a/src/playlist/item-ext.c +++ b/src/playlist/item-ext.c @@ -425,6 +425,26 @@ playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id ) return NULL; } +/** + * Search an item by its input_item_t + * + * \param p_playlist the playlist + * \param p_item the input_item_t to find + * \return the item, or NULL on failure + */ +playlist_item_t * playlist_ItemGetByInput( playlist_t * p_playlist , + input_item_t *p_item ) +{ + int i; + for( i = 0 ; i < p_playlist->i_size ; i++ ) + { + if( &p_playlist->pp_items[i]->input == p_item ) + { + return p_playlist->pp_items[i]; + } + } + return NULL; +} -- 2.39.2