* vlcproc.cpp: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: vlcproc.cpp,v 1.29 2003/06/03 22:18:58 gbazin Exp $
+ * $Id: vlcproc.cpp,v 1.41 2003/07/20 10:38:49 gbazin Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
#include <vlc/aout.h>
#include <vlc/vout.h>
-#ifndef BASIC_SKINS
-#ifdef WIN32 /* mingw32 hack */
-# undef Yield
-# undef CreateDialog
-#endif
-/* Let vlc take care of the i18n stuff */
-#define WXINTL_NO_GETTEXT_MACRO
-#include <wx/wx.h>
-#endif
-
//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
#include "event.h"
#include "skin_common.h"
#include "dialogs.h"
-#ifndef BASIC_SKINS
-#include "../../wxwindows/wxwindows.h"
-#endif
-
-
//---------------------------------------------------------------------------
// VlcProc
//---------------------------------------------------------------------------
VlcProc::VlcProc( intf_thread_t *_p_intf )
{
- p_intf = _p_intf;
+ p_intf = _p_intf;
+
+ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+ VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ if( p_playlist != NULL )
+ {
+ // We want to be noticed of playlit changes
+ var_AddCallback( p_playlist, "intf-change", RefreshCallback, this );
+
+ // Raise/lower interface with middle click on vout
+ var_AddCallback( p_playlist, "intf-show", IntfShowCallback, this );
+
+ vlc_object_release( p_playlist );
+ }
+}
+//---------------------------------------------------------------------------
+VlcProc::~VlcProc()
+{
+ // Remove the refresh callback
+ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
+ VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+ if( p_playlist != NULL )
+ {
+ var_DelCallback( p_playlist, "intf-change", RefreshCallback, this );
+ vlc_object_release( p_playlist );
+ }
}
//---------------------------------------------------------------------------
bool VlcProc::EventProc( Event *evt )
return true;
case VLC_OPEN:
-#ifndef BASIC_SKINS
- p_intf->p_sys->p_dialogs->ShowOpen( TRUE );
+ p_intf->p_sys->p_dialogs->ShowOpen( true );
InterfaceRefresh();
-#endif
return true;
case VLC_LOAD_SKIN:
return true;
case VLC_PLAYLIST_ADD_FILE:
-#ifndef BASIC_SKINS
- p_intf->p_sys->p_dialogs->ShowOpen( FALSE );
+ p_intf->p_sys->p_dialogs->ShowOpen( false );
InterfaceRefresh();
-#endif
return true;
-#ifndef BASIC_SKINS
case VLC_LOG_SHOW:
p_intf->p_sys->p_dialogs->ShowMessages();
return true;
case VLC_INFO_SHOW:
p_intf->p_sys->p_dialogs->ShowFileInfo();
return true;
-#endif
case VLC_INTF_REFRESH:
- InterfaceRefresh( (bool)evt->GetParam2() );
+ InterfaceRefresh();
return true;
case VLC_TEST_ALL_CLOSED:
//---------------------------------------------------------------------------
// Private methods
//---------------------------------------------------------------------------
-void VlcProc::InterfaceRefresh( bool All )
+
+// Refresh callback
+int VlcProc::RefreshCallback( vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+ ( (VlcProc*)param )->InterfaceRefresh();
+ return VLC_SUCCESS;
+}
+
+// Interface show/hide callback
+int VlcProc::IntfShowCallback( vlc_object_t *p_this, const char *psz_variable,
+ vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+ if( new_val.b_bool == VLC_TRUE )
+ {
+ OSAPI_PostMessage( NULL, VLC_SHOW, 1, 0 );
+ }
+ else
+ {
+ OSAPI_PostMessage( NULL, VLC_HIDE, 1, 0 );
+ }
+ return VLC_SUCCESS;
+}
+
+void VlcProc::InterfaceRefresh()
{
// Shortcut pointers
intf_sys_t *Sys = p_intf->p_sys;
else
EnabledEvent( "next", true );
-
- // Update file name text
+ // Update file name
if( PlayList->i_index != Sys->i_index )
{
+ string long_name = PlayList->pp_items[PlayList->i_index]->psz_name;
+ int pos = long_name.rfind( DIRECTORY_SEPARATOR, long_name.size() );
+
+ // Complete file name
Thema->EvtBank->Get( "file_name" )->PostTextMessage(
PlayList->pp_items[PlayList->i_index]->psz_name );
+ // File name without path
+ Thema->EvtBank->Get( "title" )->PostTextMessage(
+ PlayList->pp_items[PlayList->i_index]->psz_name + pos + 1 );
}
// Update playlists
Sys->i_size = 0;
}
}
-
}
//---------------------------------------------------------------------------
void VlcProc::EnabledEvent( string type, bool state )
//---------------------------------------------------------------------------
-
//---------------------------------------------------------------------------
// Common VLC procedures
//---------------------------------------------------------------------------
void VlcProc::LoadSkin()
{
-#ifndef BASIC_SKINS
if( p_intf->p_sys->p_new_theme_file == NULL )
{
- wxFileDialog dialog( NULL,
- wxU(_("Open a skin file")), wxT(""), wxT(""),
- wxT("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
- "All files|*.*"), wxOPEN );
-
- if( dialog.ShowModal() == wxID_OK )
- {
- p_intf->p_sys->p_new_theme_file =
- new char[strlen(dialog.GetPath().mb_str()) + 1];
-
- strcpy( p_intf->p_sys->p_new_theme_file,
- dialog.GetPath().mb_str() );
-
- // Tell vlc to change skin after hiding interface
- OSAPI_PostMessage( NULL, VLC_HIDE, VLC_LOAD_SKIN, 0 );
- }
+ p_intf->p_sys->p_dialogs->ShowOpenSkin( 0 /*none blocking*/ );
}
else
{
delete Loader;
// Uninitialize new theme
- delete (char *)p_intf->p_sys->p_new_theme_file;
+ delete[] p_intf->p_sys->p_new_theme_file;
p_intf->p_sys->p_new_theme_file = NULL;
}
-#endif
}
//---------------------------------------------------------------------------
+
void VlcProc::DropFile( unsigned int param )
{
// Get pointer to file
{
if( p_intf->p_sys->p_playlist == NULL )
return;
+
if( !p_intf->p_sys->p_playlist->i_size )
+ {
+ p_intf->p_sys->p_dialogs->ShowOpen( true );
+ InterfaceRefresh();
return;
+ }
playlist_Play( p_intf->p_sys->p_playlist );