* skin-main.cpp: skins plugin for VLC
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.28 2003/05/26 19:06:47 gbazin Exp $
+ * $Id: skin_main.cpp,v 1.45 2003/07/17 17:30:40 gbazin Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
#include <vlc/intf.h>
#include <vlc/aout.h>
-//--- GENERAL ---------------------------------------------------------------
-#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 "themeloader.h"
#include "vlcproc.h"
#include "skin_common.h"
-#ifndef BASIC_SKINS
-#include "../../wxwindows/wxwindows.h"
-#endif
+#include "dialogs.h"
#ifdef X11_SKINS
#include <X11/Xlib.h>
+#include <Imlib2.h>
#endif
//---------------------------------------------------------------------------
};
p_intf->pf_run = Run;
+ p_intf->p_sys->pf_showdialog = Dialogs::ShowDialog;
// Suscribe to messages bank
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-#ifdef GTK2_SKINS
- // Initialize GDK
- int i_args = 3;
- char *p_args[] = { "", "", "--sync", NULL };
- char **pp_args = p_args;
-
- gdk_init( &i_args, &pp_args );
-
-#elif defined X11_SKINS
+#if defined X11_SKINS
// Initialize X11
- p_intf->p_sys->display = XOpenDisplay( NULL );
+ Display *display = XOpenDisplay( NULL );
+ p_intf->p_sys->display = display;
+ vlc_mutex_init( p_intf, &p_intf->p_sys->xlock );
+ // Fake window to receive broadcast events
+ Window root = DefaultRootWindow( display );
+ p_intf->p_sys->mainWin = XCreateSimpleWindow( display, root, 0, 0,
+ 1, 1, 0, 0, 0 );
+ XStoreName( display, p_intf->p_sys->mainWin, "VLC Media Player" );
+
+ // Load the vlc icon
+ int screen = DefaultScreen( display );
+ Screen *screenptr = DefaultScreenOfDisplay( display );
+ Visual *visual = DefaultVisualOfScreen( screenptr );
+ imlib_context_set_display( display );
+ imlib_context_set_visual( visual );
+ imlib_context_set_drawable( root );
+ imlib_context_set_colormap( DefaultColormap( display, screen ) );
+ imlib_context_set_dither( 1 );
+ imlib_context_set_blend( 1 );
+ Imlib_Image img = imlib_load_image_immediately( DATA_PATH"/vlc32x32.png" );
+ if( img == NULL )
+ {
+ // for developers ;)
+ img = imlib_load_image_immediately( "./share/vlc32x32.png" );
+ }
+ if( img == NULL )
+ {
+ msg_Err( p_intf, "loading vlc icon failed" );
+ p_intf->p_sys->iconPixmap = None;
+ p_intf->p_sys->iconMask = None;
+ }
+ else
+ {
+ imlib_context_set_image( img );
+ imlib_render_pixmaps_for_whole_image( &p_intf->p_sys->iconPixmap,
+ &p_intf->p_sys->iconMask );
+ imlib_free_image();
+ }
+
#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 ||
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
-
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
// Delete theme, it's important to do it correctly
delete (OSTheme *)p_intf->p_sys->p_theme;
+#if defined X11_SKINS
+ XDestroyWindow( p_intf->p_sys->display, p_intf->p_sys->mainWin );
+ XCloseDisplay( p_intf->p_sys->display );
+#endif
+
// Unsuscribe to messages bank
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
FreeLibrary( p_intf->p_sys->h_msimg32_dll );
if( p_intf->p_sys->h_user32_dll )
FreeLibrary( p_intf->p_sys->h_user32_dll );
+#elif defined X11_SKINS
+ vlc_mutex_destroy( &p_intf->p_sys->xlock );
#endif
// Destroy structure
int a = OSAPI_GetTime();
+ // Initialize the dialog boxes
+ p_intf->p_sys->p_dialogs = new Dialogs( p_intf );
+ if( !p_intf->p_sys->p_dialogs ) return;
+
// Load a theme
char *skin_last = config_GetPsz( p_intf, "skin_last" );
ThemeLoader *Loader = new ThemeLoader( p_intf );
if( skin_last == NULL || ! Loader->Load( skin_last ) )
{
// Too bad, it failed. Let's try with the default theme
-#if 0
- if( ! Loader->Load( DEFAULT_SKIN_FILE ) )
-#else
+// if( ! Loader->Load( DEFAULT_SKIN_FILE ) )
#ifdef WIN32
string default_dir = (string)p_intf->p_libvlc->psz_vlcpath +
DIRECTORY_SEPARATOR + "skins" +
DIRECTORY_SEPARATOR + "default" +
DIRECTORY_SEPARATOR + "theme.xml";
-#else
-// FIXME: find VLC directory
- string default_dir = (string)"./share" +
- DIRECTORY_SEPARATOR + "skins" +
- DIRECTORY_SEPARATOR + "default" +
- DIRECTORY_SEPARATOR + "theme.xml";
-#endif
if( ! Loader->Load( default_dir ) )
-#endif
{
// Last chance: the user can select a new theme file
-// FIXME: wxWindows isn't initialized yet !!!
+#else
+ string user_skin = (string)p_intf->p_vlc->psz_homedir +
+ DIRECTORY_SEPARATOR + CONFIG_DIR +
+ DIRECTORY_SEPARATOR + "skins" +
+ DIRECTORY_SEPARATOR + "default" +
+ DIRECTORY_SEPARATOR + "theme.xml";
+
+ string default_skin = (string)DATA_PATH +
+ DIRECTORY_SEPARATOR + "skins" +
+ DIRECTORY_SEPARATOR + "default" +
+ DIRECTORY_SEPARATOR + "theme.xml";
+ if( !Loader->Load( user_skin ) && !Loader->Load( default_skin ) )
+ {
+#endif
#if 0
-#ifndef BASIC_SKINS
- wxFileDialog dialog( NULL, _("Open a skin file"), "", "",
- "Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
- "All files|*.*", wxOPEN );
+#if !defined(MODULE_NAME_IS_basic_skins)
+ wxMutexGuiEnter();
+ 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 )
{
// try to load selected file
- if( ! Loader->Load( dialog.GetPath().c_str() ) )
+ if( ! Loader->Load( (string)dialog.GetPath().mb_str() ) )
{
// He, he, what the hell is he doing ?
delete Loader;
+ wxMutexGuiLeave();
return;
}
+ wxMutexGuiLeave();
}
else
#endif
#endif
{
delete Loader;
+#if 0
+#if !defined(MODULE_NAME_IS_basic_skins)
+ wxMutexGuiLeave();
+#endif
+#endif
return;
}
}
delete Loader;
- msg_Err( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a );
+ msg_Dbg( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a );
- // Refresh the whole interface
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true );
OSRun( p_intf );
+
+ // clean up the dialog boxes
+ delete p_intf->p_sys->p_dialogs;
}
//---------------------------------------------------------------------------
p_intf->p_sys->p_input = NULL;
}
- OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false );
-
-#ifndef BASIC_SKINS
- // Update the log window
- p_intf->p_sys->MessagesDlg->UpdateLog();
-
- // Update the file info window
- p_intf->p_sys->InfoDlg->UpdateFileInfo();
-#endif
-
//-------------------------------------------------------------------------
if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )
{
p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" ),
(long)( volume * SLIDER_RANGE / AOUT_VOLUME_MAX ) );
-
// Refresh slider
// if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
if( p_input->stream.b_seekable )