From 84b846bf8c510666af2b7436ce4563025e6b6063 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Stenac?= Date: Wed, 29 Oct 2003 17:32:55 +0000 Subject: [PATCH] * src/playlist/* && Makefile.am - splitted the enormous playlist.c file - implemented a better item group system: groups have a name and must be created before use by playlist_CreateGroup( p_playlist, "newgroupname") * modules/misc/sap.c - Create our own playlist group ("SAP") and use it * modules/access/slp.c - Create our own playlist group ("SLP") and use it * modules/demux/util/id3tag.c - Trigger playlist update when we have parsed our tag * modules/gui/wxwindows/interface.cpp - Fixed the about box by using vlc_wraptext - Added the simple open and the streaming wizard icons *** Icons need to be changed ! *** - Added the visualization to the extended gui * modules/gui/wxwindows/preferences.cpp && include/vlc_help.h - Enlarged the window to fit the wrapped text - Added help for audio encoders * modules/gui/wxwindows/stream.cpp & open.cpp & include/vlc_interface.h - Created a "streaming wizard" window (3-step streaming) * modules/gui/wxwindows/iteminfo.cpp: - Group change is now based on the name * modules/gui/wxwindows/playlist.cpp - Added author and group columns to the listview - Redesigned the window - Added the Sort menu with several criteria (title, author, group) - Added up/down buttons to move an item in the playlist - Added the group menu to enable/disable a group in an understandable way TODO: ----- * playlist core : - Implement advanced sort capabilities (multi-criteria) - File format to save the new features - export playlist (to M3U, eg) - more robust group creation (duplicates check, ...) * wxWindows playlist: The idea of a treeview seems impossible, because of wxWindow's treeview, that don't allow multi-selection, and, as far as I know, multi-columns. - Provide a frontend to advanced sort (when it's done :-) ) - Allow moving items by drag & drop (well, if possible, haven't checked yet) - Allow moving several items at once - Customizable listview (ability to remove/move columns) - Find a solution to the focus problem (when you change track, the selected one scrolls at the bottom of the visible screen) * wxWindows interface: - New icons, our icons begin to get old and not so pretty - Find a solution for the volume bar (nobody understands what it is) --- Makefile.am | 4 + include/vlc_common.h | 3 +- include/vlc_help.h | 5 +- include/vlc_interface.h | 4 +- include/vlc_playlist.h | 27 +- modules/access/slp.c | 43 +- modules/demux/util/id3tag.c | 43 +- modules/gui/wxwindows/Modules.am | 1 + modules/gui/wxwindows/dialogs.cpp | 22 +- modules/gui/wxwindows/interface.cpp | 131 ++++- modules/gui/wxwindows/iteminfo.cpp | 79 ++- modules/gui/wxwindows/open.cpp | 157 +++--- modules/gui/wxwindows/playlist.cpp | 372 +++++++++++--- modules/gui/wxwindows/preferences.cpp | 6 +- modules/gui/wxwindows/wxwindows.h | 96 +++- modules/misc/sap.c | 46 +- src/playlist/playlist.c | 667 +------------------------- 17 files changed, 826 insertions(+), 880 deletions(-) diff --git a/Makefile.am b/Makefile.am index 58ed815045..869ff75a43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -296,6 +296,10 @@ SOURCES_libvlc_common = \ src/interface/interface.c \ src/interface/intf_eject.c \ src/playlist/playlist.c \ + src/playlist/sort.c \ + src/playlist/loadsave.c \ + src/playlist/group.c \ + src/playlist/item.c \ src/input/input.c \ src/input/stream.c \ src/input/demux.c \ diff --git a/include/vlc_common.h b/include/vlc_common.h index 5400438c66..20398d00a7 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -3,7 +3,7 @@ * Collection of useful common types and macros definitions ***************************************************************************** * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id: vlc_common.h,v 1.84 2003/10/29 01:33:27 gbazin Exp $ + * $Id: vlc_common.h,v 1.85 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Samuel Hocevar * Vincent Seguin @@ -184,6 +184,7 @@ typedef struct msg_subscription_t msg_subscription_t; /* Playlist */ typedef struct playlist_t playlist_t; typedef struct playlist_item_t playlist_item_t; +typedef struct playlist_group_t playlist_group_t; /* Modules */ typedef struct module_bank_t module_bank_t; diff --git a/include/vlc_help.h b/include/vlc_help.h index 8e0f92231a..7fdedc6832 100644 --- a/include/vlc_help.h +++ b/include/vlc_help.h @@ -2,7 +2,7 @@ * vlc_help.h: Help strings ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: vlc_help.h,v 1.3 2003/10/08 19:40:42 gbazin Exp $ + * $Id: vlc_help.h,v 1.4 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Clément Stenac * Anil Daoud @@ -58,6 +58,9 @@ #define AOUT_TITLE N_("Audio output modules settings") #define AOUT_HELP N_("These are general settings for audio output modules.") +#define AOUT_ENC_TITLE N_("Audio encoders settings") +#define AOUT_ENC_HELP N_("These are general settings for audio encoding modules.") + #define CHROMA_TITLE N_("Chroma modules settings") #define CHROMA_HELP N_(" ") diff --git a/include/vlc_interface.h b/include/vlc_interface.h index cb75b7325c..43546bf94c 100644 --- a/include/vlc_interface.h +++ b/include/vlc_interface.h @@ -4,7 +4,7 @@ * interface, such as message output. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: vlc_interface.h,v 1.7 2003/10/14 22:41:41 gbazin Exp $ + * $Id: vlc_interface.h,v 1.8 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Vincent Seguin * @@ -135,6 +135,8 @@ VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) ); #define INTF_DIALOG_NET 4 #define INTF_DIALOG_SAT 5 +#define INTF_DIALOG_STREAM 8 + #define INTF_DIALOG_PLAYLIST 10 #define INTF_DIALOG_MESSAGES 11 #define INTF_DIALOG_FILEINFO 12 diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index c88cd961c4..51cbd7d533 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -2,7 +2,7 @@ * vlc_playlist.h : Playlist functions ***************************************************************************** * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN - * $Id: vlc_playlist.h,v 1.14 2003/10/06 16:23:30 zorglub Exp $ + * $Id: vlc_playlist.h,v 1.15 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Samuel Hocevar * @@ -59,6 +59,12 @@ struct playlist_item_t char * psz_author; /**< Author */ }; +struct playlist_group_t +{ + char * psz_name; /**< name of the group */ + int i_id; /**< Identifier for the group */ +}; + /** * Playlist status */ @@ -81,7 +87,10 @@ struct playlist_t int i_enabled; /**< How many items are enabled ? */ playlist_item_t ** pp_items; /**< array of pointers to the * playlist items */ - + int i_groups; /**< How many groups are in the playlist */ + playlist_group_t ** pp_groups;/**< array of pointers to the playlist + * groups */ + int i_max_id; /**< Maximal group id given */ input_thread_t * p_input; /**< the input thread ascosiated * with the current item */ /*@}*/ @@ -90,8 +99,8 @@ struct playlist_t #define SORT_NORMAL 0 #define SORT_REVERSE 1 -#define PLAYLIST_TYPE_MANUAL 0 -#define PLAYLIST_TYPE_SAP 1 +#define PLAYLIST_TYPE_MANUAL 1 +#define PLAYLIST_TYPE_SAP 2 /***************************************************************************** * Prototypes @@ -117,7 +126,15 @@ VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Enable, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_DisableGroup, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_EnableGroup, ( playlist_t *, int ) ); -VLC_EXPORT( int, playlist_Sort, ( playlist_t *, int) ); + +VLC_EXPORT( playlist_group_t *, playlist_CreateGroup, (playlist_t *, char* ) ); +VLC_EXPORT( int, playlist_DeleteGroup, (playlist_t *, int ) ); +VLC_EXPORT( char *, playlist_FindGroup, (playlist_t *, int ) ); + +VLC_EXPORT( int, playlist_SortTitle, ( playlist_t *, int) ); +VLC_EXPORT( int, playlist_SortAuthor, ( playlist_t *, int) ); +VLC_EXPORT( int, playlist_SortGroup, ( playlist_t *, int) ); + VLC_EXPORT( int, playlist_Move, ( playlist_t *, int, int ) ); VLC_EXPORT( int, playlist_LoadFile, ( playlist_t *, const char * ) ); VLC_EXPORT( int, playlist_SaveFile, ( playlist_t *, const char * ) ); diff --git a/modules/access/slp.c b/modules/access/slp.c index 2be2436c2d..1ed5405267 100644 --- a/modules/access/slp.c +++ b/modules/access/slp.c @@ -2,7 +2,7 @@ * slp.c: SLP access plugin ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: slp.c,v 1.16 2003/09/14 16:41:48 zorglub Exp $ + * $Id: slp.c,v 1.17 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Loïc Minier * @@ -10,7 +10,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -44,6 +44,8 @@ static int Init ( vlc_object_t * ); static void End ( vlc_object_t * ); static int Demux ( input_thread_t * ); +int i_group; + /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -112,10 +114,12 @@ static SLPBoolean AttrCallback( SLPHandle slph_slp, /* or there was a problem with getting the data we requested */ if( (slpe_errcode != SLP_OK) ) { -/* msg_Err( (vlc_object_t*)NULL, +#if 0 + msg_Err( (vlc_object_t*)NULL, "AttrCallback got an error %i with attribute %s", slpe_errcode, - psz_attrlist ); */ + psz_attrlist ); +#endif return SLP_TRUE; } @@ -145,7 +149,7 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, { return SLP_TRUE; } - + msg_Dbg(p_input,"URL: %s",psz_srvurl); /* or there was a problem with getting the data we requested */ @@ -188,6 +192,9 @@ static SLPBoolean SrvUrlCallback( SLPHandle slph_slp, p_playlist_item->b_autodeletion = VLC_FALSE; p_playlist_item->i_options = 0; p_playlist_item->ppsz_options = 0; + p_playlist_item->psz_author = NULL; + p_playlist_item->i_group = i_group; + p_playlist_item->b_enabled = VLC_TRUE; /* search the description of the stream */ if( SLPOpen( config_GetPsz( p_input, "slp-lang" ), @@ -258,7 +265,7 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp, { return SLP_TRUE; } - + msg_Dbg(p_input,"Services: %s",psz_srvurl); /* or there was a problem with getting the data we requested */ @@ -289,14 +296,14 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp, if(!psz_eos) break; if(!strncasecmp(psz_eos+1,"service:",8)) break; } - - if(psz_eos) + + if(psz_eos) *psz_eos = '\0'; psz_service = strdup( psz_srvurl); - + msg_Dbg(p_input,"Getting details for %s",psz_service); - + slpe_result = SLPFindSrvs( slph_slp2, psz_service, config_GetPsz( p_input, "slp-scopelist" ), @@ -306,9 +313,10 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp, if(psz_eos) psz_srvurl = psz_eos; - -// SLPClose( slph_slp2 ); +#if 0 + SLPClose( slph_slp2 ); +#endif if( slpe_result != SLP_OK ) { msg_Err( p_input, @@ -330,10 +338,11 @@ static SLPBoolean SrvTypeCallback( SLPHandle slph_slp, *****************************************************************************/ static int Open( vlc_object_t * p_this ) { - input_thread_t * p_input = (input_thread_t *)p_this; - SLPError slpe_result; - SLPHandle slph_slp; - playlist_t * p_playlist; + input_thread_t * p_input = (input_thread_t *)p_this; + SLPError slpe_result; + SLPHandle slph_slp; + playlist_t * p_playlist; + playlist_group_t * p_group; /* remove the "slp:" entry of the playlist */ p_playlist = (playlist_t *) vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, @@ -344,6 +353,8 @@ static int Open( vlc_object_t * p_this ) return VLC_FALSE; } + p_group = playlist_CreateGroup( p_playlist , "SLP" ); + i_group = p_group->i_id; p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE; vlc_object_release( (vlc_object_t *)p_playlist ); diff --git a/modules/demux/util/id3tag.c b/modules/demux/util/id3tag.c index bef087ee48..f66dbe96c8 100644 --- a/modules/demux/util/id3tag.c +++ b/modules/demux/util/id3tag.c @@ -2,7 +2,7 @@ * id3tag.c: id3 tag parser/skipper based on libid3tag ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: id3tag.c,v 1.13 2003/10/25 00:49:14 sam Exp $ + * $Id: id3tag.c,v 1.14 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Sigmund Augdal * @@ -76,6 +76,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) return; } + val.b_bool = VLC_FALSE; p_id3_tag = id3_tag_parse( p_data, i_size ); p_category = input_InfoCategory( p_input, "ID3" ); i = 0; @@ -93,42 +94,64 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) i_genre = strtol( psz_temp, &psz_endptr, 10 ); if( psz_temp != psz_endptr && i_genre >= 0 && i_genre < NUM_GENRES ) { - input_AddInfo( p_category, (char *)p_frame->description, ppsz_genres[atoi(psz_temp)]); + input_AddInfo( p_category, (char *)p_frame->description, + ppsz_genres[atoi(psz_temp)]); } else { - input_AddInfo( p_category, (char *)p_frame->description, psz_temp ); + input_AddInfo( p_category, (char *)p_frame->description, + psz_temp ); } } else if ( !strcmp(p_frame->id, ID3_FRAME_TITLE ) ) { - p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT ); + p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, + FIND_PARENT ); if( p_playlist ) { - p_playlist->pp_items[p_playlist->i_index]->psz_name = strdup( psz_temp ); + p_playlist->pp_items[p_playlist->i_index]->psz_name = + strdup( psz_temp ); + val.b_bool = VLC_TRUE; vlc_object_release( p_playlist ); } - input_AddInfo( p_category, (char *)p_frame->description, psz_temp ); + input_AddInfo( p_category, (char *)p_frame->description, + psz_temp ); } else if ( !strcmp(p_frame->id, ID3_FRAME_ARTIST ) ) { - p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT ); + p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, + FIND_PARENT ); if( p_playlist ) { - p_playlist->pp_items[p_playlist->i_index]->psz_author = strdup( psz_temp ); + p_playlist->pp_items[p_playlist->i_index]->psz_author = + strdup( psz_temp ); + val.b_bool = VLC_TRUE; vlc_object_release( p_playlist ); } - input_AddInfo( p_category, (char *)p_frame->description, psz_temp ); + input_AddInfo( p_category, (char *)p_frame->description, + psz_temp ); } else { - input_AddInfo( p_category, (char *)p_frame->description, psz_temp ); + input_AddInfo( p_category, (char *)p_frame->description, + psz_temp ); } free( psz_temp ); } i++; } id3_tag_delete( p_id3_tag ); + if(val.b_bool == VLC_TRUE ) + { + p_playlist = vlc_object_find( p_input, + VLC_OBJECT_PLAYLIST, FIND_PARENT ); + if( p_playlist ) + { + val.b_bool = VLC_TRUE; + var_Set( p_playlist, "intf-change", val ); + vlc_object_release( p_playlist ); + } + } val.b_bool = VLC_TRUE; var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL ); } diff --git a/modules/gui/wxwindows/Modules.am b/modules/gui/wxwindows/Modules.am index e895c3683d..37fddbc941 100644 --- a/modules/gui/wxwindows/Modules.am +++ b/modules/gui/wxwindows/Modules.am @@ -5,6 +5,7 @@ SOURCES_wxwindows = \ dialogs.cpp \ open.cpp \ streamout.cpp \ + stream.cpp \ messages.cpp \ playlist.cpp \ iteminfo.cpp \ diff --git a/modules/gui/wxwindows/dialogs.cpp b/modules/gui/wxwindows/dialogs.cpp index 59bfe74887..fe4473e45b 100644 --- a/modules/gui/wxwindows/dialogs.cpp +++ b/modules/gui/wxwindows/dialogs.cpp @@ -2,7 +2,7 @@ * dialogs.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: dialogs.cpp,v 1.9 2003/10/15 12:24:14 gbazin Exp $ + * $Id: dialogs.cpp,v 1.10 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Gildas Bazin * @@ -60,6 +60,8 @@ BEGIN_EVENT_TABLE(DialogsProvider, wxFrame) DialogsProvider::OnMessages) EVT_COMMAND(INTF_DIALOG_PREFS, wxEVT_DIALOG, DialogsProvider::OnPreferences) + EVT_COMMAND(INTF_DIALOG_STREAM, wxEVT_DIALOG, + DialogsProvider::OnStreamDialog) EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG, DialogsProvider::OnFileInfo) EVT_COMMAND(INTF_DIALOG_POPUPMENU, wxEVT_DIALOG, @@ -83,6 +85,7 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent ) p_fileinfo_dialog = NULL; p_prefs_dialog = NULL; p_file_generic_dialog = NULL; + p_stream_dialog = NULL; /* Give our interface a nice little icon */ p_intf->p_sys->p_icon = new wxIcon( vlc_xpm ); @@ -104,6 +107,8 @@ DialogsProvider::~DialogsProvider() if( p_messages_dialog ) delete p_messages_dialog; if( p_fileinfo_dialog ) delete p_fileinfo_dialog; if( p_file_generic_dialog ) delete p_file_generic_dialog; + if( p_stream_dialog ) delete p_stream_dialog; + if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon; @@ -177,6 +182,18 @@ void DialogsProvider::OnPreferences( wxCommandEvent& WXUNUSED(event) ) } } +void DialogsProvider::OnStreamDialog( wxCommandEvent& WXUNUSED(event) ) +{ + /* Show/hide the stream window */ + if( !p_stream_dialog ) + p_stream_dialog = new StreamDialog( p_intf, this ); + + if( p_stream_dialog ) + { + p_stream_dialog->Show( !p_stream_dialog->IsShown() ); + } +} + void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event ) { intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData(); @@ -306,7 +323,8 @@ void DialogsProvider::Open( int i_access_method, int i_arg ) { /* Show/hide the open dialog */ if( !p_open_dialog ) - p_open_dialog = new OpenDialog( p_intf, this, i_access_method, i_arg ); + p_open_dialog = new OpenDialog(p_intf, this, i_access_method, i_arg , + OPEN_NORMAL ); if( p_open_dialog ) { diff --git a/modules/gui/wxwindows/interface.cpp b/modules/gui/wxwindows/interface.cpp index afb51dfbbb..d08181d6dc 100644 --- a/modules/gui/wxwindows/interface.cpp +++ b/modules/gui/wxwindows/interface.cpp @@ -2,7 +2,7 @@ * interface.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: interface.cpp,v 1.68 2003/10/29 01:33:27 gbazin Exp $ + * $Id: interface.cpp,v 1.69 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Gildas Bazin * @@ -39,10 +39,13 @@ /* include the toolbar graphics */ #include "bitmaps/file.xpm" + +#include "bitmaps/stream.xpm" + #include "bitmaps/disc.xpm" #include "bitmaps/net.xpm" #if 0 -#include "bitmaps/sat.xpm" + #include "bitmaps/sat.xpm" #endif #include "bitmaps/play.xpm" #include "bitmaps/pause.xpm" @@ -53,6 +56,8 @@ #include "bitmaps/fast.xpm" #include "bitmaps/slow.xpm" +#include + #define TOOLBAR_BMP_WIDTH 36 #define TOOLBAR_BMP_HEIGHT 36 @@ -113,14 +118,19 @@ END_EVENT_TABLE() enum { /* menu items */ + MenuDummy_Event = wxID_HIGHEST + 1000, Exit_Event = wxID_HIGHEST, OpenFileSimple_Event, + OpenAdv_Event, OpenFile_Event, OpenDisc_Event, OpenNet_Event, OpenSat_Event, + OpenOther_Event, EjectDisc_Event, + Stream_Event, + Playlist_Event, Logs_Event, FileInfo_Event, @@ -144,6 +154,8 @@ enum Saturation_Event, Ratio_Event, + Visual_Event, + /* it is important for the id corresponding to the "About" command to have * this standard value as otherwise it won't be handled properly under Mac * (where it is special and put into the "Apple" menu) */ @@ -166,6 +178,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame) EVT_CHECKBOX( Adjust_Event, Interface::OnEnableAdjust) EVT_COMBOBOX( Ratio_Event, Interface::OnRatio) + EVT_CHECKBOX( Visual_Event, Interface::OnEnableVisual) #if defined( __WXMSW__ ) || defined( __WXMAC__ ) EVT_CONTEXT_MENU(Interface::OnContextMenu2) @@ -174,10 +187,12 @@ BEGIN_EVENT_TABLE(Interface, wxFrame) /* Toolbar events */ EVT_MENU(OpenFileSimple_Event, Interface::OnShowDialog) + EVT_MENU(OpenAdv_Event, Interface::OnShowDialog) EVT_MENU(OpenFile_Event, Interface::OnShowDialog) EVT_MENU(OpenDisc_Event, Interface::OnShowDialog) EVT_MENU(OpenNet_Event, Interface::OnShowDialog) EVT_MENU(OpenSat_Event, Interface::OnShowDialog) + EVT_MENU(Stream_Event, Interface::OnStream) EVT_MENU(StopStream_Event, Interface::OnStopStream) EVT_MENU(PlayStream_Event, Interface::OnPlayStream) EVT_MENU(PrevStream_Event, Interface::OnPrevStream) @@ -211,7 +226,6 @@ Interface::Interface( intf_thread_t *_p_intf ): SetIcon( wxIcon( vlc_xpm ) ); /* Create a sizer for the main frame */ - //frame_sizer= new wxFlexGridSizer( 1, 0, 0); frame_sizer = new wxBoxSizer( wxVERTICAL ); SetSizer( frame_sizer ); @@ -280,6 +294,8 @@ Interface::~Interface() *****************************************************************************/ void Interface::CreateOurMenuBar() { +#define HELP_SIMPLE N_("Quick file open") +#define HELP_ADV N_("Advanced open") #define HELP_FILE N_("Open a file") #define HELP_DISC N_("Open a DVD or (S)VCD") #define HELP_NET N_("Open a network stream") @@ -287,6 +303,9 @@ void Interface::CreateOurMenuBar() #define HELP_EJECT N_("Eject the DVD/CD") #define HELP_EXIT N_("Exit this program") +#define HELP_STREAM N_("Streaming wizard") +#define HELP_OTHER N_("Open other types of inputs") + #define HELP_PLAYLIST N_("Open the playlist") #define HELP_LOGS N_("Show the program logs") #define HELP_FILEINFO N_("Show information about the file being played") @@ -299,22 +318,23 @@ void Interface::CreateOurMenuBar() /* Create the "File" menu */ wxMenu *file_menu = new wxMenu; file_menu->Append( OpenFileSimple_Event, wxU(_("Simple &Open ...")), - wxU(_(HELP_FILE)) ); + wxU(_(HELP_SIMPLE)) ); + + file_menu->AppendSeparator(); file_menu->Append( OpenFile_Event, wxU(_("Open &File...")), - wxU(_(HELP_FILE)) ); + wxT(_(HELP_FILE))); file_menu->Append( OpenDisc_Event, wxU(_("Open &Disc...")), - wxU(_(HELP_DISC)) ); + wxT(_(HELP_DISC))); file_menu->Append( OpenNet_Event, wxU(_("Open &Network Stream...")), - wxU(_(HELP_NET)) ); + wxT(_(HELP_NET))); + #if 0 file_menu->Append( OpenSat_Event, wxU(_("Open &Satellite Stream...")), wxU(_(HELP_NET)) ); #endif -#if 0 file_menu->AppendSeparator(); - file_menu->Append( EjectDisc_Event, wxU(_("&Eject Disc")), - wxU(_(HELP_EJECT)) ); -#endif + file_menu->Append( Stream_Event, wxU(_("Streaming Wizard...")), + wxU(_(HELP_STREAM)) ); file_menu->AppendSeparator(); file_menu->Append( Exit_Event, wxU(_("E&xit")), wxU(_(HELP_EXIT)) ); @@ -379,6 +399,7 @@ void Interface::CreateOurMenuBar() void Interface::CreateOurToolBar() { #define HELP_STOP N_("Stop current playlist item") + #define HELP_PLAY N_("Play current playlist item") #define HELP_PAUSE N_("Pause current playlist item") #define HELP_PLO N_("Open playlist") @@ -395,6 +416,11 @@ void Interface::CreateOurToolBar() toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) ); + toolbar->AddTool( OpenFileSimple_Event, wxU(_("Simple open")), wxBitmap( file_xpm ), + wxU(_(HELP_SIMPLE)) ); + + toolbar->AddSeparator(); + toolbar->AddTool( OpenFile_Event, wxU(_("File")), wxBitmap( file_xpm ), wxU(_(HELP_FILE)) ); toolbar->AddTool( OpenDisc_Event, wxU(_("Disc")), wxBitmap( disc_xpm ), @@ -406,6 +432,12 @@ void Interface::CreateOurToolBar() wxU(_(HELP_SAT)) ); #endif toolbar->AddSeparator(); + + toolbar->AddTool( Stream_Event, wxU(_("Stream")), wxBitmap( stream_xpm ), + wxU(_(HELP_STREAM)) ); + + toolbar->AddSeparator(); + toolbar->AddTool( StopStream_Event, wxU(_("Stop")), wxBitmap( stop_xpm ), wxU(_(HELP_STOP)) ); toolbar->AddTool( PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ), @@ -489,7 +521,8 @@ void Interface::CreateOurExtraPanel() wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL ); /* Create static box to surround the adjust controls */ - adjust_box = new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) ); + wxStaticBox *adjust_box = + new wxStaticBox( extra_frame, -1, wxU(_("Image adjust")) ); /* Create the size for the frame */ wxStaticBoxSizer *adjust_sizer = @@ -549,13 +582,16 @@ void Interface::CreateOurExtraPanel() extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5); - /* Create static box to surround the other controls */ - other_box = new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) ); + /* Create sizer to surround the other controls */ + wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBox *video_box = + new wxStaticBox( extra_frame, -1, wxU(_("Video Options")) ); /* Create the sizer for the frame */ - wxStaticBoxSizer *other_sizer = - new wxStaticBoxSizer( other_box, wxVERTICAL ); - other_sizer->SetMinSize( -1, 50 ); + wxStaticBoxSizer *video_sizer = + new wxStaticBoxSizer( video_box, wxVERTICAL ); + video_sizer->SetMinSize( -1, 50 ); static const wxString ratio_array[] = { @@ -576,7 +612,30 @@ void Interface::CreateOurExtraPanel() ratio_sizer->Add( ratio_combo, 0, wxALL, 2 ); ratio_sizer->Layout(); - other_sizer->Add(ratio_sizer,0,wxALL,0 ); + video_sizer->Add( ratio_sizer , 0 , wxALL , 0 ); + video_sizer->Layout(); + + wxBoxSizer *visual_sizer = new wxBoxSizer( wxHORIZONTAL ); + + wxCheckBox *visual_checkbox = new wxCheckBox( extra_frame, Visual_Event, + wxU(_("Visualisation")) ); + + visual_sizer->Add( visual_checkbox, 0, wxEXPAND, 0); + visual_sizer->Layout(); + + wxStaticBox *audio_box = + new wxStaticBox( extra_frame, -1, wxU(_("Audio Options")) ); + /* Create the sizer for the frame */ + wxStaticBoxSizer *audio_sizer = + new wxStaticBoxSizer( audio_box, wxVERTICAL ); + audio_sizer->SetMinSize( -1, 50 ); + + audio_sizer->Add( visual_sizer, 0, wxALL, 0); + audio_sizer->Layout(); + + other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0); + other_sizer->Add( audio_sizer , 0 , wxALL | wxEXPAND , 0 ); + other_sizer->Layout(); extra_sizer->Add(other_sizer,0,wxBOTTOM,5); @@ -588,6 +647,12 @@ void Interface::CreateOurExtraPanel() extra_sizer->SetSizeHints(extra_frame); /* Write down initial values */ + + if( strstr( config_GetPsz( p_intf, "audio-filter" ), "visual" ) ) + { + visual_checkbox->SetValue(1); + } + psz_filters = config_GetPsz( p_intf, "filter" ); if(psz_filters == NULL) psz_filters=strdup(""); @@ -820,7 +885,7 @@ void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) ) msg.Printf( wxString(wxT("VLC media player " VERSION)) + wxU(_(" (wxWindows interface)\n\n")) + wxU(_("(C) 1996-2003 - the VideoLAN Team\n\n")) + - wxU( INTF_ABOUT_MSG ) + wxT("\n\n") + + wxU( vlc_wraptext(INTF_ABOUT_MSG,WRAPCOUNT,ISUTF8) ) + wxT("\n\n") + wxU(_("The VideoLAN team \n" "http://www.videolan.org/\n\n")) ); @@ -839,6 +904,8 @@ void Interface::OnShowDialog( wxCommandEvent& event ) case OpenFileSimple_Event: i_id = INTF_DIALOG_FILE_SIMPLE; break; + case OpenAdv_Event: + i_id = INTF_DIALOG_FILE; case OpenFile_Event: i_id = INTF_DIALOG_FILE; break; @@ -873,6 +940,14 @@ void Interface::OnShowDialog( wxCommandEvent& event ) } } + +void Interface::OnStream( wxCommandEvent& event ) +{ + StreamDialog *p_stream_dialog = new StreamDialog(p_intf,this); + p_stream_dialog->Show(); +} + + void Interface::OnExtra(wxCommandEvent& event) { if( b_extra == VLC_FALSE) @@ -995,6 +1070,18 @@ void Interface::OnRatio( wxCommandEvent& event ) config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() ); } +void Interface::OnEnableVisual(wxCommandEvent& event) +{ + if( event.IsChecked() ) + { + config_PutPsz( p_intf, "audio-filter", "visual" ); + } + else + { + config_PutPsz( p_intf, "audio-filter", "" ); + } +} + void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) ) { wxCommandEvent dummy; @@ -1157,7 +1244,7 @@ void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) ) vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); var_Set( p_playlist->p_input, "next-title", val ); vlc_mutex_unlock( &p_playlist->object_lock ); - vlc_object_release( p_playlist ); + vlc_object_release( p_playlist ); return; } vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock ); @@ -1205,13 +1292,13 @@ void Interface::TogglePlayButton( int i_playing_status ) if( i_playing_status == PLAYING_S ) { - GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Pause")), + GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Pause")), wxBitmap( pause_xpm ), wxNullBitmap, wxITEM_NORMAL, wxU(_(HELP_PAUSE)) ); } else { - GetToolBar()->InsertTool( 5, PlayStream_Event, wxU(_("Play")), + GetToolBar()->InsertTool( 8, PlayStream_Event, wxU(_("Play")), wxBitmap( play_xpm ), wxNullBitmap, wxITEM_NORMAL, wxU(_(HELP_PLAY)) ); } diff --git a/modules/gui/wxwindows/iteminfo.cpp b/modules/gui/wxwindows/iteminfo.cpp index 9a69dfbe1c..f870abda89 100644 --- a/modules/gui/wxwindows/iteminfo.cpp +++ b/modules/gui/wxwindows/iteminfo.cpp @@ -2,7 +2,7 @@ * iteminfo.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: iteminfo.cpp,v 1.2 2003/10/06 17:41:47 gbazin Exp $ + * $Id: iteminfo.cpp,v 1.3 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Clément Stenac * @@ -66,14 +66,15 @@ enum Name_Event, Author_Event, Enabled_Event, + New_Event, }; BEGIN_EVENT_TABLE(ItemInfoDialog, wxDialog) /* Button events */ EVT_BUTTON(wxID_OK, ItemInfoDialog::OnOk) EVT_BUTTON(wxID_CANCEL, ItemInfoDialog::OnCancel) - /* Events generated by the panels */ + EVT_BUTTON( New_Event, ItemInfoDialog::OnNewGroup) END_EVENT_TABLE() @@ -213,41 +214,60 @@ wxPanel *ItemInfoDialog::GroupPanel( wxWindow* parent ) { wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ); - wxStaticBox *panel_box = new wxStaticBox( panel, -1, wxU(_("Group Info")) ); - wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box, wxVERTICAL); - wxBoxSizer *subpanel_sizer; - group_subpanel = new wxPanel( panel, -1 ); - subpanel_sizer = new wxBoxSizer( wxVERTICAL) ; - enabled_checkbox = new wxCheckBox( group_subpanel, - -1, - wxU(_("Item enabled")) ); + -1, wxU(_("Item enabled")) ); enabled_checkbox->SetValue( p_item->b_enabled); wxStaticText *group_label = new wxStaticText( group_subpanel, -1, wxU(_("Group")) ); - group_spin = new wxSpinCtrl( group_subpanel, - -1 ); - group_spin->SetValue( p_item->i_group > 0 ? p_item->i_group : 0); + + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist == NULL ) + { + return NULL; + } + + group_combo = new wxComboBox( group_subpanel, -1, + wxT(""),wxDefaultPosition, wxDefaultSize, + 0, NULL, + wxCB_READONLY ); + + wxButton *newgroup_button = new wxButton( group_subpanel, New_Event, + wxT(_("New Group"))); + + for( int i=0; i< p_playlist->i_groups ; i++) + { + group_combo->Append( wxT( p_playlist->pp_groups[i]->psz_name)); + } + + vlc_object_release ( p_playlist ); subpanel_sizer->Add( enabled_checkbox, 0, wxALIGN_RIGHT| wxALIGN_CENTER_VERTICAL ); subpanel_sizer->Add( group_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); - subpanel_sizer->Add( group_spin, 0, wxALIGN_RIGHT ); + + wxBoxSizer *group_sizer = new wxBoxSizer( wxHORIZONTAL); + group_sizer->Add(group_combo, 0, wxALIGN_LEFT|wxRIGHT, 5); + group_sizer->Add( newgroup_button, 0, wxALIGN_RIGHT|wxLEFT, 5); + group_sizer->Layout(); + + subpanel_sizer->Add( group_sizer, 0, wxALIGN_RIGHT ); group_subpanel->SetSizerAndFit( subpanel_sizer ); /* Stuff everything into the main panel */ - panel_sizer->Add( group_subpanel, 0, + panel_sizer->Add( group_subpanel, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 ); panel->SetSizerAndFit( panel_sizer ); @@ -276,11 +296,20 @@ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) else if( b_old_enabled == VLC_TRUE && !enabled_checkbox->IsChecked() ) p_playlist->i_enabled --; + for (int i=0 ; i< p_playlist->i_groups ; i++) + { + if( !strcasecmp( p_playlist->pp_groups[i]->psz_name, + group_combo->GetValue() )) + { + p_item->i_group = p_playlist->pp_groups[i]->i_id; + break; + } + } + vlc_object_release( p_playlist ); } p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ; - p_item->i_group = group_spin->GetValue(); EndModal( wxID_OK ); } @@ -289,6 +318,18 @@ void ItemInfoDialog::OnCancel( wxCommandEvent& WXUNUSED(event) ) EndModal( wxID_CANCEL ); } -/****************************************************************************** - * Info panel event methods. - *****************************************************************************/ +void ItemInfoDialog::OnNewGroup( wxCommandEvent& WXUNUSED(event) ) +{ + NewGroup *p_newgroup = NULL; + + p_newgroup = new NewGroup( p_intf, this ); + + if( p_newgroup) + { + if( p_newgroup->ShowModal() == wxID_OK && p_newgroup->psz_name) + { + group_combo->Append( wxT( p_newgroup->psz_name)); + } + delete( p_newgroup ); + } +} diff --git a/modules/gui/wxwindows/open.cpp b/modules/gui/wxwindows/open.cpp index 29a8139080..58df0838bb 100644 --- a/modules/gui/wxwindows/open.cpp +++ b/modules/gui/wxwindows/open.cpp @@ -2,7 +2,7 @@ * open.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: open.cpp,v 1.38 2003/08/22 14:03:40 adn Exp $ + * $Id: open.cpp,v 1.39 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Gildas Bazin * @@ -164,8 +164,17 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, int i_access_method, int i_arg ): wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ) +{ + OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL ); +} + +OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, + int i_access_method, int i_arg, int _i_method ): + wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition, + wxDefaultSize, wxDEFAULT_FRAME_STYLE ) { /* Initializations */ + i_method = _i_method; p_intf = _p_intf; p_parent = _p_parent; SetIcon( *p_intf->p_sys->p_icon ); @@ -206,57 +215,70 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, wxU(_("Alternatively, you can build an MRL using one of the " "following predefined targets:")) ); - /* Create Stream Output checkox */ - wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 ); - sout_checkbox = new wxCheckBox( panel, SoutEnable_Event, - wxU(_("Stream output")) ); - sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) ); - sout_sizer->Add( sout_checkbox, 0, - wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); - sout_button = new wxButton( panel, SoutSettings_Event, - wxU(_("Settings...")) ); - sout_button->Disable(); - - char *psz_sout = config_GetPsz( p_intf, "sout" ); - if( psz_sout && *psz_sout ) - { - sout_checkbox->SetValue(TRUE); - sout_button->Enable(); - subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) ); - } - if( psz_sout ) free( psz_sout ); - - sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); - - /* Create Demux Dump checkox */ - wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL ); - demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event, - wxU(_("Capture input stream")) ); - demuxdump_checkbox->SetToolTip( - wxU(_("Capture the stream you are playing to a file")) ); - demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""), - wxDefaultPosition, wxDefaultSize, - wxTE_PROCESS_ENTER ); - demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event, - wxU(_("Browse...")) ); - - char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" ); - if( psz_demuxdump && *psz_demuxdump ) + wxFlexGridSizer *sout_sizer = NULL; + wxBoxSizer *demuxdump_sizer = NULL; + wxStaticLine *static_line = NULL; + + demuxdump_checkbox = NULL; + demuxdump_textctrl = NULL; + + if( i_method == OPEN_NORMAL ) { - demuxdump_textctrl->SetValue( wxU(psz_demuxdump) ); - } - if( psz_demuxdump ) free( psz_demuxdump ); + /* Create Stream Output checkox */ + sout_sizer = new wxFlexGridSizer( 2, 1, 20 ); - demuxdump_textctrl->Disable(); - demuxdump_button->Disable(); - demuxdump_sizer->Add( demuxdump_checkbox, 0, - wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); - demuxdump_sizer->Add( demuxdump_button, 0, - wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 ); - demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 ); - /* Separation */ - wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK ); + sout_checkbox = new wxCheckBox( panel, SoutEnable_Event, + wxU(_("Stream output")) ); + sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) ); + sout_sizer->Add( sout_checkbox, 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL ); + sout_button = new wxButton( panel, SoutSettings_Event, + wxU(_("Settings...")) ); + sout_button->Disable(); + + char *psz_sout = config_GetPsz( p_intf, "sout" ); + if( psz_sout && *psz_sout ) + { + sout_checkbox->SetValue(TRUE); + sout_button->Enable(); + subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) ); + } + if( psz_sout ) free( psz_sout ); + + sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | + wxALIGN_CENTER_VERTICAL ); + + /* Create Demux Dump checkox */ + demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL ); + demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event, + wxU(_("Capture input stream")) ); + demuxdump_checkbox->SetToolTip( + wxU(_("Capture the stream you are playing to a file")) ); + demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event, wxT(""), + wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER ); + demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event, + wxU(_("Browse...")) ); + + char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" ); + if( psz_demuxdump && *psz_demuxdump ) + { + demuxdump_textctrl->SetValue( wxU(psz_demuxdump) ); + } + if( psz_demuxdump ) free( psz_demuxdump ); + + demuxdump_textctrl->Disable(); + demuxdump_button->Disable(); + demuxdump_sizer->Add( demuxdump_checkbox, 0, + wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL ); + demuxdump_sizer->Add( demuxdump_button, 0, + wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 10 ); + demuxdump_sizer->Add( demuxdump_textctrl, 1, wxRIGHT, 10 ); + + /* Separation */ + static_line = new wxStaticLine( panel, wxID_OK ); + } /* Create the buttons */ wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) ); @@ -310,9 +332,13 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent, panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 ); panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 ); - panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 ); - panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 ); - panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); + if( i_method == OPEN_NORMAL) + { + panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 ); + panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT + | wxALL, 5 ); + panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); + } panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 ); panel_sizer->Layout(); panel->SetSizerAndFit( panel_sizer ); @@ -614,11 +640,13 @@ void OpenDialog::UpdateMRL( int i_access_method ) i_current_access_method = i_access_method; /* Check if the user asked for demuxdump */ - if( demuxdump_checkbox->GetValue() ) + if( demuxdump_checkbox ) { - demux = wxT("/demuxdump"); + if( demuxdump_checkbox->GetValue() ) + { + demux = wxT("/demuxdump"); + } } - switch( i_access_method ) { case FILE_ACCESS: @@ -713,6 +741,12 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 ); mrl_combo->SetSelection( mrl_combo->GetCount() - 1 ); + if( i_method == OPEN_STREAM ) + { + Hide(); + return; + } + /* Update the playlist */ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, @@ -979,12 +1013,15 @@ void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) ) void OpenDialog::OnSubsFileEnable( wxCommandEvent& event ) { subsfile_button->Enable( event.GetInt() != 0 ); - if( event.GetInt() && demuxdump_checkbox->IsChecked() ) + if( demuxdump_checkbox ) { - demuxdump_checkbox->SetValue( 0 ); - wxCommandEvent event = wxCommandEvent( wxEVT_NULL ); - event.SetInt( 0 ); - OnDemuxDumpEnable( event ); + if( event.GetInt() && demuxdump_checkbox->IsChecked() ) + { + demuxdump_checkbox->SetValue( 0 ); + wxCommandEvent event = wxCommandEvent( wxEVT_NULL ); + event.SetInt( 0 ); + OnDemuxDumpEnable( event ); + } } } diff --git a/modules/gui/wxwindows/playlist.cpp b/modules/gui/wxwindows/playlist.cpp index 6038da371d..028caa18ca 100644 --- a/modules/gui/wxwindows/playlist.cpp +++ b/modules/gui/wxwindows/playlist.cpp @@ -2,7 +2,7 @@ * playlist.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: playlist.cpp,v 1.22 2003/10/06 16:23:30 zorglub Exp $ + * $Id: playlist.cpp,v 1.23 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Olivier Teulière * @@ -49,12 +49,17 @@ enum /* menu items */ AddFile_Event = 1, AddMRL_Event, - Sort_Event, - RSort_Event, Close_Event, Open_Event, Save_Event, + SortTitle_Event, + RSortTitle_Event, + SortAuthor_Event, + RSortAuthor_Event, + SortGroup_Event, + RSortGroup_Event, + EnableSelection_Event, DisableSelection_Event, @@ -65,8 +70,11 @@ enum Repeat_Event, SelectAll_Event, - En_Dis_Event, + EnableGroup_Event, + DisableGroup_Event, + Up_Event, + Down_Event, Infos_Event, SearchText_Event, @@ -80,11 +88,17 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame) /* Menu events */ EVT_MENU(AddFile_Event, Playlist::OnAddFile) EVT_MENU(AddMRL_Event, Playlist::OnAddMRL) - EVT_MENU(Sort_Event, Playlist::OnSort) - EVT_MENU(RSort_Event, Playlist::OnRSort) EVT_MENU(Close_Event, Playlist::OnClose) EVT_MENU(Open_Event, Playlist::OnOpen) EVT_MENU(Save_Event, Playlist::OnSave) + + EVT_MENU(SortTitle_Event, Playlist::OnSort) + EVT_MENU(RSortTitle_Event, Playlist::OnSort) + EVT_MENU(SortAuthor_Event, Playlist::OnSort) + EVT_MENU(RSortAuthor_Event, Playlist::OnSort) + EVT_MENU(SortGroup_Event, Playlist::OnSort) + EVT_MENU(RSortGroup_Event, Playlist::OnSort) + EVT_MENU(EnableSelection_Event, Playlist::OnEnableSelection) EVT_MENU(DisableSelection_Event, Playlist::OnDisableSelection) EVT_MENU(InvertSelection_Event, Playlist::OnInvertSelection) @@ -95,16 +109,21 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame) EVT_CHECKBOX(Repeat_Event, Playlist::OnRepeat) EVT_CHECKBOX(Loop_Event, Playlist::OnLoop) + EVT_MENU(EnableGroup_Event, Playlist::OnEnDis) + EVT_MENU(DisableGroup_Event, Playlist::OnEnDis) + /* Listview events */ EVT_LIST_ITEM_ACTIVATED(ListView_Event, Playlist::OnActivateItem) EVT_LIST_KEY_DOWN(ListView_Event, Playlist::OnKeyDown) /* Button events */ EVT_BUTTON( Search_Event, Playlist::OnSearch) - EVT_BUTTON( En_Dis_Event, Playlist::OnEnDis) EVT_BUTTON( Save_Event, Playlist::OnSave) EVT_BUTTON( Infos_Event, Playlist::OnInfos) + EVT_BUTTON( Up_Event, Playlist::OnUp) + EVT_BUTTON( Down_Event, Playlist::OnDown) + EVT_TEXT(SearchText_Event, Playlist::OnSearchTextChange) /* Special events : we don't want to destroy the window when the user @@ -112,6 +131,13 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame) EVT_CLOSE(Playlist::OnClose) END_EVENT_TABLE() + +/* Event Table for the Newgroup class */ +BEGIN_EVENT_TABLE(NewGroup, wxDialog) + EVT_BUTTON( wxID_OK, NewGroup::OnOk) + EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel) +END_EVENT_TABLE() + /***************************************************************************** * Constructor. *****************************************************************************/ @@ -124,6 +150,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): p_intf = _p_intf; vlc_value_t val; i_update_counter = 0; + i_sort_mode = MODE_NONE; b_need_update = VLC_FALSE; vlc_mutex_init( p_intf, &lock ); SetIcon( *p_intf->p_sys->p_icon ); @@ -139,13 +166,23 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): wxMenu *manage_menu = new wxMenu; manage_menu->Append( AddFile_Event, wxU(_("&Simple Add...")) ); manage_menu->Append( AddMRL_Event, wxU(_("&Add MRL...")) ); - manage_menu->Append( Sort_Event, wxU(_("&Sort")) ); - manage_menu->Append( RSort_Event, wxU(_("&Reverse Sort")) ); + manage_menu->AppendSeparator(); manage_menu->Append( Open_Event, wxU(_("&Open Playlist...")) ); manage_menu->Append( Save_Event, wxU(_("&Save Playlist...")) ); manage_menu->AppendSeparator(); manage_menu->Append( Close_Event, wxU(_("&Close")) ); + /* Create our "Sort" menu */ + wxMenu *sort_menu = new wxMenu; + sort_menu->Append( SortTitle_Event, wxU(_("&Sort by title")) ); + sort_menu->Append( RSortTitle_Event, wxU(_("&Reverse sort by title")) ); + sort_menu->AppendSeparator(); + sort_menu->Append( SortAuthor_Event, wxU(_("&Sort by author")) ); + sort_menu->Append( RSortAuthor_Event, wxU(_("&Reverse sort by author")) ); + sort_menu->AppendSeparator(); + sort_menu->Append( SortGroup_Event, wxU(_("&Sort by group")) ); + sort_menu->Append( RSortGroup_Event, wxU(_("&Reverse sort by group")) ); + /* Create our "Selection" menu */ wxMenu *selection_menu = new wxMenu; selection_menu->Append( EnableSelection_Event, wxU(_("&Enable")) ); @@ -155,39 +192,30 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): selection_menu->Append( DeleteSelection_Event, wxU(_("&Delete")) ); selection_menu->Append( SelectAll_Event, wxU(_("&Select All")) ); + /* Create our "Group" menu */ + wxMenu *group_menu = new wxMenu; + group_menu->Append( EnableGroup_Event, wxU(_("&Enable all group items")) ); + group_menu->Append( DisableGroup_Event, + wxU(_("&Disable all group items")) ); + /* Append the freshly created menus to the menu bar */ wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE ); menubar->Append( manage_menu, wxU(_("&Manage")) ); + menubar->Append( sort_menu, wxU(_("S&ort")) ); menubar->Append( selection_menu, wxU(_("&Selection")) ); + menubar->Append( group_menu, wxU(_("&Groups")) ); /* Attach the menu bar to the frame */ SetMenuBar( menubar ); + /* Create a panel to put everything in */ wxPanel *playlist_panel = new wxPanel( this, -1 ); playlist_panel->SetAutoLayout( TRUE ); - /* Create the listview */ - /* FIXME: the given size is arbitrary, and prevents us from resizing - * 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 - * playlist window is ridiculously small */ - listview = new wxListView( playlist_panel, ListView_Event, - wxDefaultPosition, wxSize( 305, 300 ), - wxLC_REPORT | wxSUNKEN_BORDER ); - listview->InsertColumn( 0, wxU(_("Url")) ); - #if 0 - listview->InsertColumn( 1, wxU(_("Duration")) ); - #endif - listview->SetColumnWidth( 0, 300 ); - #if 0 - listview->SetColumnWidth( 1, 100 ); - #endif - /* Create the Random checkbox */ wxCheckBox *random_checkbox = new wxCheckBox( playlist_panel, Random_Event, wxU(_("Random")) ); - var_Get( p_intf, "random", &val); vlc_bool_t b_random = val.b_bool; random_checkbox->SetValue( b_random == VLC_FALSE ? 0 : 1); @@ -195,7 +223,6 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): /* Create the Loop Checkbox */ wxCheckBox *loop_checkbox = new wxCheckBox( playlist_panel, Loop_Event, wxU(_("Loop")) ); - var_Get( p_intf, "loop", &val ); int b_loop = val.b_bool ; loop_checkbox->SetValue( b_loop ); @@ -203,7 +230,6 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): /* Create the Repeat one checkbox */ wxCheckBox *repeat_checkbox = new wxCheckBox( playlist_panel, Repeat_Event, wxU(_("Repeat one")) ); - var_Get( p_intf, "repeat", &val ); int b_repeat = val.b_bool ; repeat_checkbox->SetValue( b_repeat ); @@ -218,17 +244,45 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): search_button = new wxButton( playlist_panel, Search_Event, wxU(_("Search")) ); - wxButton *en_dis_button = - new wxButton( playlist_panel, En_Dis_Event, wxU(_("Enable/Disable Group") ) ); + /* Create the listview */ + /* FIXME: the given size is arbitrary, and prevents us from resizing + * 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 + * playlist window is ridiculously small */ + listview = new wxListView( playlist_panel, ListView_Event, + wxDefaultPosition, wxSize( 500, 300 ), + wxLC_REPORT | wxSUNKEN_BORDER ); + listview->InsertColumn( 0, wxU(_("Name")) ); + #if 0 + listview->InsertColumn( 1, wxU(_("Duration")) ); + #endif + listview->InsertColumn( 1, wxU(_("Author")) ); + listview->InsertColumn( 2, wxU(_("Group")) ); + listview->SetColumnWidth( 0, 270 ); + listview->SetColumnWidth( 1, 150 ); + listview->SetColumnWidth( 2, 80 ); + + /* Create the Up-Down buttons */ + wxButton *up_button = + new wxButton( playlist_panel, Up_Event, wxU(_("Up") ) ); + + wxButton *down_button = + new wxButton( playlist_panel, Down_Event, wxU(_("Down") ) ); + + /* Create the iteminfo button */ wxButton *iteminfo_button = new wxButton( playlist_panel, Infos_Event, wxU(_("Item Infos") ) ); + /* Place everything in sizers */ wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); - button_sizer->Add( en_dis_button, 0, wxALIGN_CENTER|wxRIGHT, 5); button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT , 5); button_sizer->Layout(); + 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(); wxBoxSizer *checkbox_sizer = new wxBoxSizer( wxHORIZONTAL ); checkbox_sizer->Add( random_checkbox, 0, @@ -237,28 +291,30 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): wxEXPAND|wxALIGN_RIGHT, 5); checkbox_sizer->Add( repeat_checkbox, 0, wxEXPAND|wxALIGN_RIGHT, 5); - checkbox_sizer->Layout(); wxBoxSizer *search_sizer = new wxBoxSizer( wxHORIZONTAL ); - search_sizer->Add( search_text, 0, wxALL|wxALIGN_CENTER, 5); - search_sizer->Add( search_button, 0, wxALL|wxALIGN_CENTER, 5); - + search_sizer->Add( search_text, 0, wxRIGHT|wxALIGN_CENTER, 3); + search_sizer->Add( search_button, 0, wxLEFT|wxALIGN_CENTER, 3); search_sizer->Layout(); - wxBoxSizer *bottom_sizer = new wxBoxSizer( wxVERTICAL ); - bottom_sizer->Add( checkbox_sizer, 0, wxALL|wxALIGN_CENTER, 5 ); - bottom_sizer->Add( button_sizer , 0, wxALL|wxALIGN_CENTER, 5 ); + /* The top and bottom sizers */ + wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL ); + top_sizer->Add( checkbox_sizer, 0, wxLEFT|wxRIGHT|wxALIGN_LEFT, 4 ); + top_sizer->Add( search_sizer, 0, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 4 ); + top_sizer->Layout(); + wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL ); + bottom_sizer->Add( updown_sizer, 0, wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4); + bottom_sizer->Add( button_sizer , 0, wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 ); bottom_sizer->Layout(); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); + panel_sizer->Add( top_sizer, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( listview, 1, wxEXPAND | wxALL, 5 ); - - panel_sizer->Add( search_sizer, 0, wxALIGN_CENTRE ); - panel_sizer->Add( bottom_sizer, 0 , wxALIGN_CENTRE); + panel_sizer->Add( bottom_sizer, 0 , wxEXPAND | wxALL, 5); panel_sizer->Layout(); playlist_panel->SetSizerAndFit( panel_sizer ); @@ -279,7 +335,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): return; } - /* We want to be noticed of playlit changes */ + /* We want to be noticed of playlist changes */ var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this ); vlc_object_release( p_playlist ); @@ -303,6 +359,9 @@ Playlist::~Playlist() vlc_object_release( p_playlist ); } +/********************************************************************** + * Rebuild the playlist + **********************************************************************/ void Playlist::Rebuild() { playlist_t *p_playlist = @@ -313,6 +372,8 @@ void Playlist::Rebuild() return; } + int i_focused = listview->GetFocusedItem(); + /* Clear the list... */ listview->DeleteAllItems(); @@ -322,6 +383,10 @@ void Playlist::Rebuild() { wxString filename = wxU(p_playlist->pp_items[i]->psz_name); listview->InsertItem( i, filename ); + listview->SetItem( i, 1, wxU(p_playlist->pp_items[i]->psz_author)); + listview->SetItem( i, 2, + wxU(playlist_FindGroup(p_playlist,p_playlist-> + pp_items[i]->i_group))); if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) { wxListItem listitem; @@ -343,7 +408,15 @@ void Playlist::Rebuild() listitem.SetTextColour( *wxRED ); listview->SetItem( listitem ); - listview->Focus( p_playlist->i_index ); + if( i_focused ) + { + listview->Focus( i_focused ); + listview->Select( i_focused ); + } + else + { + listview->Focus( p_playlist->i_index ); + } vlc_object_release( p_playlist ); } @@ -365,12 +438,15 @@ void Playlist::UpdatePlaylist() vlc_mutex_lock( &lock ); if( this->b_need_update ) { - b_need_update = VLC_TRUE; + b_need_update =VLC_TRUE; this->b_need_update = VLC_FALSE; } vlc_mutex_unlock( &lock ); - if( b_need_update ) Rebuild(); + if( b_need_update ) + { + Rebuild(); + } /* Updating the playing status every 0.5s is enough */ if( i_update_counter % 5 ) return; @@ -384,6 +460,7 @@ void Playlist::UpdatePlaylist() } /* Update the colour of items */ + vlc_mutex_lock( &p_playlist->object_lock ); if( p_intf->p_sys->i_playing != p_playlist->i_index ) { @@ -401,7 +478,6 @@ void Playlist::UpdatePlaylist() p_intf->p_sys->i_playing = p_playlist->i_index; } vlc_mutex_unlock( &p_playlist->object_lock ); - vlc_object_release( p_playlist ); } @@ -489,7 +565,10 @@ void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) ) #endif } -void Playlist::OnSort( wxCommandEvent& WXUNUSED(event) ) +/******************************************************************** + * Move functions + ********************************************************************/ +void Playlist::OnUp( wxCommandEvent& event) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, @@ -499,16 +578,28 @@ void Playlist::OnSort( wxCommandEvent& WXUNUSED(event) ) return; } - playlist_Sort( p_playlist , 0 ); - + /* We use the first selected item, so find it */ + long i_item = -1; + i_item = listview->GetNextItem(i_item, + wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED); + if( i_item > 0 && i_item < p_playlist->i_size ) + { + playlist_Move( p_playlist , i_item, i_item - 1); + if( i_item > 1 ) + { + listview->Focus( i_item - 1 ); + } + else + { + listview->Focus(0); + } + } vlc_object_release( p_playlist ); - - Rebuild(); - return; } -void Playlist::OnRSort( wxCommandEvent& WXUNUSED(event) ) +void Playlist::OnDown( wxCommandEvent& event) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, @@ -518,8 +609,53 @@ void Playlist::OnRSort( wxCommandEvent& WXUNUSED(event) ) return; } - playlist_Sort( p_playlist , 1 ); + /* We use the first selected item, so find it */ + long i_item = -1; + i_item = listview->GetNextItem(i_item, + wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED); + if( i_item >= 0 && i_item < p_playlist->i_size - 1 ) + { + playlist_Move( p_playlist , i_item, i_item + 2 ); + listview->Focus( i_item + 1 ); + } + vlc_object_release( p_playlist ); + return; +} +/******************************************************************** + * Sorting functions + ********************************************************************/ +void Playlist::OnSort( wxCommandEvent& event ) +{ + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist == NULL ) + { + return; + } + switch( event.GetId() ) + { + case SortTitle_Event: + playlist_SortTitle( p_playlist , 0 ); + break; + case RSortTitle_Event: + playlist_SortTitle( p_playlist , 1 ); + break; + case SortAuthor_Event: + playlist_SortAuthor(p_playlist , 0 ); + break; + case RSortAuthor_Event: + playlist_SortAuthor( p_playlist , 1 ); + break; + case SortGroup_Event: + playlist_SortGroup( p_playlist , 0 ); + break; + case RSortGroup_Event: + playlist_SortGroup( p_playlist , 1 ); + break; + } vlc_object_release( p_playlist ); Rebuild(); @@ -527,6 +663,9 @@ void Playlist::OnRSort( wxCommandEvent& WXUNUSED(event) ) return; } +/********************************************************************** + * Search functions + **********************************************************************/ void Playlist::OnSearchTextChange( wxCommandEvent& WXUNUSED(event) ) { search_button->SetDefault(); @@ -540,7 +679,7 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) int i_first = 0 ; int i_item = -1; - for( i_current = 0 ; i_current <= listview->GetItemCount() ; i_current++ ) + for( i_current = 0 ; i_current <= listview->GetItemCount() ; i_current++ ) { if( listview->GetItemState( i_current, wxLIST_STATE_SELECTED) == wxLIST_STATE_SELECTED ) @@ -550,7 +689,7 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) } } - for ( i_current = i_first + 1; i_current <= listview->GetItemCount() ; + for ( i_current = i_first + 1; i_current <= listview->GetItemCount() ; i_current++ ) { wxListItem listitem; @@ -566,7 +705,7 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) { listview->Select( item, FALSE ); } - + wxListItem listitem; listitem.SetId(i_item); listitem.m_state = wxLIST_STATE_SELECTED; @@ -575,6 +714,9 @@ void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) ) } +/********************************************************************** + * Selection functions + **********************************************************************/ void Playlist::OnInvertSelection( wxCommandEvent& WXUNUSED(event) ) { for( long item = 0; item < listview->GetItemCount(); item++ ) @@ -639,6 +781,17 @@ void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) ) Rebuild(); } +void Playlist::OnSelectAll( wxCommandEvent& WXUNUSED(event) ) +{ + for( long item = 0; item < listview->GetItemCount(); item++ ) + { + listview->Select( item, TRUE ); + } +} + +/********************************************************************** + * Playlist mode functions + **********************************************************************/ void Playlist::OnRandom( wxCommandEvent& event ) { vlc_value_t val; @@ -683,13 +836,7 @@ void Playlist::OnRepeat ( wxCommandEvent& event ) vlc_object_release( p_playlist ); } -void Playlist::OnSelectAll( wxCommandEvent& WXUNUSED(event) ) -{ - for( long item = 0; item < listview->GetItemCount(); item++ ) - { - listview->Select( item, TRUE ); - } -} + void Playlist::OnActivateItem( wxListEvent& event ) { @@ -745,8 +892,7 @@ void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) ) vlc_object_release( p_playlist ); } - -void Playlist::OnEnDis( wxCommandEvent& WXUNUSED(event) ) +void Playlist::OnEnDis( wxCommandEvent& event ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, @@ -763,17 +909,23 @@ void Playlist::OnEnDis( wxCommandEvent& WXUNUSED(event) ) if( i_item >= 0 && i_item < p_playlist->i_size ) { - if( p_playlist->pp_items[i_item]->b_enabled == VLC_TRUE) - playlist_DisableGroup( p_playlist , + switch( event.GetId() ) + { + case EnableGroup_Event: + playlist_EnableGroup( p_playlist , p_playlist->pp_items[i_item]->i_group ); - else - playlist_EnableGroup( p_playlist , + break; + case DisableGroup_Event: + playlist_DisableGroup( p_playlist , p_playlist->pp_items[i_item]->i_group ); + break; + } Rebuild(); } vlc_object_release( p_playlist ); } + /***************************************************************************** * PlaylistChanged: callback triggered by the intf-change playlist variable * We don't rebuild the playlist directly here because we don't want the @@ -788,3 +940,81 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable, vlc_mutex_unlock( &p_playlist_dialog->lock ); return VLC_SUCCESS; } + + +/*************************************************************************** + * NewGroup + ***************************************************************************/ +NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ): + wxDialog( _p_parent, -1, wxU(_("New Group")), wxDefaultPosition, + wxDefaultSize, wxDEFAULT_FRAME_STYLE ) +{ + /* Initializations */ + p_intf = _p_intf; + psz_name = NULL; + SetIcon( *p_intf->p_sys->p_icon ); + + /* Create a panel to put everything in*/ + wxPanel *panel = new wxPanel( this, -1 ); + panel->SetAutoLayout( TRUE ); + + wxStaticText *group_label = + new wxStaticText( panel , -1, + wxU(_("Enter the name for the new group"))); + + groupname = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition, + wxSize(80,27),wxTE_PROCESS_ENTER); + + wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) ); + ok_button->SetDefault(); + wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, + wxU(_("Cancel")) ); + + wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); + + button_sizer->Add( ok_button, 0, wxALL, 5 ); + button_sizer->Add( cancel_button, 0, wxALL, 5 ); + button_sizer->Layout(); + + wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); + panel_sizer->Add( group_label, 0, wxEXPAND | wxALL, 5 ); + panel_sizer->Add( groupname, 0, wxEXPAND | wxALL, 5 ); + panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 ); + panel_sizer->Layout(); + + panel->SetSizerAndFit( panel_sizer ); + + wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); + main_sizer->Add( panel, 1, wxEXPAND, 0 ); + main_sizer->Layout(); + SetSizerAndFit( main_sizer ); +} + +NewGroup::~NewGroup() +{ +} + +void NewGroup::OnOk( wxCommandEvent& event ) +{ + psz_name = strdup( groupname->GetLineText(0).mb_str() ); + + playlist_t * p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + + if( p_playlist ) + { + if( !playlist_CreateGroup( p_playlist, psz_name ) ) + { + psz_name = NULL; + } + } + + vlc_object_release( p_playlist ); + EndModal( wxID_OK ); +} + +void NewGroup::OnCancel( wxCommandEvent& WXUNUSED(event) ) +{ + EndModal( wxID_CANCEL ); +} diff --git a/modules/gui/wxwindows/preferences.cpp b/modules/gui/wxwindows/preferences.cpp index 869826b10c..342da0433f 100644 --- a/modules/gui/wxwindows/preferences.cpp +++ b/modules/gui/wxwindows/preferences.cpp @@ -2,7 +2,7 @@ * preferences.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: preferences.cpp,v 1.39 2003/10/29 01:33:27 gbazin Exp $ + * $Id: preferences.cpp,v 1.40 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Gildas Bazin * @@ -173,7 +173,7 @@ END_EVENT_TABLE() *****************************************************************************/ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf, wxWindow *p_parent) : wxFrame( p_parent, -1, wxU(_("Preferences")), wxDefaultPosition, - wxSize(700,450), wxDEFAULT_FRAME_STYLE ) + wxSize(830,450), wxDEFAULT_FRAME_STYLE ) { /* Initializations */ p_intf = _p_intf; @@ -305,6 +305,8 @@ static char * GetCapabilityHelp( char *psz_capability, int i_type) return i_type == 1 ? AUDIO_FILTER_TITLE : AUDIO_FILTER_HELP; if( !strcasecmp(psz_capability,"audio output") ) return i_type == 1 ? AOUT_TITLE : AOUT_HELP; + if( !strcasecmp(psz_capability,"audio encoder") ) + return i_type == 1 ? AOUT_ENC_TITLE : AOUT_ENC_HELP; if( !strcasecmp(psz_capability,"chroma") ) return i_type == 1 ? CHROMA_TITLE : CHROMA_HELP; if( !strcasecmp(psz_capability,"decoder") ) diff --git a/modules/gui/wxwindows/wxwindows.h b/modules/gui/wxwindows/wxwindows.h index 35e8e0004c..ddecc9c94a 100644 --- a/modules/gui/wxwindows/wxwindows.h +++ b/modules/gui/wxwindows/wxwindows.h @@ -2,7 +2,7 @@ * wxwindows.h: private wxWindows interface description ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: wxwindows.h,v 1.65 2003/10/14 22:41:41 gbazin Exp $ + * $Id: wxwindows.h,v 1.66 2003/10/29 17:32:54 zorglub Exp $ * * Authors: Gildas Bazin * @@ -73,6 +73,14 @@ class FileInfo; #define WRAPCOUNT 80 +#define OPEN_NORMAL 0 +#define OPEN_STREAM 1 + +#define MODE_NONE 0 +#define MODE_GROUP 1 +#define MODE_AUTHOR 2 +#define MODE_TITLE 3 + wxArrayString SeparateEntries( wxString ); /***************************************************************************** @@ -185,6 +193,7 @@ private: void OnOpenNet( wxCommandEvent& event ); void OnOpenSat( wxCommandEvent& event ); void OnOpenV4L( wxCommandEvent& event ); + void OnStream( wxCommandEvent& event ); void OnExtra( wxCommandEvent& event ); void OnShowDialog( wxCommandEvent& event ); void OnPlayStream( wxCommandEvent& event ); @@ -202,6 +211,7 @@ private: void OnSaturationUpdate( wxScrollEvent& event ); void OnRatio( wxCommandEvent& event ); + void OnEnableVisual( wxCommandEvent& event ); void OnMenuOpen( wxMenuEvent& event ); @@ -229,6 +239,8 @@ private: vlc_bool_t b_misc_menu; }; +class StreamDialog; + /* Dialogs Provider */ class DialogsProvider: public wxFrame { @@ -246,6 +258,7 @@ private: void OnMessages( wxCommandEvent& event ); void OnFileInfo( wxCommandEvent& event ); void OnPreferences( wxCommandEvent& event ); + void OnStreamDialog( wxCommandEvent& event ); void OnOpenFileGeneric( wxCommandEvent& event ); void OnOpenFileSimple( wxCommandEvent& event ); @@ -271,6 +284,7 @@ public: Playlist *p_playlist_dialog; Messages *p_messages_dialog; FileInfo *p_fileinfo_dialog; + StreamDialog *p_stream_dialog; wxFrame *p_prefs_dialog; wxFileDialog *p_file_generic_dialog; }; @@ -284,7 +298,11 @@ class OpenDialog: public wxFrame public: /* Constructor */ OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent, - int i_access_method, int i_arg = 0 ); + int i_access_method, int i_arg = 0 ); + + /* Extended Contructor */ + OpenDialog( intf_thread_t *p_intf, wxWindow *p_parent, + int i_access_method, int i_arg = 0 , int _i_method = 0 ); virtual ~OpenDialog(); int Show(); @@ -344,6 +362,7 @@ private: wxWindow *p_parent; int i_current_access_method; + int i_method; /* Normal or for the stream dialog ? */ wxComboBox *mrl_combo; wxNotebook *notebook; @@ -610,6 +629,36 @@ private: wxWindow *p_parent; }; +/* Stream */ +class StreamDialog: public wxFrame +{ +public: + /* Constructor */ + StreamDialog( intf_thread_t *p_intf, wxWindow *p_parent ); + virtual ~StreamDialog(); + +private: + void OnClose( wxCommandEvent& event ); + void OnOpen( wxCommandEvent& event ); + void OnSout( wxCommandEvent& event ); + void OnStart( wxCommandEvent& event ); + + DECLARE_EVENT_TABLE(); + + intf_thread_t *p_intf; + + wxStaticText *step2_label; + wxStaticText *step3_label; + wxButton *sout_button; + wxButton *start_button; + wxArrayString mrl; + wxArrayString sout_mrl; + OpenDialog *p_open_dialog; + SoutDialog *p_sout_dialog; +}; + + + /* Preferences Dialog */ class PrefsTreeCtrl; class PrefsDialog: public wxFrame @@ -668,6 +717,7 @@ private: /* Playlist */ class ItemInfoDialog; +class NewGroup; class Playlist: public wxFrame { public: @@ -687,8 +737,6 @@ private: /* Event handlers (these functions should _not_ be virtual) */ void OnAddFile( wxCommandEvent& event ); void OnAddMRL( wxCommandEvent& event ); - void OnSort( wxCommandEvent& event ); - void OnRSort( wxCommandEvent& event ); void OnClose( wxCommandEvent& event ); void OnSearch( wxCommandEvent& event ); void OnEnDis( wxCommandEvent& event ); @@ -696,6 +744,12 @@ private: void OnSearchTextChange( wxCommandEvent& event ); void OnOpen( wxCommandEvent& event ); void OnSave( wxCommandEvent& event ); + + void OnSort( wxCommandEvent& event ); + + void OnUp( wxCommandEvent& event); + void OnDown( wxCommandEvent& event); + void OnEnableSelection( wxCommandEvent& event ); void OnDisableSelection( wxCommandEvent& event ); void OnInvertSelection( wxCommandEvent& event ); @@ -706,6 +760,8 @@ private: void OnLoop ( wxCommandEvent& event ); void OnActivateItem( wxListEvent& event ); void OnKeyDown( wxListEvent& event ); + void OnNewGroup( wxCommandEvent& event ); + void Rebuild(); wxTextCtrl *search_text; @@ -717,7 +773,34 @@ private: intf_thread_t *p_intf; wxListView *listview; + wxTreeCtrl *treeview; int i_update_counter; + int i_sort_mode; +}; + + +class NewGroup: public wxDialog +{ +public: + /* Constructor */ + NewGroup( intf_thread_t *p_intf, wxWindow *p_parent ); + virtual ~NewGroup(); + +private: + + /* Event handlers (these functions should _not_ be virtual) */ + void OnOk( wxCommandEvent& event ); + void OnCancel( wxCommandEvent& event ); + + DECLARE_EVENT_TABLE(); + + intf_thread_t *p_intf; + wxTextCtrl *groupname; + +protected: + friend class Playlist; + friend class ItemInfoDialog; + char *psz_name; }; @@ -739,6 +822,7 @@ private: /* Event handlers (these functions should _not_ be virtual) */ void OnOk( wxCommandEvent& event ); void OnCancel( wxCommandEvent& event ); + void OnNewGroup( wxCommandEvent& event ); DECLARE_EVENT_TABLE(); @@ -758,7 +842,8 @@ private: wxTextCtrl *author_text; wxCheckBox *enabled_checkbox; - wxSpinCtrl *group_spin; + wxComboBox *group_combo; + int ids_array[100]; }; @@ -783,6 +868,7 @@ private: }; + #if !defined(__WXX11__) /* Drag and Drop class */ class DragAndDrop: public wxFileDropTarget diff --git a/modules/misc/sap.c b/modules/misc/sap.c index 98c8b54e89..15e0e441de 100644 --- a/modules/misc/sap.c +++ b/modules/misc/sap.c @@ -2,7 +2,7 @@ * sap.c : SAP interface module ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: sap.c,v 1.27 2003/10/13 05:48:08 zorglub Exp $ + * $Id: sap.c,v 1.28 2003/10/29 17:32:55 zorglub Exp $ * * Authors: Arnaud Schauly * Clément Stenac @@ -115,6 +115,12 @@ static void free_sd( sess_descr_t * ); /* Detect multicast addresses */ static int ismult( char * ); +/* Our custom structure */ +struct intf_sys_t +{ + int i_group; +}; + /* The struct that contains sdp informations */ struct sess_descr_t { @@ -160,9 +166,6 @@ struct attr_descr_t #define SAP_IPV6_LONGTEXT N_("Set this if you want SAP to listen for IPv6 announces") #define SAP_SCOPE_TEXT N_("IPv6 SAP scope") #define SAP_SCOPE_LONGTEXT N_("Sets the scope for IPv6 announces (default is 8)") -#define SAP_GROUP_ID_TEXT N_("SAP Playlist group ID") -#define SAP_GROUP_ID_LONGTEXT N_("Sets the default group ID in which" \ - "SAP items are put" ) vlc_module_begin(); add_category_hint( N_("SAP"), NULL, VLC_TRUE ); @@ -178,9 +181,6 @@ vlc_module_begin(); add_string( "sap-ipv6-scope", "8" , NULL, SAP_SCOPE_TEXT, SAP_SCOPE_LONGTEXT, VLC_TRUE); - add_integer( "sap-group-id", 42, NULL, - SAP_GROUP_ID_TEXT, SAP_GROUP_ID_LONGTEXT, VLC_TRUE); - set_description( _("SAP interface") ); set_capability( "interface", 0 ); set_callbacks( Activate, NULL); @@ -221,6 +221,8 @@ static void Run( intf_thread_t *p_intf ) module_t *p_network; network_socket_t socket_desc; + playlist_t *p_playlist; + playlist_group_t *p_group; if( sap_ipv4 == -1 || sap_ipv6 == -1 || sap_ipv6_scope == NULL ) { @@ -228,6 +230,22 @@ static void Run( intf_thread_t *p_intf ) return; } + + p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); + if( !p_intf->p_sys ) + { + msg_Err( p_intf, "Out of memory !"); + return VLC_EGENERIC; + } + /* Create our playlist group */ + p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + p_group = playlist_CreateGroup( p_playlist , "SAP" ); + p_intf->p_sys->i_group = p_group->i_id; + + vlc_object_release( p_playlist ); + /* Prepare IPv4 Networking */ if ( sap_ipv4 == 1) { @@ -487,7 +505,7 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) if( p_item ) { - p_item->i_group = config_GetInt( p_intf, "sap-group-id" ); + p_item->i_group = p_intf->p_sys->i_group; p_item->b_enabled = VLC_TRUE; p_item->psz_author = NULL; p_playlist = vlc_object_find( p_intf, @@ -784,8 +802,18 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet ) *psz_eof = '\0'; sd->pp_attributes[sd->i_attributes]->psz_field = strdup( p_packet ); - sd->pp_attributes[sd->i_attributes]->psz_value = + if( psz_eof + 1 ) + { + sd->pp_attributes[sd->i_attributes]->psz_value = strdup( ++psz_eof ); + } + else + { + if( sd->pp_attributes[sd->i_attributes]->psz_field ) + free( sd->pp_attributes[sd->i_attributes] + ->psz_field ); + break; + } for( i=0 ; i< strlen(sd->pp_attributes[sd->i_attributes]->psz_value) ; i++ ) diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index f4c877527e..27ea9cc2bb 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -2,7 +2,7 @@ * playlist.c : Playlist management functions ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: playlist.c,v 1.61 2003/10/20 22:28:26 gbazin Exp $ + * $Id: playlist.c,v 1.62 2003/10/29 17:32:55 zorglub Exp $ * * Authors: Samuel Hocevar * @@ -85,6 +85,13 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent ) p_playlist->i_size = 0; p_playlist->pp_items = NULL; + p_playlist->i_groups = 0; + p_playlist->pp_groups = NULL; + p_playlist->i_max_id = 0; + + playlist_CreateGroup( p_playlist, strdup("Normal") ); + + msg_Dbg(p_playlist,"pouet"); if( vlc_thread_create( p_playlist, "playlist", RunThread, VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) ) { @@ -93,6 +100,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent ) return NULL; } + msg_Dbg(p_playlist,"pouet2"); /* The object has been initialized, now attach it */ vlc_object_attach( p_playlist, p_parent ); @@ -116,507 +124,6 @@ void playlist_Destroy( playlist_t * p_playlist ) vlc_object_destroy( p_playlist ); } -/** - * Add an MRL to the playlist. This is a simplified version of - * playlist_AddExt inculded for convenince. It equals calling playlist_AddExt - * with psz_name == psz_target and i_duration == -1 - */ - -int playlist_Add( playlist_t *p_playlist, const char *psz_target, - const char **ppsz_options, int i_options, - int i_mode, int i_pos ) -{ - return playlist_AddExt( p_playlist, psz_target, psz_target, -1, - ppsz_options, i_options, i_mode, i_pos ); -} - -/** - * Add a MRL into the playlist. - * - * \param p_playlist the playlist to add into - * \param psz_uri the mrl to add to the playlist - * \param psz_name a text giving a name or description of this item - * \param i_duration a hint about the duration of this item, in miliseconds, or - * -1 if unknown. - * \param ppsz_options array of options - * \param i_options number of items in ppsz_options - * \param i_mode the mode used when adding - * \param i_pos the position in the playlist where to add. If this is - * PLAYLIST_END the item will be added at the end of the playlist - * regardless of it's size - * \return always returns 0 -*/ -int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri, - const char * psz_name, mtime_t i_duration, - const char **ppsz_options, int i_options, int i_mode, - int i_pos ) -{ - playlist_item_t * p_item; - - p_item = malloc( sizeof( playlist_item_t ) ); - if( p_item == NULL ) - { - msg_Err( p_playlist, "out of memory" ); - } - - p_item->psz_name = strdup( psz_name ); - p_item->psz_uri = strdup( psz_uri ); - p_item->psz_author = strdup( "" ); - p_item->i_duration = i_duration; - p_item->i_type = 0; - p_item->i_status = 0; - p_item->b_autodeletion = VLC_FALSE; - p_item->b_enabled = VLC_TRUE; - p_item->i_group = PLAYLIST_TYPE_MANUAL; - - p_item->ppsz_options = NULL; - p_item->i_options = i_options; - - if( i_options ) - { - int i; - - p_item->ppsz_options = (char **)malloc( i_options * sizeof(char *) ); - for( i = 0; i < i_options; i++ ) - p_item->ppsz_options[i] = strdup( ppsz_options[i] ); - - } - - return playlist_AddItem( p_playlist, p_item, i_mode, i_pos ); -} - -/** - * Add a playlist item into a playlist - * - * \param p_playlist the playlist to insert into - * \param p_item the playlist item to insert - * \param i_mode the mode used when adding - * \param i_pos the possition in the playlist where to add. If this is - * PLAYLIST_END the item will be added at the end of the playlist - * regardless of it's size - * \return always returns 0 -*/ -int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, - int i_mode, int i_pos) -{ - vlc_value_t val; - - vlc_mutex_lock( &p_playlist->object_lock ); - - /* - * CHECK_INSERT : checks if the item is already enqued before - * enqueing it - */ - if ( i_mode & PLAYLIST_CHECK_INSERT ) - { - int j; - - if ( p_playlist->pp_items ) - { - for ( j = 0; j < p_playlist->i_size; j++ ) - { - if ( !strcmp( p_playlist->pp_items[j]->psz_uri, p_item->psz_uri ) ) - { - if( p_item->psz_name ) - { - free( p_item->psz_name ); - } - if( p_item->psz_uri ) - { - free( p_item->psz_uri ); - } - free( p_item ); - vlc_mutex_unlock( &p_playlist->object_lock ); - return 0; - } - } - } - i_mode &= ~PLAYLIST_CHECK_INSERT; - i_mode |= PLAYLIST_APPEND; - } - - - msg_Dbg( p_playlist, "adding playlist item « %s » ( %s )", p_item->psz_name, p_item->psz_uri); - - /* Create the new playlist item */ - - - /* Do a few boundary checks and allocate space for the item */ - if( i_pos == PLAYLIST_END ) - { - if( i_mode & PLAYLIST_INSERT ) - { - i_mode &= ~PLAYLIST_INSERT; - i_mode |= PLAYLIST_APPEND; - } - - i_pos = p_playlist->i_size - 1; - } - - if( !(i_mode & PLAYLIST_REPLACE) - || i_pos < 0 || i_pos >= p_playlist->i_size ) - { - /* Additional boundary checks */ - if( i_mode & PLAYLIST_APPEND ) - { - i_pos++; - } - - if( i_pos < 0 ) - { - i_pos = 0; - } - else if( i_pos > p_playlist->i_size ) - { - i_pos = p_playlist->i_size; - } - - INSERT_ELEM( p_playlist->pp_items, - p_playlist->i_size, - i_pos, - p_item ); - p_playlist->i_enabled ++; - - if( p_playlist->i_index >= i_pos ) - { - p_playlist->i_index++; - } - } - else - { - /* i_mode == PLAYLIST_REPLACE and 0 <= i_pos < p_playlist->i_size */ - if( p_playlist->pp_items[i_pos]->psz_name ) - { - free( p_playlist->pp_items[i_pos]->psz_name ); - } - if( p_playlist->pp_items[i_pos]->psz_uri ) - { - free( p_playlist->pp_items[i_pos]->psz_uri ); - } - /* XXX: what if the item is still in use? */ - free( p_playlist->pp_items[i_pos] ); - p_playlist->pp_items[i_pos] = p_item; - } - - if( i_mode & PLAYLIST_GO ) - { - p_playlist->i_index = i_pos; - if( p_playlist->p_input ) - { - input_StopThread( p_playlist->p_input ); - } - p_playlist->i_status = PLAYLIST_RUNNING; - } - - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * delete an item from a playlist. - * - * \param p_playlist the playlist to remove from. - * \param i_pos the position of the item to remove - * \return returns 0 - */ -int playlist_Delete( playlist_t * p_playlist, int i_pos ) -{ - vlc_value_t val; - vlc_mutex_lock( &p_playlist->object_lock ); - - if( i_pos >= 0 && i_pos < p_playlist->i_size ) - { - msg_Dbg( p_playlist, "deleting playlist item « %s »", - p_playlist->pp_items[i_pos]->psz_name ); - - if( p_playlist->pp_items[i_pos]->psz_name ) - { - free( p_playlist->pp_items[i_pos]->psz_name ); - } - if( p_playlist->pp_items[i_pos]->psz_uri ) - { - free( p_playlist->pp_items[i_pos]->psz_uri ); - } - if( p_playlist->pp_items[i_pos]->i_options ) - { - int i; - - for( i = 0; i < p_playlist->pp_items[i_pos]->i_options; i++ ) - free( p_playlist->pp_items[i_pos]->ppsz_options[i] ); - - free( p_playlist->pp_items[i_pos]->ppsz_options ); - } - - /* XXX: what if the item is still in use? */ - free( p_playlist->pp_items[i_pos] ); - - if( i_pos <= p_playlist->i_index ) - { - p_playlist->i_index--; - } - - /* Renumber the playlist */ - REMOVE_ELEM( p_playlist->pp_items, - p_playlist->i_size, - i_pos ); - if( p_playlist->i_enabled > 0 ) - p_playlist->i_enabled--; - } - - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * Disables a playlist item - * - * \param p_playlist the playlist to disable from. - * \param i_pos the position of the item to disable - * \return returns 0 - */ -int playlist_Disable( playlist_t * p_playlist, int i_pos ) -{ - vlc_value_t val; - vlc_mutex_lock( &p_playlist->object_lock ); - - - if( i_pos >= 0 && i_pos < p_playlist->i_size ) - { - msg_Dbg( p_playlist, "disabling playlist item « %s »", - p_playlist->pp_items[i_pos]->psz_name ); - - if( p_playlist->pp_items[i_pos]->b_enabled == VLC_TRUE ) - p_playlist->i_enabled--; - p_playlist->pp_items[i_pos]->b_enabled = VLC_FALSE; - } - - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * Enables a playlist item - * - * \param p_playlist the playlist to enable from. - * \param i_pos the position of the item to enable - * \return returns 0 - */ -int playlist_Enable( playlist_t * p_playlist, int i_pos ) -{ - vlc_value_t val; - vlc_mutex_lock( &p_playlist->object_lock ); - - if( i_pos >= 0 && i_pos < p_playlist->i_size ) - { - msg_Dbg( p_playlist, "enabling playlist item « %s »", - p_playlist->pp_items[i_pos]->psz_name ); - - if( p_playlist->pp_items[i_pos]->b_enabled == VLC_FALSE ) - p_playlist->i_enabled++; - - p_playlist->pp_items[i_pos]->b_enabled = VLC_TRUE; - } - - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * Disables a playlist group - * - * \param p_playlist the playlist to disable from. - * \param i_pos the id of the group to disable - * \return returns 0 - */ -int playlist_DisableGroup( playlist_t * p_playlist, int i_group) -{ - vlc_value_t val; - int i; - vlc_mutex_lock( &p_playlist->object_lock ); - - msg_Dbg(p_playlist,"Disabling group %i",i_group); - for( i = 0 ; i< p_playlist->i_size; i++ ) - { - if( p_playlist->pp_items[i]->i_group == i_group ) - { - msg_Dbg( p_playlist, "disabling playlist item « %s »", - p_playlist->pp_items[i]->psz_name ); - - if( p_playlist->pp_items[i]->b_enabled == VLC_TRUE ) - p_playlist->i_enabled--; - - p_playlist->pp_items[i]->b_enabled = VLC_FALSE; - } - } - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * Enables a playlist group - * - * \param p_playlist the playlist to enable from. - * \param i_pos the id of the group to enable - * \return returns 0 - */ -int playlist_EnableGroup( playlist_t * p_playlist, int i_group) -{ - vlc_value_t val; - int i; - vlc_mutex_lock( &p_playlist->object_lock ); - - for( i = 0 ; i< p_playlist->i_size; i++ ) - { - if( p_playlist->pp_items[i]->i_group == i_group ) - { - msg_Dbg( p_playlist, "enabling playlist item « %s »", - p_playlist->pp_items[i]->psz_name ); - - if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) - p_playlist->i_enabled++; - - p_playlist->pp_items[i]->b_enabled = VLC_TRUE; - } - } - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} - -/** - * Sort the playlist - * - */ -int playlist_Sort( playlist_t * p_playlist , int i_type ) -{ - int i , i_small , i_position; - playlist_item_t *p_temp; - - vlc_mutex_lock( &p_playlist->object_lock ); - - for( i_position = 0; i_position < p_playlist->i_size -1 ; i_position ++ ) - { - i_small = i_position; - for( i = i_position + 1 ; i< p_playlist->i_size ; i++) - { - int i_test; - - i_test = strcasecmp( p_playlist->pp_items[i]->psz_name, - p_playlist->pp_items[i_small]->psz_name ); - - if( ( i_type == SORT_NORMAL && i_test < 0 ) || - ( i_type == SORT_REVERSE && i_test > 0 ) ) - { - i_small = i; - } - } - /* Keep the correct current index */ - if( i_small == p_playlist->i_index ) - p_playlist->i_index = i_position; - else if( i_position == p_playlist->i_index ) - p_playlist->i_index = i_small; - - p_temp = p_playlist->pp_items[i_position]; - p_playlist->pp_items[i_position] = p_playlist->pp_items[i_small]; - p_playlist->pp_items[i_small] = p_temp; - } - vlc_mutex_unlock( &p_playlist->object_lock ); - - return 0; -} - -/** - * Move an item in a playlist - * - * Move the item in the playlist with position i_pos before the current item - * at position i_newpos. - * \param p_playlist the playlist to move items in - * \param i_pos the position of the item to move - * \param i_newpos the position of the item that will be behind the moved item - * after the move - * \return returns 0 - */ -int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) -{ - vlc_value_t val; - vlc_mutex_lock( &p_playlist->object_lock ); - - /* take into account that our own row disappears. */ - if ( i_pos < i_newpos ) i_newpos--; - - if( i_pos >= 0 && i_newpos >=0 && i_pos <= p_playlist->i_size - && i_newpos <= p_playlist->i_size ) - { - playlist_item_t * temp; - - msg_Dbg( p_playlist, "moving playlist item « %s »", - p_playlist->pp_items[i_pos]->psz_name ); - - if( i_pos == p_playlist->i_index ) - { - p_playlist->i_index = i_newpos; - } - else if( i_pos > p_playlist->i_index && i_newpos <= p_playlist->i_index ) - { - p_playlist->i_index++; - } - else if( i_pos < p_playlist->i_index && i_newpos >= p_playlist->i_index ) - { - p_playlist->i_index--; - } - - if ( i_pos < i_newpos ) - { - temp = p_playlist->pp_items[i_pos]; - while ( i_pos < i_newpos ) - { - p_playlist->pp_items[i_pos] = p_playlist->pp_items[i_pos+1]; - i_pos++; - } - p_playlist->pp_items[i_newpos] = temp; - } - else if ( i_pos > i_newpos ) - { - temp = p_playlist->pp_items[i_pos]; - while ( i_pos > i_newpos ) - { - p_playlist->pp_items[i_pos] = p_playlist->pp_items[i_pos-1]; - i_pos--; - } - p_playlist->pp_items[i_newpos] = temp; - } - } - - vlc_mutex_unlock( &p_playlist->object_lock ); - - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-change", val ); - - return 0; -} /** * Do a playlist action @@ -767,6 +274,8 @@ static void RunThread ( playlist_t *p_playlist ) /* Tell above that we're ready */ vlc_thread_ready( p_playlist ); + msg_Dbg(p_playlist,"pouet3"); + while( !p_playlist->b_die ) { vlc_mutex_lock( &p_playlist->object_lock ); @@ -1031,157 +540,3 @@ static void PlayItem( playlist_t *p_playlist ) p_playlist->p_input = input_CreateThread( p_playlist, p_playlist->pp_items[p_playlist->i_index] ); } - -/***************************************************************************** - * playlist_LoadFile: load a playlist file. - ****************************************************************************/ -int playlist_LoadFile( playlist_t * p_playlist, const char *psz_filename ) -{ - FILE *file; - char line[1024]; - int i_current_status; - int i_format; - int i; - - msg_Dbg( p_playlist, "opening playlist file %s", psz_filename ); - - file = fopen( psz_filename, "rt" ); - if( !file ) - { - msg_Err( p_playlist, "playlist file %s does not exist", psz_filename ); - return -1; - } - fseek( file, 0L, SEEK_SET ); - - /* check the file is not empty */ - if ( ! fgets( line, 1024, file ) ) - { - msg_Err( p_playlist, "playlist file %s is empty", psz_filename ); - fclose( file ); - return -1; - } - - /* get rid of line feed */ - if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' ) - { - line[strlen(line)-1] = (char)0; - if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0; - } - /* check the file format is valid */ - if ( !strcmp ( line , PLAYLIST_FILE_HEADER_0_5 ) ) - { - i_format = 5; - } - else if( !strcmp ( line , PLAYLIST_FILE_HEADER_0_6 ) ) - { - i_format = 6; - } - else - { - msg_Err( p_playlist, "playlist file %s format is unsupported" - , psz_filename ); - fclose( file ); - return -1; - } - - /* stop playing */ - i_current_status = p_playlist->i_status; - if ( p_playlist->i_status != PLAYLIST_STOPPED ) - { - playlist_Stop ( p_playlist ); - } - - /* delete current content of the playlist */ - for( i = p_playlist->i_size - 1; i >= 0; i-- ) - { - playlist_Delete ( p_playlist , i ); - } - - /* simply add each line */ - while( fgets( line, 1024, file ) ) - { - /* ignore comments or empty lines */ - if( (line[0] == '#') || (line[0] == '\r') || (line[0] == '\n') - || (line[0] == (char)0) ) - continue; - - /* get rid of line feed */ - if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' ) - { - line[strlen(line)-1] = (char)0; - if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0; - } - if( i_format == 5 ) - { - playlist_Add ( p_playlist , (char *)&line , - 0, 0, PLAYLIST_APPEND , PLAYLIST_END ); - } - else - { - msg_Warn( p_playlist, "Not supported yet"); - } - } - - /* start playing */ - if ( i_current_status != PLAYLIST_STOPPED ) - { - playlist_Play ( p_playlist ); - } - - fclose( file ); - - return 0; -} - -/***************************************************************************** - * playlist_SaveFile: Save a playlist in a file. - *****************************************************************************/ -int playlist_SaveFile( playlist_t * p_playlist, const char * psz_filename ) -{ - FILE *file; - int i; - - vlc_mutex_lock( &p_playlist->object_lock ); - - msg_Dbg( p_playlist, "saving playlist file %s", psz_filename ); - - file = fopen( psz_filename, "wt" ); - if( !file ) - { - msg_Err( p_playlist , "could not create playlist file %s" - , psz_filename ); - return -1; - } - /* Save is done in 0_5 mode at the moment*/ - - fprintf( file , PLAYLIST_FILE_HEADER_0_5 "\n" ); - - for ( i = 0 ; i < p_playlist->i_size ; i++ ) - { - fprintf( file , p_playlist->pp_items[i]->psz_uri ); - fprintf( file , "\n" ); - } -#if 0 - fprintf( file, PLAYLIST_FILE_HEADER_0_6 "\n" ); - - for ( i=0 ; i< p_playlist->i_size ; i++ ) - { - fprintf( file, p_playlist->pp_items[i]->psz_uri ); - fprintf( file, "||" ); - fprintf( file, p_playlist->pp_items[i]->psz_name ); - fprintf( file, "||" ); - fprintf( file, "%i",p_playlist->pp_items[i]->b_enabled = VLC_TRUE ? - 1:0 ); - fprintf( file, "||" ); - fprintf( file, "%i", p_playlist->pp_items[i]->i_group ); - fprintf( file, "||" ); - fprintf( file, p_playlist->pp_items[i]->psz_author ); - fprintf( file , "\n" ); - } -#endif - fclose( file ); - - vlc_mutex_unlock( &p_playlist->object_lock ); - - return 0; -} -- 2.39.2