]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/src/skin_main.cpp
* fixed a timing issue under windows ?
[vlc] / modules / gui / skins / src / skin_main.cpp
index 2fe3d96376315697097378056cb774d0da03202d..8e4ad1ec6db5699ba49d482e5cae17c055ba6a52 100644 (file)
@@ -2,7 +2,7 @@
  * skin-main.cpp: skins plugin for VLC
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: skin_main.cpp,v 1.2 2003/03/19 03:11:14 karibu Exp $
+ * $Id: skin_main.cpp,v 1.15 2003/04/21 02:50:49 asmax Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
@@ -23,6 +23,8 @@
  * USA.
  *****************************************************************************/
 
+//--- GENERAL ---------------------------------------------------------------
+#include <wx/wx.h>
 
 //--- VLC -------------------------------------------------------------------
 #include <vlc/vlc.h>
 #include <vlc/aout.h>
 
 //--- SKIN ------------------------------------------------------------------
-#include "os_api.h"
+#include "../os_api.h"
 #include "event.h"
-#include "dialog.h"
-#include "os_dialog.h"
 #include "banks.h"
 #include "window.h"
 #include "theme.h"
-#include "os_theme.h"
+#include "../os_theme.h"
 #include "themeloader.h"
 #include "vlcproc.h"
 #include "skin_common.h"
+#include "wxdialogs.h"
 
 
 //---------------------------------------------------------------------------
@@ -53,8 +54,10 @@ intf_thread_t *g_pIntf;
 //---------------------------------------------------------------------------
 // Exported interface functions.
 //---------------------------------------------------------------------------
+#ifdef WIN32
 extern "C" __declspec( dllexport )
     int __VLC_SYMBOL( vlc_entry ) ( module_t *p_module );
+#endif
 
 //---------------------------------------------------------------------------
 // Local prototypes.
@@ -102,6 +105,10 @@ static int Open ( vlc_object_t *p_this )
     p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
         VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
 
+    // Initialize conditions
+    vlc_mutex_init( p_intf, &p_intf->p_sys->init_lock);
+    vlc_cond_init( p_intf, &p_intf->p_sys->init_cond);
+    
     p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
 
     return( 0 );
@@ -131,8 +138,10 @@ static void Close ( vlc_object_t *p_this )
     // Unsuscribe to messages bank
     msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
 
-
-
+    // Destroy conditions
+    vlc_cond_destroy( &p_intf->p_sys->init_cond);
+    vlc_mutex_destroy( &p_intf->p_sys->init_lock);
+    
     // Destroy structure
     free( p_intf->p_sys );
 }
@@ -143,6 +152,17 @@ static void Close ( vlc_object_t *p_this )
 //---------------------------------------------------------------------------
 static void Run( intf_thread_t *p_intf )
 {
+
+#if !defined WIN32
+/* FIXME: should be elsewhere ? */
+    // Initialize GDK
+    int    i_args   = 1;
+    char  *p_args[] = { "", NULL };
+    char **pp_args  = p_args;
+
+    gdk_init( &i_args, &pp_args );
+#endif
+
     int a = OSAPI_GetTime();
 
     // Load a theme
@@ -152,38 +172,44 @@ static void Run( intf_thread_t *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
+#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
+            wxFileDialog dialog( NULL, _("Open a skin file"), "", "",
+                "Skin files (*.vlt)|*.vlt|Skin files (*.xml)|*.xml|"
+                    "All files|*.*", wxOPEN );
 
-            // Initialize file structure
-            OpenFileDialog *OpenFile;
-            OpenFile = (OpenFileDialog *)new OSOpenFileDialog( _("Open skin"),
-                false );
-            OpenFile->AddFilter( _("Skin files"), "*.vlt" );
-            OpenFile->AddFilter( _("Skin files"), "*.xml" );
-            OpenFile->AddFilter( _("All files"), "*.*" );
-
-            // Open dialog box
-            if( OpenFile->Open() )
+            if( dialog.ShowModal() == wxID_OK )
             {
                 // try to load selected file
-                if( ! Loader->Load( OpenFile->FileList.front() ) )
+                if( ! Loader->Load( dialog.GetPath().c_str() ) )
                 {
                     // He, he, what the hell is he doing ?
-                    delete OpenFile;
                     delete Loader;
                     return;
                 }
             }
             else
             {
-                delete OpenFile;
                 delete Loader;
                 return;
             }
-
-            delete OpenFile;
         }
     }
 
@@ -198,7 +224,6 @@ static void Run( intf_thread_t *p_intf )
     // Refresh the whole interface
     OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true );
 
-    // Run interface message loop
     OSRun( p_intf );
 }
 
@@ -223,7 +248,7 @@ vlc_module_begin();
               VLC_FALSE );
     add_bool( "show_in_taskbar", VLC_TRUE, NULL, SKIN_TASKBAR,
               SKIN_TASKBAR_LONG, VLC_FALSE );
-    set_description( _("Skinnable Interface Module") );
+    set_description( _("Skinnable Interface") );
     set_capability( "interface", 30 );
     set_callbacks( Open, Close );
     add_shortcut( "skins" );
@@ -252,7 +277,10 @@ int SkinManage( intf_thread_t *p_intf )
     OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false );
 
     // Update the log window
-    //p_intf->p_sys->p_theme->UpdateLog( p_intf->p_sys->p_sub );
+    p_intf->p_sys->MessagesDlg->UpdateLog();
+
+    // Update the file info window
+    p_intf->p_sys->InfoDlg->UpdateFileInfo();
 
     //-------------------------------------------------------------------------
     if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )
@@ -275,8 +303,9 @@ int SkinManage( intf_thread_t *p_intf )
 
 
         // Refresh slider
-        //if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
-        //{
+       // if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
+        if( p_input->stream.b_seekable )
+        {
 #define p_area p_input->stream.p_selected_area
 
             // Set value of sliders
@@ -312,12 +341,11 @@ int SkinManage( intf_thread_t *p_intf )
             delete[] text;
 
 #undef p_area
-        //}
+        }
         vlc_mutex_unlock( &p_input->stream.stream_lock );
     }
     //-------------------------------------------------------------------------
     vlc_mutex_unlock( &p_intf->change_lock );
 
-    return( TRUE );
+    return( VLC_TRUE );
 }
-//---------------------------------------------------------------------------