]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/src/vlcproc.cpp
* modules/gui/wxwindows/*, include/vlc_interface.h: new generic "open file" dialog.
[vlc] / modules / gui / skins / src / vlcproc.cpp
index c81d26bc17b23b1b65c8d173844c663bb384b612..d06d7434852235e9912e1406caa6ef966a5fe627 100644 (file)
@@ -2,7 +2,7 @@
  * vlcproc.cpp: VlcProc class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: vlcproc.cpp,v 1.35 2003/06/11 10:42:34 gbazin Exp $
+ * $Id: vlcproc.cpp,v 1.41 2003/07/20 10:38:49 gbazin Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
 //---------------------------------------------------------------------------
 VlcProc::VlcProc( intf_thread_t *_p_intf )
 {
-    p_intf = _p_intf;
+    p_intf = _p_intf; 
+    
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, 
+        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist != NULL )
+    {
+        // We want to be noticed of playlit changes
+        var_AddCallback( p_playlist, "intf-change", RefreshCallback, this );
+        
+        // Raise/lower interface with middle click on vout
+        var_AddCallback( p_playlist, "intf-show", IntfShowCallback, this );
+        
+        vlc_object_release( p_playlist );   
+    }
 }
 //---------------------------------------------------------------------------
 VlcProc::~VlcProc()
 {
+    // Remove the refresh callback
+    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, 
+        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist != NULL )
+    {
+        var_DelCallback( p_playlist, "intf-change", RefreshCallback, this );
+        vlc_object_release( p_playlist );
+    }
 }
 //---------------------------------------------------------------------------
 bool VlcProc::EventProc( Event *evt )
@@ -145,7 +166,7 @@ bool VlcProc::EventProc( Event *evt )
             return true;
 
         case VLC_INTF_REFRESH:
-            InterfaceRefresh( (bool)evt->GetParam2() );
+            InterfaceRefresh();
             return true;
 
         case VLC_TEST_ALL_CLOSED:
@@ -225,7 +246,31 @@ bool VlcProc::IsClosing()
 //---------------------------------------------------------------------------
 // Private methods
 //---------------------------------------------------------------------------
-void VlcProc::InterfaceRefresh( bool All )
+
+// Refresh callback
+int VlcProc::RefreshCallback( vlc_object_t *p_this, const char *psz_variable,
+        vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    ( (VlcProc*)param )->InterfaceRefresh();
+    return VLC_SUCCESS;
+}
+
+// Interface show/hide callback
+int VlcProc::IntfShowCallback( vlc_object_t *p_this, const char *psz_variable,
+        vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    if( new_val.b_bool == VLC_TRUE )
+    {
+        OSAPI_PostMessage( NULL, VLC_SHOW, 1, 0 );
+    }
+    else
+    {
+        OSAPI_PostMessage( NULL, VLC_HIDE, 1, 0 );
+    }
+    return VLC_SUCCESS;
+}
+
+void VlcProc::InterfaceRefresh()
 {
     // Shortcut pointers
     intf_sys_t  *Sys      = p_intf->p_sys;
@@ -269,12 +314,18 @@ void VlcProc::InterfaceRefresh( bool All )
         else
             EnabledEvent( "next", true );
 
-
-        // Update file name text
+        // Update file name
         if( PlayList->i_index != Sys->i_index )
         {
+            string long_name = PlayList->pp_items[PlayList->i_index]->psz_name;
+            int pos = long_name.rfind( DIRECTORY_SEPARATOR, long_name.size() );
+
+            // Complete file name
             Thema->EvtBank->Get( "file_name" )->PostTextMessage(
                 PlayList->pp_items[PlayList->i_index]->psz_name );
+            // File name without path
+            Thema->EvtBank->Get( "title" )->PostTextMessage(
+                PlayList->pp_items[PlayList->i_index]->psz_name + pos + 1 );
         }
 
         // Update playlists
@@ -302,7 +353,6 @@ void VlcProc::InterfaceRefresh( bool All )
             Sys->i_size  = 0;
         }
     }
-
 }
 //---------------------------------------------------------------------------
 void VlcProc::EnabledEvent( string type, bool state )
@@ -320,7 +370,7 @@ void VlcProc::LoadSkin()
 {
     if( p_intf->p_sys->p_new_theme_file == NULL )
     {
-        p_intf->p_sys->p_dialogs->ShowOpenSkin();
+        p_intf->p_sys->p_dialogs->ShowOpenSkin( 0 /*none blocking*/ );
     }
     else
     {
@@ -355,7 +405,7 @@ void VlcProc::LoadSkin()
         delete Loader;
 
         // Uninitialize new theme
-        delete (char *)p_intf->p_sys->p_new_theme_file;
+        delete[] p_intf->p_sys->p_new_theme_file;
         p_intf->p_sys->p_new_theme_file = NULL;
     }
 }