Commit 45ecdf1b authored by Olivier Teulière's avatar Olivier Teulière

* skins2: new "playlist.load()" and "playlist.save()" actions

parent 874d5a11
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cmd_change_skin.cpp * cmd_change_skin.cpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: cmd_change_skin.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "../src/os_loop.hpp" #include "../src/os_loop.hpp"
#include "../src/theme.hpp" #include "../src/theme.hpp"
#include "../src/theme_loader.hpp" #include "../src/theme_loader.hpp"
#include "../src/window_manager.hpp"
void CmdChangeSkin::execute() void CmdChangeSkin::execute()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cmd_change_skin.hpp * cmd_change_skin.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: cmd_change_skin.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr> * Olivier Teulière <ipkiss@via.ecp.fr>
...@@ -28,9 +28,6 @@ ...@@ -28,9 +28,6 @@
#include "cmd_generic.hpp" #include "cmd_generic.hpp"
class WindowManager;
/// "Change Skin" command /// "Change Skin" command
class CmdChangeSkin: public CmdGeneric class CmdChangeSkin: public CmdGeneric
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cmd_dialogs.hpp * cmd_dialogs.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: cmd_dialogs.hpp,v 1.2 2004/02/01 14:44:11 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -44,6 +44,8 @@ typedef CmdDialogs<8> CmdDlgFileInfo; ...@@ -44,6 +44,8 @@ typedef CmdDialogs<8> CmdDlgFileInfo;
typedef CmdDialogs<9> CmdDlgShowPopupMenu; typedef CmdDialogs<9> CmdDlgShowPopupMenu;
typedef CmdDialogs<10> CmdDlgHidePopupMenu; typedef CmdDialogs<10> CmdDlgHidePopupMenu;
typedef CmdDialogs<11> CmdDlgAdd; typedef CmdDialogs<11> CmdDlgAdd;
typedef CmdDialogs<12> CmdDlgPlaylistLoad;
typedef CmdDialogs<13> CmdDlgPlaylistSave;
/// Generic "Open dialog" command /// Generic "Open dialog" command
...@@ -99,6 +101,12 @@ class CmdDialogs: public CmdGeneric ...@@ -99,6 +101,12 @@ class CmdDialogs: public CmdGeneric
case 11: case 11:
pDialogs->showFile( false ); pDialogs->showFile( false );
break; break;
case 12:
pDialogs->showPlaylistLoad();
break;
case 13:
pDialogs->showPlaylistSave();
break;
default: default:
msg_Warn( getIntf(), "Unknown dialog type" ); msg_Warn( getIntf(), "Unknown dialog type" );
break; break;
......
...@@ -100,3 +100,25 @@ void CmdPlaylistRepeat::execute() ...@@ -100,3 +100,25 @@ void CmdPlaylistRepeat::execute()
} }
} }
void CmdPlaylistLoad::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
{
playlist_Import( pPlaylist, m_file.c_str() );
}
}
void CmdPlaylistSave::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
{
// FIXME: when the PLS export will be working, we'll need to remove
// this hardcoding...
playlist_Export( pPlaylist, m_file.c_str(), "export-m3u" );
}
}
...@@ -119,4 +119,44 @@ class CmdPlaylistRepeat: public CmdGeneric ...@@ -119,4 +119,44 @@ class CmdPlaylistRepeat: public CmdGeneric
}; };
/// Command to load a playlist
class CmdPlaylistLoad: public CmdGeneric
{
public:
CmdPlaylistLoad( intf_thread_t *pIntf, const string& rFile ):
CmdGeneric( pIntf ), m_file( rFile ) {}
virtual ~CmdPlaylistLoad() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "playlist load"; }
private:
/// Playlist file to load
string m_file;
};
/// Command to save a playlist
class CmdPlaylistSave: public CmdGeneric
{
public:
CmdPlaylistSave( intf_thread_t *pIntf, const string& rFile ):
CmdGeneric( pIntf ), m_file( rFile ) {}
virtual ~CmdPlaylistSave() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "playlist save"; }
private:
/// Playlist file to save
string m_file;
};
#endif #endif
...@@ -55,6 +55,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -55,6 +55,8 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
REGISTER_CMD( "dialogs.prefs()", CmdDlgPrefs ) REGISTER_CMD( "dialogs.prefs()", CmdDlgPrefs )
REGISTER_CMD( "dialogs.fileInfo()", CmdDlgFileInfo ) REGISTER_CMD( "dialogs.fileInfo()", CmdDlgFileInfo )
REGISTER_CMD( "dialogs.popup()", CmdDlgShowPopupMenu ) REGISTER_CMD( "dialogs.popup()", CmdDlgShowPopupMenu )
REGISTER_CMD( "playlist.load()", CmdDlgPlaylistLoad )
REGISTER_CMD( "playlist.save()", CmdDlgPlaylistSave )
REGISTER_CMD( "playlist.add()", CmdDlgAdd ) REGISTER_CMD( "playlist.add()", CmdDlgAdd )
VarList &rVar = VlcProc::instance( getIntf() )->getPlaylistVar(); VarList &rVar = VlcProc::instance( getIntf() )->getPlaylistVar();
m_commandMap["playlist.del()"] = m_commandMap["playlist.del()"] =
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
#include "../commands/async_queue.hpp" #include "../commands/async_queue.hpp"
#include "../commands/cmd_change_skin.hpp" #include "../commands/cmd_change_skin.hpp"
#include "../commands/cmd_quit.hpp" #include "../commands/cmd_quit.hpp"
#include "../commands/cmd_playlist.hpp"
/// Callback called when a new skin is chosen /// 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; intf_thread_t *pIntf = (intf_thread_t *)pArg->p_arg;
...@@ -38,8 +39,8 @@ static void showChangeSkinCB( intf_dialog_args_t *pArg ) ...@@ -38,8 +39,8 @@ static void showChangeSkinCB( intf_dialog_args_t *pArg )
if( pArg->psz_results[0] ) if( pArg->psz_results[0] )
{ {
// Create a change skin command // Create a change skin command
CmdChangeSkin *pCmd = new CmdChangeSkin( pIntf, CmdChangeSkin *pCmd =
pArg->psz_results[0] ); new CmdChangeSkin( pIntf, pArg->psz_results[0] );
// Push the command in the asynchronous command queue // Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
...@@ -57,6 +58,42 @@ static void showChangeSkinCB( intf_dialog_args_t *pArg ) ...@@ -57,6 +58,42 @@ 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, pArg->psz_results[0] );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
pQueue->remove( "load playlist" );
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->remove( "load playlist" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
}
/// Callback called when the popup menu is requested /// Callback called when the popup menu is requested
static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param ) vlc_value_t old_val, vlc_value_t new_val, void *param )
...@@ -159,7 +196,8 @@ bool Dialogs::init() ...@@ -159,7 +196,8 @@ 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 ) if( m_pProvider && m_pProvider->pf_show_dialog )
{ {
...@@ -167,12 +205,14 @@ void Dialogs::showChangeSkin() ...@@ -167,12 +205,14 @@ void Dialogs::showChangeSkin()
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) ); (intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) ); memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->psz_title = strdup( _("Open a skin file") ); p_arg->psz_title = strdup( rTitle.c_str() );
p_arg->psz_extensions = p_arg->psz_extensions = strdup( rExtensions.c_str() );
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->p_arg = getIntf();
p_arg->pf_callback = showChangeSkinCB; p_arg->pf_callback = callback;
m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE_GENERIC, m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_FILE_GENERIC,
0, p_arg ); 0, p_arg );
...@@ -180,6 +220,29 @@ void Dialogs::showChangeSkin() ...@@ -180,6 +220,29 @@ void Dialogs::showChangeSkin()
} }
void Dialogs::showChangeSkin()
{
showFileGeneric( _("Open a skin file"),
_("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"),
showChangeSkinCB, kOPEN );
}
void Dialogs::showPlaylistLoad()
{
showFileGeneric( _("Open playlist"),
_("All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u"),
showPlaylistLoadCB, kOPEN );
}
void Dialogs::showPlaylistSave()
{
showFileGeneric( _("Save playlist"), _("M3U file|*.m3u"),
showPlaylistSaveCB, kSAVE );
}
void Dialogs::showFileSimple( bool play ) void Dialogs::showFileSimple( bool play )
{ {
if( m_pProvider && m_pProvider->pf_show_dialog ) if( m_pProvider && m_pProvider->pf_show_dialog )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dialogs.hpp * dialogs.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: dialogs.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -33,21 +33,27 @@ ...@@ -33,21 +33,27 @@
class Dialogs: public SkinObject class Dialogs: public SkinObject
{ {
public: public:
/// Get the instance of Dialogs. /// Get the instance of Dialogs
/// Returns NULL if initialization failed /// Returns NULL if initialization failed
static Dialogs *instance( intf_thread_t *pIntf ); static Dialogs *instance( intf_thread_t *pIntf );
/// Delete the instance of Dialogs /// Delete the instance of Dialogs
static void destroy( intf_thread_t *pIntf ); static void destroy( intf_thread_t *pIntf );
/// Show the Change Skin dialog. /// Show the Change Skin dialog
void showChangeSkin(); void showChangeSkin();
/// Show the Load Playlist dialog
void showPlaylistLoad();
/// Show the Save Playlist dialog
void showPlaylistSave();
/// Show the Quick Open File dialog. /// Show the Quick Open File dialog.
/// If play is false, just add the item in the playlist /// If play is false, just add the item in the playlist
void showFileSimple( bool play ); void showFileSimple( bool play );
/// Show the Open File dialog. /// Show the Open File dialog
/// If play is false, just add the item in the playlist /// If play is false, just add the item in the playlist
void showFile( bool play ); void showFile( bool play );
...@@ -71,28 +77,43 @@ class Dialogs: public SkinObject ...@@ -71,28 +77,43 @@ class Dialogs: public SkinObject
/// Show the popup menu /// Show the popup menu
void showPopupMenu( bool bShow ); void showPopupMenu( bool bShow );
// XXX: This is a kludge! In fact, the file name retrieved when
// changing the skin should be returned directly to the command, but
// the dialog provider mechanism doesn't allow it.
/// Store temporarily a file name
void setThemeFile( const string &themeFile ) { m_theme = themeFile; }
/// Get a previously saved file name
const string &getThemeFile() const { return m_theme; }
private: private:
// Private because it's a singleton // Private because it's a singleton
Dialogs( intf_thread_t *pIntf ); Dialogs( intf_thread_t *pIntf );
~Dialogs(); ~Dialogs();
/// DlgCallback is the type of the callbacks of the open/save dialog
typedef void DlgCallback( intf_dialog_args_t *pArg );
/// Possible flags for the open/save dialog
typedef enum
{
kOPEN = 0x01,
kSAVE = 0x02,
kMULTIPLE = 0x04
} flags_t;
/// Initialization method /// Initialization method
bool init(); bool init();
/// Show a generic open/save dialog, initialized with the given
/// parameters
/// The 'flags' parameter is a logical or of the flags_t values
void showFileGeneric( const string &rTitle, const string &rExtensions,
DlgCallback callback, int flags );
/// Callback for the Change Skin dialog
static void showChangeSkinCB( intf_dialog_args_t *pArg );
/// Callback for the Load Playlist dialog
static void showPlaylistLoadCB( intf_dialog_args_t *pArg );
/// Callback for the Save Playlist dialog
static void showPlaylistSaveCB( intf_dialog_args_t *pArg );
/// Dialogs provider module /// Dialogs provider module
intf_thread_t *m_pProvider; intf_thread_t *m_pProvider;
module_t *m_pModule; module_t *m_pModule;
/// Name of a theme file, obtained via the ChangeSkin dialog
string m_theme;
}; };
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "../parser/interpreter.hpp" #include "../parser/interpreter.hpp"
#include "../commands/async_queue.hpp" #include "../commands/async_queue.hpp"
#include "../commands/cmd_quit.hpp" #include "../commands/cmd_quit.hpp"
#include "../commands/cmd_dialogs.hpp"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -198,10 +199,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -198,10 +199,11 @@ static void Run( intf_thread_t *p_intf )
if( it == resPath.end() ) if( it == resPath.end() )
{ {
// Last chance: the user can select a new theme file // Last chance: the user can select a new theme file
Dialogs *pDialogs = Dialogs::instance( p_intf ); if( Dialogs::instance( p_intf ) )
if( pDialogs )
{ {
pDialogs->showChangeSkin(); CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
pQueue->push( CmdGenericPtr( pCmd ) );
} }
else else
{ {
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#include "os_window.hpp" #include "os_window.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "theme.hpp" #include "theme.hpp"
#include "dialogs.hpp"
#include "var_manager.hpp" #include "var_manager.hpp"
#include "../commands/cmd_on_top.hpp" #include "../commands/cmd_on_top.hpp"
#include "../commands/cmd_dialogs.hpp"
#include "../controls/ctrl_generic.hpp" #include "../controls/ctrl_generic.hpp"
#include "../events/evt_enter.hpp" #include "../events/evt_enter.hpp"
#include "../events/evt_focus.hpp" #include "../events/evt_focus.hpp"
...@@ -183,20 +183,17 @@ void TopWindow::processEvent( EvtKey &rEvtKey ) ...@@ -183,20 +183,17 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
// Only do the action when the key is down // Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos ) if( rEvtKey.getAsString().find( "key:down") != string::npos )
{ {
//XXX not to be hardcoded ! //XXX not to be hardcoded!
// Ctrl-S = Change skin // Ctrl-S = Change skin
if( (rEvtKey.getMod() & EvtInput::kModCtrl) && if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
rEvtKey.getKey() == 's' ) rEvtKey.getKey() == 's' )
{ {
Dialogs *pDialogs = Dialogs::instance( getIntf() ); CmdDlgChangeSkin cmd( getIntf() );
if( pDialogs != NULL ) cmd.execute();
{
pDialogs->showChangeSkin();
}
return; return;
} }
//XXX not to be hardcoded ! //XXX not to be hardcoded!
// Ctrl-T = Toggle on top // Ctrl-T = Toggle on top
if( (rEvtKey.getMod() & EvtInput::kModCtrl) && if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
rEvtKey.getKey() == 't' ) rEvtKey.getKey() == 't' )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment