Commit 5143bba0 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/skins/*: misc fixes and clean-up. There are still thread issues when passing messages between the skins thread and the wxWindows dialogs thread that will need to be fixed.
* modules/gui/wxwindows/timer.cpp: fixed comment.
parent a87a5168
......@@ -2,7 +2,7 @@
* dialogs.cpp: Handles all the different dialog boxes we provide.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: dialogs.cpp,v 1.1 2003/06/03 22:20:00 gbazin Exp $
* $Id: dialogs.cpp,v 1.2 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -39,6 +39,10 @@
#include "skin_common.h"
#include "dialogs.h"
/* Callback prototype */
int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param );
#ifdef BASIC_SKINS
// Constructor
......@@ -47,6 +51,7 @@ Dialogs::Dialogs( intf_thread_t *_p_intf ){}
Dialogs::~Dialogs(){}
void Dialogs::ShowOpen( bool b_play ){}
void Dialogs::ShowOpenSkin(){}
void Dialogs::ShowMessages(){}
void Dialogs::ShowPrefs(){}
void Dialogs::ShowFileInfo(){}
......@@ -57,9 +62,10 @@ void Dialogs::ShowFileInfo(){}
#include "share/vlc32x32.xpm" // include the graphic icon
#define ShowOpen_Event 0
#define ShowMessages_Event 1
#define ShowPrefs_Event 2
#define ShowFileInfo_Event 3
#define ShowOpenSkin_Event 1
#define ShowMessages_Event 2
#define ShowPrefs_Event 3
#define ShowFileInfo_Event 4
#define ExitThread_Event 99
//---------------------------------------------------------------------------
......@@ -93,6 +99,7 @@ private:
BEGIN_EVENT_TABLE(Instance, wxApp)
EVT_COMMAND(ShowOpen_Event, wxEVT_DIALOG, Dialogs::OnShowOpen)
EVT_COMMAND(ShowOpenSkin_Event, wxEVT_DIALOG, Dialogs::OnShowOpenSkin)
EVT_COMMAND(ShowMessages_Event, wxEVT_DIALOG, Dialogs::OnShowMessages)
EVT_COMMAND(ShowPrefs_Event, wxEVT_DIALOG, Dialogs::OnShowPrefs)
EVT_COMMAND(ShowFileInfo_Event, wxEVT_DIALOG, Dialogs::OnShowFileInfo)
......@@ -145,7 +152,18 @@ bool Instance::OnInit()
#endif
// OK, initialization is over, now the other thread can go on working...
vlc_thread_ready( p_intf );
vlc_thread_ready( p_intf->p_sys->p_dialogs->p_thread );
/* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB,
p_intf->p_sys->p_dialogs );
vlc_object_release( p_playlist );
}
return TRUE;
}
......@@ -178,11 +196,12 @@ DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
// We create all wxWindows dialogs in a separate thread because we don't want
// any interaction with our own message loop
//---------------------------------------------------------------------------
void SkinsDialogsThread( intf_thread_t *p_intf )
void SkinsDialogsThread( dialogs_thread_t *p_thread )
{
#if !defined( WIN32 )
static char *p_args[] = { "" };
#endif
intf_thread_t *p_intf = p_thread->p_intf;
/* Hack to pass the p_intf pointer to the new wxWindow Instance object */
wxTheApp = new Instance( p_intf );
......@@ -207,10 +226,15 @@ Dialogs::Dialogs( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
p_intf->p_sys->p_dialogs = this;
b_popup_change = VLC_FALSE;
p_thread = (dialogs_thread_t *)vlc_object_create( p_intf,
sizeof(dialogs_thread_t) );
p_thread->p_intf = p_intf;
// Create a new thread for wxWindows
if( vlc_thread_create( p_intf, "Skins Dialogs Thread", SkinsDialogsThread,
0, VLC_TRUE ) )
if( vlc_thread_create( p_thread, "Skins Dialogs Thread",
SkinsDialogsThread, 0, VLC_TRUE ) )
{
OpenDlg = NULL;
msg_Err( p_intf, "cannot create SkinsDialogsThread" );
......@@ -224,7 +248,7 @@ Dialogs::~Dialogs()
wxTheApp->AddPendingEvent( event );
vlc_thread_join( p_intf ); //FIXME, use own vlc_object
vlc_thread_join( p_thread );
}
void Dialogs::ShowOpen( bool b_play )
......@@ -236,6 +260,14 @@ void Dialogs::ShowOpen( bool b_play )
wxTheApp->AddPendingEvent( event );
}
void Dialogs::ShowOpenSkin()
{
wxCommandEvent event( wxEVT_DIALOG, ShowOpenSkin_Event );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
}
void Dialogs::ShowMessages()
{
wxCommandEvent event( wxEVT_DIALOG, ShowMessages_Event );
......@@ -265,7 +297,7 @@ void Dialogs::OnShowOpen( wxCommandEvent& event )
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
bool b_play = event.GetInt() ? TRUE : FALSE;
//p_dialogs->OpenDlg->Show( !p_dialogs->OpenDlg->IsShown() );
if( p_dialogs->OpenDlg->IsShown() ) return;
if( p_dialogs->OpenDlg->ShowModal() != wxID_OK )
{
......@@ -308,6 +340,29 @@ void Dialogs::OnShowOpen( wxCommandEvent& event )
return;
}
void Dialogs::OnShowOpenSkin( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
intf_thread_t *p_intf = p_dialogs->p_intf;
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 );
}
}
void Dialogs::OnShowMessages( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
......@@ -331,3 +386,18 @@ void Dialogs::OnExitThread( wxCommandEvent& event )
wxTheApp->ExitMainLoop();
}
#endif // BASIC_SKINS
/*****************************************************************************
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
* caller to block for a too long time.
*****************************************************************************/
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->b_popup_change = VLC_TRUE;
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* dialogs.h: Dialogs class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: dialogs.h,v 1.1 2003/06/03 22:20:00 gbazin Exp $
* $Id: dialogs.h,v 1.2 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -48,6 +48,14 @@ class SoutDialog;
class PrefsDialog;
class FileInfo;
class wxIcon;
typedef struct dialogs_thread_t
{
VLC_COMMON_MEMBERS
intf_thread_t * p_intf;
} dialogs_thread_t;
#endif
//---------------------------------------------------------------------------
......@@ -64,10 +72,13 @@ class Dialogs
virtual ~Dialogs();
void ShowOpen( bool b_play );
void ShowOpenSkin();
void ShowMessages();
void ShowPrefs();
void ShowFileInfo();
vlc_bool_t b_popup_change;
#ifndef BASIC_SKINS
// Dialogs
OpenDialog *OpenDlg;
......@@ -75,9 +86,10 @@ class Dialogs
PrefsDialog *PrefsDlg;
FileInfo *FileInfoDlg;
wxIcon *p_icon;
dialogs_thread_t *p_thread;
void OnShowOpen( wxCommandEvent& event );
void OnShowOpenSkin( wxCommandEvent& event );
void OnShowMessages( wxCommandEvent& event );
void OnShowPrefs( wxCommandEvent& event );
void OnShowFileInfo( wxCommandEvent& event );
......
......@@ -2,7 +2,7 @@
* skin_common.h: Private Skin interface description
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_common.h,v 1.13 2003/06/03 22:18:58 gbazin Exp $
* $Id: skin_common.h,v 1.14 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -78,6 +78,9 @@ struct intf_sys_t
#endif
#ifdef WIN32
// Interface thread id used to post broadcast messages
DWORD dwThreadId;
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
HINSTANCE h_msimg32_dll;
BOOL (WINAPI *TransparentBlt)( HDC,int,int,int,int,HDC,int,
......
......@@ -2,7 +2,7 @@
* skin-main.cpp: skins plugin for VLC
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_main.cpp,v 1.31 2003/06/03 22:18:58 gbazin Exp $
* $Id: skin_main.cpp,v 1.32 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -133,6 +133,9 @@ static int Open ( vlc_object_t *p_this )
vlc_mutex_init( p_intf, &p_intf->p_sys->xlock );
#elif defined WIN32
// Interface thread id used to post broadcast messages
p_intf->p_sys->dwThreadId = GetCurrentThreadId();
// We dynamically load msimg32.dll to get a pointer to TransparentBlt()
p_intf->p_sys->h_msimg32_dll = LoadLibrary("msimg32.dll");
if( !p_intf->p_sys->h_msimg32_dll ||
......
......@@ -2,7 +2,7 @@
* 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.30 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -51,11 +51,6 @@
#include "skin_common.h"
#include "dialogs.h"
#ifndef BASIC_SKINS
#include "../../wxwindows/wxwindows.h"
#endif
//---------------------------------------------------------------------------
// VlcProc
//---------------------------------------------------------------------------
......@@ -103,10 +98,8 @@ bool VlcProc::EventProc( Event *evt )
return true;
case VLC_OPEN:
#ifndef BASIC_SKINS
p_intf->p_sys->p_dialogs->ShowOpen( TRUE );
InterfaceRefresh();
#endif
return true;
case VLC_LOAD_SKIN:
......@@ -138,13 +131,10 @@ bool VlcProc::EventProc( Event *evt )
return true;
case VLC_PLAYLIST_ADD_FILE:
#ifndef BASIC_SKINS
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;
......@@ -159,7 +149,6 @@ bool VlcProc::EventProc( Event *evt )
case VLC_INFO_SHOW:
p_intf->p_sys->p_dialogs->ShowFileInfo();
return true;
#endif
case VLC_INTF_REFRESH:
InterfaceRefresh( (bool)evt->GetParam2() );
......@@ -330,31 +319,14 @@ 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();
}
else
{
......@@ -392,9 +364,9 @@ void VlcProc::LoadSkin()
delete (char *)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
......
......@@ -2,7 +2,7 @@
* win32_api.cpp: Various win32-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_api.cpp,v 1.4 2003/04/21 21:51:16 asmax Exp $
* $Id: win32_api.cpp,v 1.5 2003/06/04 16:03:33 gbazin Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -29,12 +29,14 @@
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
#include <vlc/intf.h>
#include "../src/skin_common.h"
#include "../src/window.h"
#include "../os_window.h"
#include "../os_api.h"
#include "../src/event.h" // for MAX_PARAM_SIZE
extern intf_thread_t *g_pIntf; // ugly, but it's not my fault ;)
//---------------------------------------------------------------------------
// Event API
......@@ -53,7 +55,8 @@ void OSAPI_PostMessage( SkinWindow *win, unsigned int message, unsigned int para
long param2 )
{
if( win == NULL )
PostMessage( NULL, message, param1, param2 );
PostThreadMessage( g_pIntf->p_sys->dwThreadId, message, param1,
param2 );
else
PostMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
param2 );
......
......@@ -2,7 +2,7 @@
* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: timer.cpp,v 1.20 2003/05/27 11:35:34 gbazin Exp $
* $Id: timer.cpp,v 1.21 2003/06/04 16:03:34 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -318,8 +318,8 @@ void DisplayStreamDate( wxControl *p_slider_frame, intf_thread_t * p_intf ,
}
/*****************************************************************************
* PlaylistChanged: callback triggered by the intf-change playlist variable
* We don't rebuild the playlist directly here because we don't want the
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
* caller to block for a too long time.
*****************************************************************************/
int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
......
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