]> 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 a68629a5a29ec3d9f3ced54531e3924a2c822abb..d06d7434852235e9912e1406caa6ef966a5fe627 100644 (file)
@@ -2,7 +2,7 @@
  * vlcproc.cpp: VlcProc class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: vlcproc.cpp,v 1.17 2003/04/30 19:22:27 ipkiss 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>
  * USA.
  *****************************************************************************/
 
-#ifndef BASIC_SKINS
-#include <wx/wx.h>
-#endif
-
 //--- VLC -------------------------------------------------------------------
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 #include <vlc/aout.h>
 #include <vlc/vout.h>
 
-extern "C" {
-#include "netutils.h"
-}
-
 //--- SKIN ------------------------------------------------------------------
 #include "../os_api.h"
 #include "event.h"
@@ -47,18 +39,39 @@ extern "C" {
 #include "window.h"
 #include "vlcproc.h"
 #include "skin_common.h"
-
-#ifndef BASIC_SKINS
-#include "wxdialogs.h"
-#endif
-
+#include "dialogs.h"
 
 //---------------------------------------------------------------------------
 // VlcProc
 //---------------------------------------------------------------------------
 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 )
@@ -100,7 +113,8 @@ bool VlcProc::EventProc( Event *evt )
             return true;
 
         case VLC_OPEN:
-            OpenFile( true );
+            p_intf->p_sys->p_dialogs->ShowOpen( true );
+            InterfaceRefresh();
             return true;
 
         case VLC_LOAD_SKIN:
@@ -132,31 +146,27 @@ bool VlcProc::EventProc( Event *evt )
             return true;
 
         case VLC_PLAYLIST_ADD_FILE:
-            OpenFile( false );
+            p_intf->p_sys->p_dialogs->ShowOpen( false );
+            InterfaceRefresh();
             return true;
 
-#ifndef BASIC_SKINS
         case VLC_LOG_SHOW:
-            p_intf->p_sys->MessagesDlg->Show(
-                !p_intf->p_sys->MessagesDlg->IsShown() );
+            p_intf->p_sys->p_dialogs->ShowMessages();
             return true;
 
         case VLC_LOG_CLEAR:
             return true;
 
         case VLC_PREFS_SHOW:
-            p_intf->p_sys->PrefsDlg->Show(
-                !p_intf->p_sys->PrefsDlg->IsShown() );
+            p_intf->p_sys->p_dialogs->ShowPrefs();
             return true;
 
         case VLC_INFO_SHOW:
-            p_intf->p_sys->InfoDlg->Show(
-                !p_intf->p_sys->InfoDlg->IsShown() );
+            p_intf->p_sys->p_dialogs->ShowFileInfo();
             return true;
-#endif
 
         case VLC_INTF_REFRESH:
-            InterfaceRefresh( (bool)evt->GetParam2() );
+            InterfaceRefresh();
             return true;
 
         case VLC_TEST_ALL_CLOSED:
@@ -177,10 +187,6 @@ bool VlcProc::EventProc( Event *evt )
             AddNetworkUDP( (int)evt->GetParam2() );
             return true;
 
-        case VLC_NET_ADDCS:
-            AddNetworkChannelServer( (char *)evt->GetParam1() );
-            return true;
-
         default:
             return true;
     }
@@ -240,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;
@@ -284,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
@@ -317,7 +353,6 @@ void VlcProc::InterfaceRefresh( bool All )
             Sys->i_size  = 0;
         }
     }
-
 }
 //---------------------------------------------------------------------------
 void VlcProc::EnabledEvent( string type, bool state )
@@ -328,30 +363,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, _("Open a skin file"), "", "",
-            "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[dialog.GetPath().Length()];
-
-            strcpy( p_intf->p_sys->p_new_theme_file,
-                    dialog.GetPath().c_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( 0 /*none blocking*/ );
     }
     else
     {
@@ -386,51 +405,12 @@ 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;
     }
-#endif
 }
 //---------------------------------------------------------------------------
-void VlcProc::OpenFile( bool play )
-{
-#ifndef BASIC_SKINS
-    if( p_intf->p_sys->OpenDlg->ShowModal() != wxID_OK )
-    {
-        return;
-    }
-
-    // Check if playlist is available
-    playlist_t *p_playlist = p_intf->p_sys->p_playlist;
-    if( p_playlist == NULL )
-    {
-        return;
-    }
-
-    if( play )
-    {
-        // Append and play
-        playlist_Add( p_playlist,
-                      (char *)p_intf->p_sys->OpenDlg->mrl.c_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
 
-        p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
-    }
-    else
-    {
-        // Append only
-        playlist_Add( p_playlist,
-                        (char *)p_intf->p_sys->OpenDlg->mrl.c_str(),
-                        PLAYLIST_APPEND, PLAYLIST_END );
-    }
-
-    // Refresh interface !
-    p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" )
-        ->PostSynchroMessage();
-    InterfaceRefresh();
-#endif
-}
-//---------------------------------------------------------------------------
 void VlcProc::DropFile( unsigned int param )
 {
     // Get pointer to file
@@ -482,8 +462,13 @@ void VlcProc::PlayStream()
 {
     if( p_intf->p_sys->p_playlist == NULL )
         return;
+
     if( !p_intf->p_sys->p_playlist->i_size )
+    {
+        p_intf->p_sys->p_dialogs->ShowOpen( true );
+        InterfaceRefresh();
         return;
+    }
 
     playlist_Play( p_intf->p_sys->p_playlist );
 
@@ -595,8 +580,6 @@ void VlcProc::ChangeVolume( unsigned int msg, long param )
 //---------------------------------------------------------------------------
 void VlcProc::AddNetworkUDP( int port )
 {
-    config_PutInt( p_intf, "network-channel", VLC_FALSE );
-
     // Build source name
     char *s_port = new char[5];
     sprintf( s_port, "%i", port );
@@ -612,31 +595,3 @@ void VlcProc::AddNetworkUDP( int port )
     InterfaceRefresh();
 }
 //---------------------------------------------------------------------------
-void VlcProc::AddNetworkChannelServer( char *server )
-{
-    char *name = new char[MAX_PARAM_SIZE];
-    int  port = 0;
-
-    // Scan the server address
-    int scan = sscanf( server, "%[^:]:%i", name, &port );
-
-    if( scan != 2)
-    {
-        msg_Err( p_intf, "Invalid channel server: %s", server );
-        delete[] name;
-        return;
-    }
-
-    config_PutInt( p_intf, "network-channel", VLC_TRUE );
-    config_PutPsz( p_intf, "channel-server", name );
-    config_PutInt( p_intf, "channel-port", port );
-
-    if( p_intf->p_vlc->p_channel == NULL )
-    {
-        network_ChannelCreate( p_intf );
-    }
-
-    delete[] name;
-}
-//---------------------------------------------------------------------------
-