]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/src/vlcproc.cpp
* ./modules/gui/skins/src/vlcproc.cpp: added the "title" option to the
[vlc] / modules / gui / skins / src / vlcproc.cpp
index 658d623138a78a8b05e8daa6489aa9d7555ab307..e729e070c5d7c18c0548fe8c109c0833cf1c8bfa 100644 (file)
@@ -2,7 +2,7 @@
  * vlcproc.cpp: VlcProc class
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: vlcproc.cpp,v 1.4 2003/04/11 22:08:06 videolan Exp $
+ * $Id: vlcproc.cpp,v 1.36 2003/06/20 19:50:29 ipkiss Exp $
  *
  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
  *          Emmanuel Puig    <karibu@via.ecp.fr>
  * USA.
  *****************************************************************************/
 
-
 //--- VLC -------------------------------------------------------------------
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 #include <vlc/aout.h>
 #include <vlc/vout.h>
 
-
 //--- SKIN ------------------------------------------------------------------
-#include "os_api.h"
-#include "dialog.h"
-#include "os_dialog.h"
+#include "../os_api.h"
 #include "event.h"
 #include "banks.h"
 #include "theme.h"
-#include "os_theme.h"
+#include "../os_theme.h"
 #include "themeloader.h"
 #include "window.h"
 #include "vlcproc.h"
 #include "skin_common.h"
-
-
+#include "dialogs.h"
 
 //---------------------------------------------------------------------------
 // VlcProc
@@ -54,6 +49,10 @@ VlcProc::VlcProc( intf_thread_t *_p_intf )
     p_intf = _p_intf;
 }
 //---------------------------------------------------------------------------
+VlcProc::~VlcProc()
+{
+}
+//---------------------------------------------------------------------------
 bool VlcProc::EventProc( Event *evt )
 {
     switch( evt->GetMessage() )
@@ -71,7 +70,7 @@ bool VlcProc::EventProc( Event *evt )
             return true;
 
         case VLC_HIDE:
-            for( list<Window *>::const_iterator win =
+            for( list<SkinWindow *>::const_iterator win =
                     p_intf->p_sys->p_theme->WindowList.begin();
                  win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
             {
@@ -82,7 +81,7 @@ bool VlcProc::EventProc( Event *evt )
             return true;
 
         case VLC_SHOW:
-            for( list<Window *>::const_iterator win =
+            for( list<SkinWindow *>::const_iterator win =
                     p_intf->p_sys->p_theme->WindowList.begin();
                  win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
             {
@@ -93,7 +92,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:
@@ -125,15 +125,23 @@ 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;
 
         case VLC_LOG_SHOW:
-            p_intf->p_sys->p_theme->ShowLog( evt->GetParam2() );
+            p_intf->p_sys->p_dialogs->ShowMessages();
             return true;
 
         case VLC_LOG_CLEAR:
-            p_intf->p_sys->p_theme->ClearLog();
+            return true;
+
+        case VLC_PREFS_SHOW:
+            p_intf->p_sys->p_dialogs->ShowPrefs();
+            return true;
+
+        case VLC_INFO_SHOW:
+            p_intf->p_sys->p_dialogs->ShowFileInfo();
             return true;
 
         case VLC_INTF_REFRESH:
@@ -168,7 +176,7 @@ bool VlcProc::EventProcEnd()
     if( p_intf->p_sys->b_all_win_closed )
         return true;
 
-    list<Window *>::const_iterator win;
+    list<SkinWindow *>::const_iterator win;
 
     // If a window has been closed, test if all are closed !
     for( win = p_intf->p_sys->p_theme->WindowList.begin();
@@ -224,10 +232,8 @@ void VlcProc::InterfaceRefresh( bool All )
     Theme       *Thema    = Sys->p_theme;
     playlist_t  *PlayList = Sys->p_playlist;
 
-
     // Refresh
-    if( PlayList != NULL && Sys->p_input != NULL &&
-        Sys->p_input->stream.b_seekable )
+    if( PlayList != NULL )
     {
         // Refresh stream control controls ! :)
         switch( PlayList->i_status )
@@ -263,12 +269,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
@@ -307,7 +319,6 @@ void VlcProc::EnabledEvent( string type, bool state )
 //---------------------------------------------------------------------------
 
 
-
 //---------------------------------------------------------------------------
 // Common VLC procedures
 //---------------------------------------------------------------------------
@@ -315,29 +326,7 @@ void VlcProc::LoadSkin()
 {
     if( p_intf->p_sys->p_new_theme_file == NULL )
     {
-        // Initialize file structure
-        OpenFileDialog *OpenFile;
-        OpenFile = (OpenFileDialog *)new OSOpenFileDialog( p_intf,
-            _("Change skin - Open new file"), false );
-        OpenFile->AddFilter( _("Skin files"), "*.vlt" );
-        OpenFile->AddFilter( _("Skin files"), "*.xml" );
-        OpenFile->AddFilter( _("All files"), "*.*" );
-
-        // Open dialog box
-        if( OpenFile->Open() )
-        {
-            p_intf->p_sys->p_new_theme_file =
-                new char[OpenFile->FileList.front().length()];
-
-            strcpy( p_intf->p_sys->p_new_theme_file,
-                    OpenFile->FileList.front().c_str() );
-
-            // Tell vlc to change skin after hiding interface
-            OSAPI_PostMessage( NULL, VLC_HIDE, VLC_LOAD_SKIN, 0 );
-        }
-
-        // Free memory
-        delete OpenFile;
+        p_intf->p_sys->p_dialogs->ShowOpenSkin();
     }
     else
     {
@@ -377,55 +366,7 @@ void VlcProc::LoadSkin()
     }
 }
 //---------------------------------------------------------------------------
-void VlcProc::OpenFile( bool play )
-{
-    // Initialize file structure
-    OpenFileDialog *OpenFile;
-    if( play )
-    {
-        OpenFile = (OpenFileDialog *)new OSOpenFileDialog( p_intf,
-            _("Open file"), false );
-    }
-    else
-    {
-        OpenFile = (OpenFileDialog *)new OSOpenFileDialog( p_intf,
-            _("Add file"), true );
-    }
-    OpenFile->AddFilter( _("All files"), "*.*" );
-
-    // Check if palylist is available
-    playlist_t *p_playlist = p_intf->p_sys->p_playlist;
-    if( p_playlist == NULL )
-        return;
-
-    // Open dialog box and launch file
-    if( OpenFile->Open() )
-    {
-        list<string>::const_iterator file;
-        for( file = OpenFile->FileList.begin();
-             file != OpenFile->FileList.end(); file++ )
-        {
-            playlist_Add( p_playlist, (*file).c_str(), PLAYLIST_APPEND,
-                          PLAYLIST_END );
-        }
-
-        // Refreshing
-        if( play )
-        {
-            // Play
-            p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
-        }
 
-        // Refresh interface !
-        p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" )
-            ->PostSynchroMessage();
-        InterfaceRefresh();
-    }
-
-    // Free memory
-    delete OpenFile;
-}
-//---------------------------------------------------------------------------
 void VlcProc::DropFile( unsigned int param )
 {
     // Get pointer to file
@@ -477,8 +418,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 );
 
@@ -581,10 +527,6 @@ void VlcProc::ChangeVolume( unsigned int msg, long param )
     }
     aout_VolumeGet( p_intf, &volume );
 
-    PostMessage( NULL, CTRL_SET_SLIDER,
-        (unsigned int)
-            p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" ),
-        (int)( volume * SLIDER_RANGE / AOUT_VOLUME_MAX ) );
 }
 //---------------------------------------------------------------------------
 
@@ -594,8 +536,6 @@ void VlcProc::ChangeVolume( unsigned int msg, long param )
 //---------------------------------------------------------------------------
 void VlcProc::AddNetworkUDP( int port )
 {
-    config_PutInt( p_intf, "network-channel", FALSE );
-
     // Build source name
     char *s_port = new char[5];
     sprintf( s_port, "%i", port );
@@ -611,5 +551,3 @@ void VlcProc::AddNetworkUDP( int port )
     InterfaceRefresh();
 }
 //---------------------------------------------------------------------------
-
-