]> git.sesse.net Git - vlc/commitdiff
* modules/gui/skins/*: misc fixes and clean-up. There are still thread issues when...
authorGildas Bazin <gbazin@videolan.org>
Wed, 4 Jun 2003 16:03:34 +0000 (16:03 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 4 Jun 2003 16:03:34 +0000 (16:03 +0000)
* modules/gui/wxwindows/timer.cpp: fixed comment.

modules/gui/skins/src/dialogs.cpp
modules/gui/skins/src/dialogs.h
modules/gui/skins/src/skin_common.h
modules/gui/skins/src/skin_main.cpp
modules/gui/skins/src/vlcproc.cpp
modules/gui/skins/win32/win32_api.cpp
modules/gui/wxwindows/timer.cpp

index b44e7a2da936ee6cd3979a509ac00a2a902d6de4..d63039758d1292caecc3c021dc0cbfc1ddced242 100644 (file)
@@ -2,7 +2,7 @@
  * dialogs.cpp: Handles all the different dialog boxes we provide.\r
  *****************************************************************************\r
  * Copyright (C) 2003 VideoLAN\r
- * $Id: dialogs.cpp,v 1.1 2003/06/03 22:20:00 gbazin Exp $\r
+ * $Id: dialogs.cpp,v 1.2 2003/06/04 16:03:33 gbazin Exp $\r
  *\r
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>\r
  *          Emmanuel Puig    <karibu@via.ecp.fr>\r
 #include "skin_common.h"\r
 #include "dialogs.h"\r
 \r
+/* Callback prototype */\r
+int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,\r
+                 vlc_value_t old_val, vlc_value_t new_val, void *param );\r
+\r
 #ifdef BASIC_SKINS\r
 \r
 // Constructor\r
@@ -47,6 +51,7 @@ Dialogs::Dialogs( intf_thread_t *_p_intf ){}
 Dialogs::~Dialogs(){}\r
 \r
 void Dialogs::ShowOpen( bool b_play ){}\r
+void Dialogs::ShowOpenSkin(){}\r
 void Dialogs::ShowMessages(){}\r
 void Dialogs::ShowPrefs(){}\r
 void Dialogs::ShowFileInfo(){}\r
@@ -57,9 +62,10 @@ void Dialogs::ShowFileInfo(){}
 #include "share/vlc32x32.xpm"       // include the graphic icon\r
 \r
 #define ShowOpen_Event     0\r
-#define ShowMessages_Event 1\r
-#define ShowPrefs_Event    2\r
-#define ShowFileInfo_Event 3\r
+#define ShowOpenSkin_Event 1\r
+#define ShowMessages_Event 2\r
+#define ShowPrefs_Event    3\r
+#define ShowFileInfo_Event 4\r
 #define ExitThread_Event   99\r
 \r
 //---------------------------------------------------------------------------\r
@@ -93,6 +99,7 @@ private:
 \r
 BEGIN_EVENT_TABLE(Instance, wxApp)\r
     EVT_COMMAND(ShowOpen_Event, wxEVT_DIALOG, Dialogs::OnShowOpen)\r
+    EVT_COMMAND(ShowOpenSkin_Event, wxEVT_DIALOG, Dialogs::OnShowOpenSkin)\r
     EVT_COMMAND(ShowMessages_Event, wxEVT_DIALOG, Dialogs::OnShowMessages)\r
     EVT_COMMAND(ShowPrefs_Event, wxEVT_DIALOG, Dialogs::OnShowPrefs)\r
     EVT_COMMAND(ShowFileInfo_Event, wxEVT_DIALOG, Dialogs::OnShowFileInfo)\r
@@ -145,7 +152,18 @@ bool Instance::OnInit()
 #endif\r
 \r
     // OK, initialization is over, now the other thread can go on working...\r
-    vlc_thread_ready( p_intf );\r
+    vlc_thread_ready( p_intf->p_sys->p_dialogs->p_thread );\r
+\r
+    /* Register callback for the intf-popupmenu variable */\r
+    playlist_t *p_playlist =\r
+        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,\r
+                                       FIND_ANYWHERE );\r
+    if( p_playlist != NULL )\r
+    {\r
+        var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB,\r
+                        p_intf->p_sys->p_dialogs );\r
+        vlc_object_release( p_playlist );\r
+    }\r
 \r
     return TRUE;\r
 }\r
@@ -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\r
 // any interaction with our own message loop\r
 //---------------------------------------------------------------------------\r
-void SkinsDialogsThread( intf_thread_t *p_intf )\r
+void SkinsDialogsThread( dialogs_thread_t *p_thread )\r
 {\r
 #if !defined( WIN32 )\r
     static char  *p_args[] = { "" };\r
 #endif\r
+    intf_thread_t *p_intf = p_thread->p_intf;\r
 \r
     /* Hack to pass the p_intf pointer to the new wxWindow Instance object */\r
     wxTheApp = new Instance( p_intf );\r
@@ -207,10 +226,15 @@ Dialogs::Dialogs( intf_thread_t *_p_intf )
 {\r
     p_intf = _p_intf;\r
     p_intf->p_sys->p_dialogs = this;\r
+    b_popup_change = VLC_FALSE;\r
+\r
+    p_thread = (dialogs_thread_t *)vlc_object_create( p_intf,\r
+                                                sizeof(dialogs_thread_t) );\r
+    p_thread->p_intf = p_intf;\r
 \r
     // Create a new thread for wxWindows\r
-    if( vlc_thread_create( p_intf, "Skins Dialogs Thread", SkinsDialogsThread,\r
-                           0, VLC_TRUE ) )\r
+    if( vlc_thread_create( p_thread, "Skins Dialogs Thread",\r
+                          SkinsDialogsThread, 0, VLC_TRUE ) )\r
     {\r
         OpenDlg = NULL;\r
         msg_Err( p_intf, "cannot create SkinsDialogsThread" );\r
@@ -224,7 +248,7 @@ Dialogs::~Dialogs()
 \r
     wxTheApp->AddPendingEvent( event );\r
 \r
-    vlc_thread_join( p_intf ); //FIXME, use own vlc_object\r
+    vlc_thread_join( p_thread );\r
 }\r
 \r
 void Dialogs::ShowOpen( bool b_play )\r
@@ -236,6 +260,14 @@ void Dialogs::ShowOpen( bool b_play )
     wxTheApp->AddPendingEvent( event );\r
 }\r
 \r
+void Dialogs::ShowOpenSkin()\r
+{\r
+    wxCommandEvent event( wxEVT_DIALOG, ShowOpenSkin_Event );\r
+    event.SetClientData( this );\r
+\r
+    wxTheApp->AddPendingEvent( event );\r
+}\r
+\r
 void Dialogs::ShowMessages()\r
 {\r
     wxCommandEvent event( wxEVT_DIALOG, ShowMessages_Event );\r
@@ -265,7 +297,7 @@ void Dialogs::OnShowOpen( wxCommandEvent& event )
     Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
     bool b_play = event.GetInt() ? TRUE : FALSE;\r
 \r
-    //p_dialogs->OpenDlg->Show( !p_dialogs->OpenDlg->IsShown() );\r
+    if( p_dialogs->OpenDlg->IsShown() ) return;\r
  \r
     if( p_dialogs->OpenDlg->ShowModal() != wxID_OK )\r
     {\r
@@ -308,6 +340,29 @@ void Dialogs::OnShowOpen( wxCommandEvent& event )
     return;\r
 }\r
 \r
+void Dialogs::OnShowOpenSkin( wxCommandEvent& event )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
+    intf_thread_t *p_intf = p_dialogs->p_intf;\r
+\r
+    wxFileDialog dialog( NULL,\r
+        wxU(_("Open a skin file")), wxT(""), wxT(""),\r
+        wxT("Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"\r
+            "All files|*.*"), wxOPEN );\r
+\r
+    if( dialog.ShowModal() == wxID_OK )\r
+    {\r
+        p_intf->p_sys->p_new_theme_file =\r
+           new char[strlen(dialog.GetPath().mb_str()) + 1];\r
+\r
+        strcpy( p_intf->p_sys->p_new_theme_file,\r
+                dialog.GetPath().mb_str() );\r
+\r
+        // Tell vlc to change skin after hiding interface\r
+        OSAPI_PostMessage( NULL, VLC_HIDE, VLC_LOAD_SKIN, 0 );\r
+    }\r
+}\r
+\r
 void Dialogs::OnShowMessages( wxCommandEvent& event )\r
 {\r
     Dialogs *p_dialogs = (Dialogs *)event.GetClientData();\r
@@ -331,3 +386,18 @@ void Dialogs::OnExitThread( wxCommandEvent& event )
     wxTheApp->ExitMainLoop();\r
 }\r
 #endif // BASIC_SKINS\r
+\r
+/*****************************************************************************\r
+ * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.\r
+ *  We don't show the menu directly here because we don't want the\r
+ *  caller to block for a too long time.\r
+ *****************************************************************************/\r
+int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,\r
+                 vlc_value_t old_val, vlc_value_t new_val, void *param )\r
+{\r
+    Dialogs *p_dialogs = (Dialogs *)param;\r
+\r
+    p_dialogs->b_popup_change = VLC_TRUE;\r
+\r
+    return VLC_SUCCESS;\r
+}\r
index 49474081b5ee9880cc12809db75ec1c9160f67d2..71fab8eede9aa68f9f50601e436ca06d23102566 100644 (file)
@@ -2,7 +2,7 @@
  * dialogs.h: Dialogs class\r
  *****************************************************************************\r
  * Copyright (C) 2003 VideoLAN\r
- * $Id: dialogs.h,v 1.1 2003/06/03 22:20:00 gbazin Exp $\r
+ * $Id: dialogs.h,v 1.2 2003/06/04 16:03:33 gbazin Exp $\r
  *\r
  * Authors: Gildas Bazin <gbazin@netcourrier.com>\r
  *\r
@@ -48,6 +48,14 @@ class SoutDialog;
 class PrefsDialog;\r
 class FileInfo;\r
 class wxIcon;\r
+\r
+typedef struct dialogs_thread_t\r
+{\r
+    VLC_COMMON_MEMBERS\r
+    intf_thread_t * p_intf;\r
+\r
+} dialogs_thread_t;\r
+\r
 #endif\r
 \r
 //---------------------------------------------------------------------------\r
@@ -64,10 +72,13 @@ class Dialogs
         virtual ~Dialogs();\r
 \r
         void ShowOpen( bool b_play );\r
+        void ShowOpenSkin();\r
         void ShowMessages();\r
         void ShowPrefs();\r
         void ShowFileInfo();\r
 \r
+        vlc_bool_t b_popup_change;\r
+\r
 #ifndef BASIC_SKINS\r
         // Dialogs\r
         OpenDialog  *OpenDlg;\r
@@ -75,9 +86,10 @@ class Dialogs
         PrefsDialog *PrefsDlg;\r
         FileInfo    *FileInfoDlg;\r
 \r
-        wxIcon      *p_icon;\r
+        dialogs_thread_t *p_thread;\r
 \r
         void OnShowOpen( wxCommandEvent& event );\r
+        void OnShowOpenSkin( wxCommandEvent& event );\r
         void OnShowMessages( wxCommandEvent& event );\r
         void OnShowPrefs( wxCommandEvent& event );\r
         void OnShowFileInfo( wxCommandEvent& event );\r
index 33b580be092aa6797de643d2b7a56bea27b2747d..3780028bbc2ce7375459665394d5f0394b36dddc 100644 (file)
@@ -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 Teulière <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,
index 2198445fc1bff650c05870c935df3c8a56c6ebcc..12105c6fdf2eccb7d10a54ae5f39d470e4891abf 100644 (file)
@@ -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 Teulière <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 ||
index 23f2f3473be9f0bcff3a42d8d678d8e2446851a4..8b1d701ce1d9895d3c86667a946c8e2b1e703d74 100644 (file)
@@ -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 Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
 #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
index 1f51e38ec615fde9117223641da60c55a79e9392..6598ddf813456033750de48ecd4845f6e2341b1a 100644 (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 Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
 #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 );
index 600e431048ba77c8f2d3ff452e65ed891ffe3e9d..afc2b0cd14d219478cede173cd04270d5242f7a2 100644 (file)
@@ -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,