]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/src/skin_main.cpp
* got rid of this useless error message
[vlc] / modules / gui / skins / src / skin_main.cpp
index 5c0d743176502bd3e3cced5313dfa7a8e845e7d0..a90cd8d823e0ddd3922ef84bc355e1c2f0f7d8b0 100644 (file)
@@ -2,7 +2,7 @@
  * skin-main.cpp: skins plugin for VLC
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.20 2003/04/28 12:00:14 asmax Exp $
+ * $Id: skin_main.cpp,v 1.33 2003/06/06 23:34:35 asmax Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
  * USA.
  *****************************************************************************/
 
-//--- GENERAL ---------------------------------------------------------------
-#include <wx/wx.h>
-
 //--- VLC -------------------------------------------------------------------
 #include <vlc/vlc.h>
 #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"
-#include "wxdialogs.h"
+#include "dialogs.h"
 
+#ifndef BASIC_SKINS
+#include "../../wxwindows/wxwindows.h"
+#endif
+
+#ifdef X11_SKINS
+#include <X11/Xlib.h>
+#endif
 
 //---------------------------------------------------------------------------
 // Interface thread
@@ -94,11 +109,10 @@ static int Open ( vlc_object_t *p_this )
     // Set no new theme when opening file
     p_intf->p_sys->p_new_theme_file = NULL;
 
-    // Initialize Win32 thread
+    // Initialize info on playlist
     p_intf->p_sys->i_index        = -1;
     p_intf->p_sys->i_size         = 0;
 
-
     p_intf->p_sys->i_close_status = VLC_NOTHING;
 
     p_intf->p_sys->p_input = NULL;
@@ -112,11 +126,42 @@ static int Open ( vlc_object_t *p_this )
     char **pp_args  = p_args;
 
     gdk_init( &i_args, &pp_args );
-#endif
 
-    // Initialize conditions and mutexes
-    vlc_mutex_init( p_intf, &p_intf->p_sys->init_lock );
-    vlc_cond_init( p_intf, &p_intf->p_sys->init_cond );
+#elif defined X11_SKINS
+    // Initialize X11
+    p_intf->p_sys->display = XOpenDisplay( NULL );
+    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 ||
+        !( p_intf->p_sys->TransparentBlt =
+           (BOOL (WINAPI*)(HDC,int,int,int,int,HDC,
+                           int,int,int,int,unsigned int))
+           GetProcAddress( p_intf->p_sys->h_msimg32_dll, "TransparentBlt" ) ) )
+    {
+        p_intf->p_sys->TransparentBlt = NULL;
+        msg_Dbg( p_intf, "Couldn't find TransparentBlt(), "
+                 "falling back to BitBlt()" );
+    }
+
+    // idem for user32.dll and SetLayeredWindowAttributes()
+    p_intf->p_sys->h_user32_dll = LoadLibrary("user32.dll");
+    if( !p_intf->p_sys->h_user32_dll ||
+        !( p_intf->p_sys->SetLayeredWindowAttributes =
+           (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))
+           GetProcAddress( p_intf->p_sys->h_user32_dll,
+                           "SetLayeredWindowAttributes" ) ) )
+    {
+        p_intf->p_sys->SetLayeredWindowAttributes = NULL;
+        msg_Dbg( p_intf, "Couldn't find SetLayeredWindowAttributes()" );
+    }
+
+#endif
 
     p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
 
@@ -130,7 +175,6 @@ static void Close ( vlc_object_t *p_this )
 {
     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 );
@@ -147,9 +191,15 @@ static void Close ( vlc_object_t *p_this )
     // Unsuscribe to messages bank
     msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
 
-    // Destroy conditions and mutexes
-    vlc_cond_destroy( &p_intf->p_sys->init_cond );
-    vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+#ifdef WIN32
+    // Unload msimg32.dll and user32.dll
+    if( p_intf->p_sys->h_msimg32_dll )
+        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
     free( p_intf->p_sys );
@@ -164,6 +214,13 @@ static void Run( intf_thread_t *p_intf )
 
     int a = OSAPI_GetTime();
 
+#ifndef BASIC_SKINS
+    // Initialize the dialog boxes
+    p_intf->p_sys->p_dialogs = new Dialogs( p_intf );
+    if( !p_intf->p_sys->p_dialogs ||
+        !p_intf->p_sys->p_dialogs->OpenDlg ) return;
+#endif
+
     // Load a theme
     char *skin_last = config_GetPsz( p_intf, "skin_last" );
     ThemeLoader *Loader = new ThemeLoader( p_intf );
@@ -190,14 +247,16 @@ static void Run( intf_thread_t *p_intf )
 #endif
         {
             // Last chance: the user can  select a new theme file
-            wxFileDialog dialog( NULL, _("Open a skin file"), "", "",
-                "Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
-                    "All files|*.*", wxOPEN );
+#ifndef BASIC_SKINS
+            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;
@@ -205,6 +264,7 @@ static void Run( intf_thread_t *p_intf )
                 }
             }
             else
+#endif
             {
                 delete Loader;
                 return;
@@ -218,12 +278,17 @@ static void Run( intf_thread_t *p_intf )
 
     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 );
+
+#ifndef BASIC_SKINS
+    // clean up the dialog boxes
+    delete p_intf->p_sys->p_dialogs;
+#endif
 }
 
 //---------------------------------------------------------------------------
@@ -250,7 +315,6 @@ vlc_module_begin();
     set_description( _("Skinnable Interface") );
     set_capability( "interface", 30 );
     set_callbacks( Open, Close );
-    add_shortcut( "skins" );
 vlc_module_end();
 
 
@@ -275,11 +339,13 @@ int SkinManage( intf_thread_t *p_intf )
 
     OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false );
 
+#ifndef BASIC_SKINS //FIXME
     // Update the log window
-    p_intf->p_sys->MessagesDlg->UpdateLog();
+    p_intf->p_sys->p_dialogs->MessagesDlg->UpdateLog();
 
     // Update the file info window
-    p_intf->p_sys->InfoDlg->UpdateFileInfo();
+    p_intf->p_sys->p_dialogs->FileInfoDlg->UpdateFileInfo();
+#endif
 
     //-------------------------------------------------------------------------
     if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )