X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fskins2%2Fsrc%2Fdialogs.cpp;h=ee80de2a5ae274dab159c99cbf3dfeb0da077b47;hb=15a6423d9be7811633a2dab3cfdec8745471e094;hp=572cac1f2c3e3e41923770b4d16c99d8e3894bbf;hpb=82a67660c9c7fbc9a1ea78b7929e34af26ebca01;p=vlc diff --git a/modules/gui/skins2/src/dialogs.cpp b/modules/gui/skins2/src/dialogs.cpp index 572cac1f2c..ee80de2a5a 100644 --- a/modules/gui/skins2/src/dialogs.cpp +++ b/modules/gui/skins2/src/dialogs.cpp @@ -1,11 +1,11 @@ /***************************************************************************** * dialogs.cpp ***************************************************************************** - * Copyright (C) 2003 VideoLAN - * $Id: dialogs.cpp,v 1.2 2004/01/25 17:20:19 kuehne Exp $ + * Copyright (C) 2003 the VideoLAN team + * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière + * Olivier Teulière * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,17 +19,19 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include "dialogs.hpp" #include "../commands/async_queue.hpp" #include "../commands/cmd_change_skin.hpp" #include "../commands/cmd_quit.hpp" - +#include "../commands/cmd_playlist.hpp" +#include "../commands/cmd_playtree.hpp" +#include /// Callback called when a new skin is chosen -static void showChangeSkinCB( intf_dialog_args_t *pArg ) +void Dialogs::showChangeSkinCB( intf_dialog_args_t *pArg ) { intf_thread_t *pIntf = (intf_thread_t *)pArg->p_arg; @@ -38,12 +40,11 @@ static void showChangeSkinCB( intf_dialog_args_t *pArg ) if( pArg->psz_results[0] ) { // Create a change skin command - CmdChangeSkin *pCmd = new CmdChangeSkin( pIntf, - pArg->psz_results[0] ); + CmdChangeSkin *pCmd = + new CmdChangeSkin( pIntf, sFromLocale( pArg->psz_results[0] ) ); // Push the command in the asynchronous command queue AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); - pQueue->remove( "resize" ); pQueue->push( CmdGenericPtr( pCmd ) ); } } @@ -56,13 +57,46 @@ static void showChangeSkinCB( intf_dialog_args_t *pArg ) } } +void Dialogs::showPlaylistLoadCB( intf_dialog_args_t *pArg ) +{ + intf_thread_t *pIntf = (intf_thread_t *)pArg->p_arg; + + if( pArg->i_results && pArg->psz_results[0] ) + { + // Create a Playlist Load command + CmdPlaylistLoad *pCmd = + new CmdPlaylistLoad( pIntf, sFromLocale( pArg->psz_results[0] ) ); + + // Push the command in the asynchronous command queue + AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } +} + + +void Dialogs::showPlaylistSaveCB( intf_dialog_args_t *pArg ) +{ + intf_thread_t *pIntf = (intf_thread_t *)pArg->p_arg; + + if( pArg->i_results && pArg->psz_results[0] ) + { + // Create a Playlist Save command + CmdPlaylistSave *pCmd = + new CmdPlaylistSave( pIntf, pArg->psz_results[0] ); + + // Push the command in the asynchronous command queue + AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); + pQueue->push( CmdGenericPtr( pCmd ) ); + } +} + /// Callback called when the popup menu is requested static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ) { Dialogs *p_dialogs = (Dialogs *)param; - p_dialogs->showPopupMenu( new_val.b_bool ); + p_dialogs->showPopupMenu( new_val.b_bool != 0, INTF_DIALOG_POPUPMENU ); return VLC_SUCCESS; } @@ -81,8 +115,8 @@ Dialogs::~Dialogs() // Detach the dialogs provider from its parent interface vlc_object_detach( m_pProvider ); - module_Unneed( m_pProvider, m_pModule ); - vlc_object_destroy( m_pProvider ); + module_unneed( m_pProvider, m_pModule ); + vlc_object_release( m_pProvider ); } /* Unregister callbacks */ @@ -125,18 +159,15 @@ bool Dialogs::init() { // Allocate descriptor m_pProvider = (intf_thread_t *)vlc_object_create( getIntf(), - VLC_OBJECT_INTF ); + sizeof( intf_thread_t ) ); if( m_pProvider == NULL ) - { - msg_Err( getIntf(), "out of memory" ); return false; - } - m_pModule = module_Need( m_pProvider, "dialogs provider", NULL ); + m_pModule = module_need( m_pProvider, "dialogs provider", NULL, false ); if( m_pModule == NULL ) { - msg_Err( getIntf(), "No suitable dialogs provider found" ); - vlc_object_destroy( m_pProvider ); + msg_Err( getIntf(), "no suitable dialogs provider found (hint: compile the qt4 plugin, and make sure it is loaded properly)" ); + vlc_object_release( m_pProvider ); m_pProvider = NULL; return false; } @@ -159,22 +190,22 @@ bool Dialogs::init() } -void Dialogs::showChangeSkin() +void Dialogs::showFileGeneric( const string &rTitle, const string &rExtensions, + DlgCallback callback, int flags ) { if( m_pProvider && m_pProvider->pf_show_dialog ) { - intf_dialog_args_t *p_arg = - (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) ); - memset( p_arg, 0, sizeof(intf_dialog_args_t) ); + intf_dialog_args_t *p_arg = (intf_dialog_args_t*) + calloc( 1, sizeof( intf_dialog_args_t ) ); - p_arg->b_blocking = false; + p_arg->psz_title = strdup( rTitle.c_str() ); + p_arg->psz_extensions = strdup( rExtensions.c_str() ); - p_arg->psz_title = strdup( _("Open a skin file.") ); - p_arg->psz_extensions = - strdup( _("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|") ); + p_arg->b_save = flags & kSAVE; + p_arg->b_multiple = flags & kMULTIPLE; p_arg->p_arg = getIntf(); - p_arg->pf_callback = showChangeSkinCB; + p_arg->pf_callback = callback; m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE_GENERIC, 0, p_arg ); @@ -182,12 +213,46 @@ void Dialogs::showChangeSkin() } +void Dialogs::showChangeSkin() +{ + showFileGeneric( _("Open a skin file"), + _("Skin files |*.vlt;*.wsz;*.xml"), + showChangeSkinCB, kOPEN ); +} + + +void Dialogs::showPlaylistLoad() +{ + showFileGeneric( _("Open playlist"), + _("Playlist Files|"EXTENSIONS_PLAYLIST"|" + "All Files|*"), + showPlaylistLoadCB, kOPEN ); +} + + +void Dialogs::showPlaylistSave() +{ + showFileGeneric( _("Save playlist"), _("XSPF playlist|*.xspf|" + "M3U file|*.m3u|" + "HTML playlist|*.html"), + showPlaylistSaveCB, kSAVE ); +} + +void Dialogs::showPlaylist() +{ + if( m_pProvider && m_pProvider->pf_show_dialog ) + { + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_PLAYLIST, + 0, NULL ); + } +} + void Dialogs::showFileSimple( bool play ) { if( m_pProvider && m_pProvider->pf_show_dialog ) { m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE_SIMPLE, - (int)play, 0 ); + (int)play, NULL ); } } @@ -197,7 +262,17 @@ void Dialogs::showFile( bool play ) if( m_pProvider && m_pProvider->pf_show_dialog ) { m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE, - (int)play, 0 ); + (int)play, NULL ); + } +} + + +void Dialogs::showDirectory( bool play ) +{ + if( m_pProvider && m_pProvider->pf_show_dialog ) + { + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_DIRECTORY, + (int)play, NULL ); } } @@ -207,7 +282,7 @@ void Dialogs::showDisc( bool play ) if( m_pProvider && m_pProvider->pf_show_dialog ) { m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_DISC, - (int)play, 0 ); + (int)play, NULL ); } } @@ -217,7 +292,7 @@ void Dialogs::showNet( bool play ) if( m_pProvider && m_pProvider->pf_show_dialog ) { m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_NET, - (int)play, 0 ); + (int)play, NULL ); } } @@ -226,7 +301,7 @@ void Dialogs::showMessages() { if( m_pProvider && m_pProvider->pf_show_dialog ) { - m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_MESSAGES, 0, 0 ); + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_MESSAGES, 0, NULL ); } } @@ -235,26 +310,49 @@ void Dialogs::showPrefs() { if( m_pProvider && m_pProvider->pf_show_dialog ) { - m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_PREFS, 0, 0 ); + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_PREFS, 0, NULL ); } } void Dialogs::showFileInfo() { - if( m_pProvider && m_pProvider->pf_show_dialog ) + if( m_pProvider && m_pProvider->pf_show_dialog ) + { + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILEINFO, 0, NULL ); + } +} + + +void Dialogs::showStreamingWizard() +{ + if( m_pProvider && m_pProvider->pf_show_dialog ) { - m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILEINFO, 0, 0 ); + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_WIZARD, 0, NULL ); } } -void Dialogs::showPopupMenu( bool bShow ) +void Dialogs::showPopupMenu( bool bShow, int popupType = INTF_DIALOG_POPUPMENU ) { if( m_pProvider && m_pProvider->pf_show_dialog ) { - m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_POPUPMENU, - (int)bShow, 0 ); + m_pProvider->pf_show_dialog( m_pProvider, popupType, + (int)bShow, NULL ); } } +void Dialogs::showInteraction( interaction_dialog_t *p_dialog ) +{ + intf_dialog_args_t *p_arg = (intf_dialog_args_t *) + calloc( 1, sizeof(intf_dialog_args_t) ); + + p_arg->p_dialog = p_dialog; + p_arg->p_intf = getIntf(); + + if( m_pProvider && m_pProvider->pf_show_dialog ) + { + m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_INTERACTION, + 0, p_arg ); + } +}