Commit 035792d5 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/*: The wxwindows interface is now a "dialogs provider" module as well as a normal "interface".
   Dialog providers expose an api that allow other modules to use the GUI dialogs the module provides (open dialogs, etc...).
   + misc small enhancements.

* modules/gui/skins/*: completely removed the dependancy on the wxwindows code (which also eliminates the need for the basic_skins module).
   The skins module will now try to load a "dialogs provider" to display the open, messages, file info and preferences dialogs.
parent 5cc5eba2
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.33 2003/07/17 14:54:26 sam Exp $
dnl $Id: configure.ac,v 1.34 2003/07/17 17:30:39 gbazin Exp $
AC_INIT(vlc,0.6.0)
......@@ -1705,7 +1705,7 @@ dnl
dnl MP4 module
dnl
AC_CHECK_HEADERS(zlib.h, [
AX_ADD_LDFLAGS([mp4 skins basic_skins],[-lz])
AX_ADD_LDFLAGS([mp4 skins],[-lz])
] )
......@@ -1713,7 +1713,7 @@ dnl
dnl skins module
dnl
AC_CHECK_HEADERS(libtar.h, [
AX_ADD_LDFLAGS([skins basic_skins],[-ltar])
AX_ADD_LDFLAGS([skins],[-ltar])
] )
......@@ -2422,72 +2422,25 @@ dnl
AC_ARG_ENABLE(skins,
[ --enable-skins Skins interface module (default enabled on Win32)])
if test "${enable_skins}" != "no"; then
WXWINDOWS_PATH="${PATH}"
AC_ARG_WITH(skins-wx-config-path,
[ --with-skins-wx-config-path=PATH wx-config path for the skins plugin (default search in \$PATH)],
[ if test "${with_skins_wx_config_path}" != "no"
then
WXWINDOWS_PATH="${with_skins_wx_config_path}:${PATH}"
fi ])
# look for wx-config
AC_PATH_PROG(WX_CONFIG_SKINS, wx-config, no, ${WXWINDOWS_PATH})
if test "${WX_CONFIG_SKINS}" != "no"
then
if expr 2.3.0 \> `${WX_CONFIG_SKINS} --version` >/dev/null
then
AC_MSG_ERROR([Your development package for wxWindows is too old, you need at least version 2.3.0. Please upgrade and try again. Alternatively you can also configure with --disable-skins.])
fi
AX_ADD_CPPFLAGS([skins],[`${WX_CONFIG_SKINS} --cxxflags` -DWX_SKINS])
AX_ADD_LDFLAGS([skins],[`${WX_CONFIG_SKINS} --libs`])
fi
if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"; then
AX_ADD_PLUGINS([skins])
AX_ADD_CPPFLAGS([skins],[-U_OFF_T_ -U_off_t -Imodules/gui/skins])
AX_ADD_CXXFLAGS([skins],[-O2 -fno-rtti])
AX_ADD_LDFLAGS([skins],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32])
else
if test "${enable_skins}" = "yes"; then
IMLIB2_PATH="${PATH}"
AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
if test "${IMLIB2_CONFIG_SKINS}" = "no"; then
AC_MSG_ERROR([Couldn't find the imlib2 package. You can download imlib2 from http://enlightenment.org/, or configure with --disable-skins.])
fi
AX_ADD_PLUGINS([skins])
AX_ADD_CPPFLAGS([skins],[-Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS])
AX_ADD_CXXFLAGS([skins],[-O2 -fno-rtti])
AX_ADD_LDFLAGS([skins],[-L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`])
AX_ADD_PLUGINS([skins])
fi
fi
fi
dnl
dnl Basic skins module (i.e. without wxWindows dialogs)
dnl
AC_ARG_ENABLE(basic-skins,
[ --enable-basic-skins Skins interface module without wxWindows dialogs (default disabled)])
if test "${enable_basic_skins}" = "yes"; then
if test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"; then
AX_ADD_CPPFLAGS([basic_skins],[-U_OFF_T_ -U_off_t -Imodules/gui/skins])
AX_ADD_CXXFLAGS([basic_skins],[-O2 -fno-rtti])
AX_ADD_LDFLAGS([basic_skins],[-loleaut32 -lwinspool -lwinmm -lshell32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32])
else
else if test "${enable_skins}" = "yes"; then
IMLIB2_PATH="${PATH}"
AC_PATH_PROG(IMLIB2_CONFIG_SKINS, imlib2-config, no, ${IMLIB2_PATH})
if test "${IMLIB2_CONFIG_SKINS}" = "no"; then
AC_MSG_ERROR([Couldn't find the imlib2 package. You can download imlib2 from http://enlightenment.org/, or configure with --disable-basic-skins.])
AC_MSG_ERROR([Couldn't find the imlib2 package. You can download imlib2 from http://enlightenment.org/, or configure with --disable-skins.])
fi
AX_ADD_CPPFLAGS([basic_skins],[-Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS])
AX_ADD_CXXFLAGS([basic_skins],[-O2 -fno-rtti])
AX_ADD_LDFLAGS([basic_skins],[-L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`])
fi
AX_ADD_PLUGINS([basic_skins])
AX_ADD_PLUGINS([skins])
AX_ADD_CPPFLAGS([skins],[-Imodules/gui/skins -I${x_includes} `${IMLIB2_CONFIG_SKINS} --cflags` -DX11_SKINS])
AX_ADD_CXXFLAGS([skins],[-O2 -fno-rtti])
AX_ADD_LDFLAGS([skins],[-L${x_libraries} -lXext -lX11 `${IMLIB2_CONFIG_SKINS} --libs`])
fi fi
fi
dnl
......
......@@ -4,7 +4,7 @@
* interface, such as message output.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: vlc_interface.h,v 1.1 2003/06/24 13:33:49 sam Exp $
* $Id: vlc_interface.h,v 1.2 2003/07/17 17:30:40 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -44,6 +44,9 @@ struct intf_thread_t
module_t * p_module;
void ( *pf_run ) ( intf_thread_t * );
/* Specific for dialogs providers */
void ( *pf_show_dialog ) ( intf_thread_t *, int, int );
/* XXX: new message passing stuff will go here */
vlc_mutex_t change_lock;
vlc_bool_t b_menu_change;
......@@ -76,3 +79,15 @@ VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
#else
# define CONSOLE_INTRO_MSG
#endif
/* Interface dialog ids for dialog providers */
#define INTF_DIALOG_FILE_SIMPLE 1
#define INTF_DIALOG_FILE 2
#define INTF_DIALOG_DISC 3
#define INTF_DIALOG_NET 4
#define INTF_DIALOG_SAT 5
#define INTF_DIALOG_PLAYLIST 10
#define INTF_DIALOG_MESSAGES 11
#define INTF_DIALOG_FILEINFO 12
#define INTF_DIALOG_PREFS 13
SOURCES_skins = \
os_api.h \
os_bitmap.h \
os_event.h \
os_font.h \
os_graphics.h \
os_theme.h \
os_window.h \
\
controls/controls.h \
controls/button.cpp \
controls/button.h \
controls/checkbox.cpp \
controls/checkbox.h \
controls/generic.cpp \
controls/generic.h \
controls/image.cpp \
controls/image.h \
controls/playlist.cpp \
controls/playlist.h \
controls/rectangle.cpp \
controls/rectangle.h \
controls/slider.cpp \
controls/slider.h \
controls/text.cpp \
controls/text.h \
\
parser/flex.c \
parser/skin.h \
parser/skin.c \
parser/wrappers.h \
parser/wrappers.cpp \
\
src/anchor.cpp \
src/anchor.h \
src/banks.cpp \
src/banks.h \
src/bezier.cpp \
src/bezier.h \
src/bitmap.cpp \
src/bitmap.h \
src/dialogs.cpp \
src/dialogs.h \
src/event.cpp \
src/event.h \
src/font.cpp \
src/font.h \
src/graphics.cpp \
src/graphics.h \
src/skin_main.cpp \
src/skin_common.h \
src/theme.cpp \
src/theme.h \
src/themeloader.cpp \
src/themeloader.h \
src/vlcproc.cpp \
src/vlcproc.h \
src/window.cpp \
src/window.h \
\
win32/win32_api.cpp \
win32/win32_bitmap.cpp \
win32/win32_bitmap.h \
win32/win32_dragdrop.cpp \
win32/win32_dragdrop.h \
win32/win32_event.cpp \
win32/win32_event.h \
win32/win32_font.cpp \
win32/win32_font.h \
win32/win32_graphics.cpp \
win32/win32_graphics.h \
win32/win32_run.cpp \
win32/win32_theme.cpp \
win32/win32_theme.h \
win32/win32_window.cpp \
win32/win32_window.h \
\
x11/x11_api.cpp \
x11/x11_bitmap.cpp \
x11/x11_bitmap.h \
x11/x11_dragdrop.cpp \
x11/x11_dragdrop.h \
x11/x11_event.cpp \
x11/x11_event.h \
x11/x11_font.cpp \
x11/x11_font.h \
x11/x11_graphics.cpp \
x11/x11_graphics.h \
x11/x11_run.cpp \
x11/x11_theme.cpp \
x11/x11_theme.h \
x11/x11_timer.cpp \
x11/x11_timer.h \
x11/x11_window.cpp \
x11/x11_window.h \
\
../wxwindows/wxwindows.h \
../wxwindows/fileinfo.cpp \
../wxwindows/messages.cpp \
../wxwindows/open.cpp \
../wxwindows/preferences.cpp \
../wxwindows/streamout.cpp \
../wxwindows/subtitles.cpp \
../wxwindows/menus.cpp \
$(NULL)
SOURCES_basic_skins = \
os_api.h \
os_bitmap.h \
os_event.h \
......
/*****************************************************************************
* dialogs.cpp: Handles all the different dialog boxes we provide.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: dialogs.cpp,v 1.9 2003/07/13 14:55:17 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
* 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
* 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
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "../os_api.h"
#include "event.h"
#include "banks.h"
#include "theme.h"
#include "../os_theme.h"
#include "themeloader.h"
#include "window.h"
#include "vlcproc.h"
#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 );
#if defined(MODULE_NAME_IS_basic_skins)
// Constructor
Dialogs::Dialogs( intf_thread_t *_p_intf ){}
// Destructor
Dialogs::~Dialogs(){}
void Dialogs::ShowOpen( bool b_play ){}
void Dialogs::ShowOpenSkin(){}
void Dialogs::ShowMessages(){}
void Dialogs::ShowPrefs(){}
void Dialogs::ShowFileInfo(){}
void Dialogs::ShowPopup(){}
#else // !MODULE_NAME_IS_basic_skins
#include "../../wxwindows/wxwindows.h"
#include "../../../../share/vlc32x32.xpm" // include the graphic icon
#define ShowOpen_Event 0
#define ShowOpenSkin_Event 1
#define ShowMessages_Event 2
#define ShowPrefs_Event 3
#define ShowFileInfo_Event 4
#define ShowPopup_Event 5
#define ExitThread_Event 99
//---------------------------------------------------------------------------
// Local classes declarations.
//---------------------------------------------------------------------------
DEFINE_EVENT_TYPE(wxEVT_DIALOG)
class Instance: public wxApp
{
public:
Instance();
Instance( intf_thread_t *_p_intf );
bool OnInit();
int OnExit();
private:
intf_thread_t *p_intf;
DECLARE_EVENT_TABLE();
};
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)
EVT_COMMAND(ShowPopup_Event, wxEVT_DIALOG, Dialogs::OnShowPopup)
EVT_COMMAND(ExitThread_Event, wxEVT_DIALOG, Dialogs::OnExitThread)
END_EVENT_TABLE()
//---------------------------------------------------------------------------
// Implementation of Instance class
//---------------------------------------------------------------------------
Instance::Instance( )
{
}
Instance::Instance( intf_thread_t *_p_intf )
{
// Initialization
p_intf = _p_intf;
}
IMPLEMENT_APP_NO_MAIN(Instance)
bool Instance::OnInit()
{
p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
// Create all the dialog boxes
p_intf->p_sys->p_dialogs->OpenDlg =
new OpenDialog( p_intf, NULL, FILE_ACCESS );
p_intf->p_sys->p_dialogs->MessagesDlg = new Messages( p_intf, NULL );
p_intf->p_sys->p_dialogs->PrefsDlg = new PrefsDialog( p_intf, NULL );
p_intf->p_sys->p_dialogs->FileInfoDlg = new FileInfo( p_intf, NULL );
// OK, initialization is over, now the other thread can go on working...
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 );
}
/* Intercept all menu events in our custom event handler */
p_intf->p_sys->p_dialogs->OpenDlg->PushEventHandler(
new MenuEvtHandler( p_intf, NULL ) );
return TRUE;
}
int Instance::OnExit()
{
// Delete evertything
delete p_intf->p_sys->p_dialogs->FileInfoDlg;
delete p_intf->p_sys->p_dialogs->PrefsDlg;
delete p_intf->p_sys->p_dialogs->MessagesDlg;
delete p_intf->p_sys->p_dialogs->OpenDlg;
delete p_intf->p_sys->p_icon;
return 0;
}
//---------------------------------------------------------------------------
#if !defined(__BUILTIN__) && defined( WIN32 )
HINSTANCE hInstance = 0;
extern "C" BOOL WINAPI
DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
{
hInstance = (HINSTANCE)hModule;
return TRUE;
}
#endif
//---------------------------------------------------------------------------
// Thread callback
// We create all wxWindows dialogs in a separate thread because we don't want
// any interaction with our own message loop
//---------------------------------------------------------------------------
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 );
#if defined( WIN32 )
#if !defined(__BUILTIN__)
wxEntry( hInstance/*GetModuleHandle(NULL)*/, NULL, NULL, SW_SHOW, TRUE );
#else
wxEntry( GetModuleHandle( NULL ), NULL, NULL, SW_SHOW, TRUE );
#endif
#else
wxEntry( 1, p_args );
#endif
return;
}
//---------------------------------------------------------------------------
// Implementation of Dialogs class
//---------------------------------------------------------------------------
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_thread, "Skins Dialogs Thread",
SkinsDialogsThread, 0, VLC_TRUE ) )
{
OpenDlg = NULL;
msg_Err( p_intf, "cannot create SkinsDialogsThread" );
}
}
Dialogs::~Dialogs()
{
wxCommandEvent event( wxEVT_DIALOG, ExitThread_Event );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
vlc_thread_join( p_thread );
}
void Dialogs::ShowOpen( bool b_play )
{
wxCommandEvent event( wxEVT_DIALOG, ShowOpen_Event );
event.SetClientData( this );
event.SetInt( 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 );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
}
void Dialogs::ShowPrefs()
{
wxCommandEvent event( wxEVT_DIALOG, ShowPrefs_Event );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
}
void Dialogs::ShowFileInfo()
{
wxCommandEvent event( wxEVT_DIALOG, ShowFileInfo_Event );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
}
void Dialogs::ShowPopup()
{
wxCommandEvent event( wxEVT_DIALOG, ShowPopup_Event );
event.SetClientData( this );
wxTheApp->AddPendingEvent( event );
}
void Dialogs::OnShowOpen( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
bool b_play = event.GetInt() ? TRUE : FALSE;
if( p_dialogs->OpenDlg->IsShown() ) return;
if( p_dialogs->OpenDlg->ShowModal() != wxID_OK )
{
return;
}
// Check if playlist is available
playlist_t *p_playlist = p_dialogs->p_intf->p_sys->p_playlist;
if( p_playlist == NULL )
{
return;
}
if( b_play )
{
// Append and play
for( size_t i = 0; i < p_dialogs->OpenDlg->mrl.GetCount(); i++ )
{
playlist_Add( p_playlist,
(const char *)p_dialogs->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
}
p_dialogs->p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
}
else
{
// Append only
for( size_t i = 0; i < p_dialogs->OpenDlg->mrl.GetCount(); i++ )
{
playlist_Add( p_playlist,
(const char *)p_dialogs->OpenDlg->mrl[i].mb_str(),
PLAYLIST_APPEND, PLAYLIST_END );
}
}
// Refresh interface !
p_dialogs->p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" )
->PostSynchroMessage();
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();
p_dialogs->MessagesDlg->Show( !p_dialogs->MessagesDlg->IsShown() );
}
void Dialogs::OnShowPrefs( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
p_dialogs->PrefsDlg->Show( !p_dialogs->PrefsDlg->IsShown() );
}
void Dialogs::OnShowFileInfo( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
p_dialogs->FileInfoDlg->Show( !p_dialogs->FileInfoDlg->IsShown() );
}
void Dialogs::OnShowPopup( wxCommandEvent& event )
{
Dialogs *p_dialogs = (Dialogs *)event.GetClientData();
wxPoint mousepos = wxGetMousePosition();
wxMouseEvent mouseevent = wxMouseEvent( wxEVT_RIGHT_UP );
mouseevent.m_x = p_dialogs->OpenDlg->ScreenToClient(mousepos).x;
mouseevent.m_y = p_dialogs->OpenDlg->ScreenToClient(mousepos).y;
::PopupMenu( p_dialogs->p_intf,
p_dialogs->OpenDlg, mouseevent.GetPosition() );
}
void Dialogs::OnExitThread( wxCommandEvent& event )
{
wxTheApp->ExitMainLoop();
}
#endif // MODULE_NAME_IS_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 )
{
#if !defined(MODULE_NAME_IS_basic_skins)
Dialogs *p_dialogs = (Dialogs *)param;
p_dialogs->ShowPopup();
#endif
return VLC_SUCCESS;