]> git.sesse.net Git - vlc/commitdiff
* modules/gui/win32/mainframe.cpp: simplifications using the new
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 9 Feb 2003 02:01:21 +0000 (02:01 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 9 Feb 2003 02:01:21 +0000 (02:01 +0000)
   aout_Volume* API

modules/gui/win32/mainframe.cpp

index 4fbebc4d5f58ecde5805b5b75c71145ebb16ec21..ef3b286219183a63761e0628b95bb640c9494240 100644 (file)
-/*****************************************************************************\r
- * mainframe.cpp: Win32 interface plugin for vlc\r
- *****************************************************************************\r
- * Copyright (C) 2002 VideoLAN\r
- *\r
- * Authors: Olivier Teulière <ipkiss@via.ecp.fr>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.\r
- *****************************************************************************/\r
-\r
-#include <vcl.h>\r
-#pragma hdrstop\r
-\r
-#include <vlc/vlc.h>\r
-#include <vlc/intf.h>\r
-#include <vlc/vout.h>\r
-\r
-#include "dragdrop.h"\r
-#include "mainframe.h"\r
-#include "menu.h"\r
-#include "disc.h"\r
-#include "network.h"\r
-#include "about.h"\r
-#include "preferences.h"\r
-#include "messages.h"\r
-#include "playlist.h"\r
-#include "sout.h"\r
-#include "subtitles.h"\r
-#include "misc.h"\r
-#include "win32_common.h"\r
-\r
-#include "netutils.h"\r
-\r
-//---------------------------------------------------------------------------\r
-#pragma link "CSPIN"\r
-#pragma resource "*.dfm"\r
-\r
-extern int Win32Manage( intf_thread_t *p_intf );\r
-\r
-//---------------------------------------------------------------------------\r
-__fastcall TMainFrameDlg::TMainFrameDlg(\r
-    TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner )\r
-{\r
-    p_intf = _p_intf;\r
-\r
-    Application->ShowHint = true;\r
-    Application->OnHint = DisplayHint;\r
-\r
-    TimerManage->Interval = INTF_IDLE_SLEEP / 1000;\r
-\r
-    TrackBar->Max = SLIDER_MAX_VALUE;\r
-\r
-    /* default height and caption */\r
-    ClientHeight = 37 + ToolBar->Height;\r
-    Caption = VOUT_TITLE " (Win32 interface)";\r
-\r
-    StringListPref = new TStringList();\r
-\r
-    Translate( this );\r
-\r
-    /* drag and drop stuff */\r
-\r
-    /* initialize the OLE library */\r
-    OleInitialize( NULL );\r
-    /* TDropTarget will send the WM_OLEDROP message to the form */\r
-    lpDropTarget = (LPDROPTARGET)new TDropTarget( this->Handle );\r
-    CoLockObjectExternal( lpDropTarget, true, true );\r
-    /* register the form as a drop target */\r
-    RegisterDragDrop( this->Handle, lpDropTarget );\r
-}\r
-//---------------------------------------------------------------------------\r
-__fastcall TMainFrameDlg::~TMainFrameDlg()\r
-{\r
-    delete StringListPref;\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * Event handlers\r
- ****************************************************************************/\r
-void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )\r
-{\r
-    Win32Manage( p_intf );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )\r
-{\r
-    StatusBar->SimpleText = GetLongHint( Application->Hint );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )\r
-{\r
-    /* This function displays the current date related to the position in\r
-     * the stream. It is called whenever the slider changes its value.\r
-     * The lock has to be taken before the function is called */\r
-\r
-    if( p_intf->p_sys->p_input != NULL )\r
-    {\r
-#define p_area p_intf->p_sys->p_input->stream.p_selected_area\r
-        char psz_time[ OFFSETTOTIME_MAX_SIZE ];\r
-        off_t Value = TrackBar->Position;\r
-\r
-        GroupBoxSlider->Caption =\r
-                input_OffsetToTime( p_intf->p_sys->p_input, psz_time,\r
-                        ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );\r
-#undef p_area\r
-     }\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::FormClose( TObject *Sender,\r
-      TCloseAction &Action )\r
-{\r
-    vlc_mutex_lock( &p_intf->change_lock );\r
-    p_intf->p_vlc->b_die = VLC_TRUE;\r
-    vlc_mutex_unlock( &p_intf->change_lock );\r
-\r
-    /* remove the form from the list of drop targets */\r
-    RevokeDragDrop( this->Handle );\r
-    lpDropTarget->Release();\r
-    CoLockObjectExternal( lpDropTarget, false, true );\r
-\r
-    /* uninitialize the OLE library */\r
-    OleUninitialize();\r
-\r
-    /* we don't destroy the form immediatly */\r
-    Action = caHide;\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * Main callbacks\r
- ****************************************************************************/\r
-void __fastcall TMainFrameDlg::OpenFileActionExecute( TObject *Sender )\r
-{\r
-    if( OpenDialog1->Execute() )\r
-    {\r
-        /* add the new file to the interface playlist */\r
-        for( int i = 0; i < OpenDialog1->Files->Count; i++ )\r
-            p_intf->p_sys->p_playwin->Add( OpenDialog1->Files->Strings[i],\r
-                    PLAYLIST_APPEND\r
-                    | ( p_intf->p_sys->b_play_when_adding ? PLAYLIST_GO : 0 ),\r
-                    PLAYLIST_END );\r
-    };\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::OpenDiscActionExecute( TObject *Sender )\r
-{\r
-    TDiscDlg *p_disc = p_intf->p_sys->p_disc;\r
-    if( p_disc == NULL )\r
-    {\r
-        p_disc = new TDiscDlg( this, p_intf );\r
-        p_intf->p_sys->p_disc = p_disc;\r
-    }\r
-    p_disc->Show();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::NetworkStreamActionExecute( TObject *Sender )\r
-{\r
-    TNetworkDlg *p_network = p_intf->p_sys->p_network;\r
-    if( p_network == NULL )\r
-    {\r
-        p_network = new TNetworkDlg( this, p_intf );\r
-        p_intf->p_sys->p_network = p_network;\r
-    }\r
-    p_network->Show();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::AddSubtitlesActionsExecute( TObject *Sender )\r
-{\r
-    TSubtitlesDlg *p_subtitles = new TSubtitlesDlg( this, p_intf );\r
-    p_subtitles->ShowModal();\r
-    delete p_subtitles;\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::StreamOutputActionExecute( TObject *Sender )\r
-{\r
-    TSoutDlg *p_sout = new TSoutDlg( this, p_intf );\r
-    p_sout->ShowModal();\r
-    delete p_sout;\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::ExitActionExecute( TObject *Sender )\r
-{\r
-    Close();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::FullscreenActionExecute( TObject *Sender )\r
-{\r
-    vout_thread_t *p_vout;\r
-\r
-    p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input,\r
-                                               VLC_OBJECT_VOUT, FIND_CHILD );\r
-    if( p_vout == NULL )\r
-    {\r
-        return;\r
-    }\r
-\r
-    p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;\r
-    vlc_object_release( p_vout );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender )\r
-{\r
-    vlc_object_t *p_vout;\r
-    p_vout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,\r
-                                              FIND_ANYWHERE );\r
-    if( p_vout != NULL )\r
+/*****************************************************************************
+ * mainframe.cpp: Win32 interface plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2002 VideoLAN
+ *
+ * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include <vcl.h>
+#pragma hdrstop
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc/vout.h>
+
+#include "dragdrop.h"
+#include "mainframe.h"
+#include "menu.h"
+#include "disc.h"
+#include "network.h"
+#include "about.h"
+#include "preferences.h"
+#include "messages.h"
+#include "playlist.h"
+#include "sout.h"
+#include "subtitles.h"
+#include "misc.h"
+#include "win32_common.h"
+
+#include "netutils.h"
+
+//---------------------------------------------------------------------------
+#pragma link "CSPIN"
+#pragma resource "*.dfm"
+
+extern int Win32Manage( intf_thread_t *p_intf );
+
+//---------------------------------------------------------------------------
+__fastcall TMainFrameDlg::TMainFrameDlg(
+    TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner )
+{
+    p_intf = _p_intf;
+
+    Application->ShowHint = true;
+    Application->OnHint = DisplayHint;
+
+    TimerManage->Interval = INTF_IDLE_SLEEP / 1000;
+
+    TrackBar->Max = SLIDER_MAX_VALUE;
+
+    /* default height and caption */
+    ClientHeight = 37 + ToolBar->Height;
+    Caption = VOUT_TITLE " (Win32 interface)";
+
+    StringListPref = new TStringList();
+
+    Translate( this );
+
+    /* drag and drop stuff */
+
+    /* initialize the OLE library */
+    OleInitialize( NULL );
+    /* TDropTarget will send the WM_OLEDROP message to the form */
+    lpDropTarget = (LPDROPTARGET)new TDropTarget( this->Handle );
+    CoLockObjectExternal( lpDropTarget, true, true );
+    /* register the form as a drop target */
+    RegisterDragDrop( this->Handle, lpDropTarget );
+}
+//---------------------------------------------------------------------------
+__fastcall TMainFrameDlg::~TMainFrameDlg()
+{
+    delete StringListPref;
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * Event handlers
+ ****************************************************************************/
+void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )
+{
+    Win32Manage( p_intf );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )
+{
+    StatusBar->SimpleText = GetLongHint( Application->Hint );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )
+{
+    /* This function displays the current date related to the position in
+     * the stream. It is called whenever the slider changes its value.
+     * The lock has to be taken before the function is called */
+
+    if( p_intf->p_sys->p_input != NULL )
+    {
+#define p_area p_intf->p_sys->p_input->stream.p_selected_area
+        char psz_time[ OFFSETTOTIME_MAX_SIZE ];
+        off_t Value = TrackBar->Position;
+
+        GroupBoxSlider->Caption =
+                input_OffsetToTime( p_intf->p_sys->p_input, psz_time,
+                        ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );
+#undef p_area
+     }
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::FormClose( TObject *Sender,
+      TCloseAction &Action )
+{
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_vlc->b_die = VLC_TRUE;
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    /* remove the form from the list of drop targets */
+    RevokeDragDrop( this->Handle );
+    lpDropTarget->Release();
+    CoLockObjectExternal( lpDropTarget, false, true );
+
+    /* uninitialize the OLE library */
+    OleUninitialize();
+
+    /* we don't destroy the form immediatly */
+    Action = caHide;
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * Main callbacks
+ ****************************************************************************/
+void __fastcall TMainFrameDlg::OpenFileActionExecute( TObject *Sender )
+{
+    if( OpenDialog1->Execute() )
+    {
+        /* add the new file to the interface playlist */
+        for( int i = 0; i < OpenDialog1->Files->Count; i++ )
+            p_intf->p_sys->p_playwin->Add( OpenDialog1->Files->Strings[i],
+                    PLAYLIST_APPEND
+                    | ( p_intf->p_sys->b_play_when_adding ? PLAYLIST_GO : 0 ),
+                    PLAYLIST_END );
+    };
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::OpenDiscActionExecute( TObject *Sender )
+{
+    TDiscDlg *p_disc = p_intf->p_sys->p_disc;
+    if( p_disc == NULL )
+    {
+        p_disc = new TDiscDlg( this, p_intf );
+        p_intf->p_sys->p_disc = p_disc;
+    }
+    p_disc->Show();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::NetworkStreamActionExecute( TObject *Sender )
+{
+    TNetworkDlg *p_network = p_intf->p_sys->p_network;
+    if( p_network == NULL )
+    {
+        p_network = new TNetworkDlg( this, p_intf );
+        p_intf->p_sys->p_network = p_network;
+    }
+    p_network->Show();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::AddSubtitlesActionsExecute( TObject *Sender )
+{
+    TSubtitlesDlg *p_subtitles = new TSubtitlesDlg( this, p_intf );
+    p_subtitles->ShowModal();
+    delete p_subtitles;
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::StreamOutputActionExecute( TObject *Sender )
+{
+    TSoutDlg *p_sout = new TSoutDlg( this, p_intf );
+    p_sout->ShowModal();
+    delete p_sout;
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::ExitActionExecute( TObject *Sender )
+{
+    Close();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::FullscreenActionExecute( TObject *Sender )
+{
+    vout_thread_t *p_vout;
+
+    p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input,
+                                               VLC_OBJECT_VOUT, FIND_CHILD );
+    if( p_vout == NULL )
+    {
+        return;
+    }
+
+    p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+    vlc_object_release( p_vout );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender )
+{
+    vlc_object_t *p_vout;
+    p_vout = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
+    if( p_vout != NULL )
     {
         vlc_value_t val;
         if( var_Get( p_vout, "directx-on-top", &val ) >= 0 )
@@ -228,517 +228,495 @@ void __fastcall TMainFrameDlg::OnTopActionExecute( TObject *Sender )
             MenuOnTop->Checked = val.b_bool;
             PopupOnTop->Checked = val.b_bool;
         }
-        vlc_object_release( p_vout );\r
-    }\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PlaylistActionExecute( TObject *Sender )\r
-{\r
-    TPlaylistDlg *p_playwin = p_intf->p_sys->p_playwin;\r
-    if( p_playwin->Visible )\r
-    {\r
-        p_playwin->Hide();\r
-    }\r
-    else\r
-    {\r
-        p_playwin->UpdateGrid();\r
-        p_playwin->Show();\r
-    }\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::MessagesActionExecute( TObject *Sender )\r
-{\r
-     p_intf->p_sys->p_messages->Show();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PreferencesActionExecute( TObject *Sender )\r
-{\r
-    CreatePreferences( "main" );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::AboutActionExecute( TObject *Sender )\r
-{\r
-    TAboutDlg *AboutDlg = new TAboutDlg( this, p_intf );\r
-    AboutDlg->ShowModal();\r
-    delete AboutDlg;\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::BackActionExecute( TObject *Sender )\r
-{\r
-    /* TODO */\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PlayActionExecute( TObject *Sender )\r
-{\r
-    p_intf->p_sys->p_playwin->Play();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PauseActionExecute( TObject *Sender )\r
-{\r
-    p_intf->p_sys->p_playwin->Pause();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::StopActionExecute( TObject *Sender )\r
-{\r
-    p_intf->p_sys->p_playwin->Stop();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::SlowActionExecute( TObject *Sender )\r
-{\r
-    p_intf->p_sys->p_playwin->Slow();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::FastActionExecute( TObject *Sender )\r
-{\r
-    p_intf->p_sys->p_playwin->Fast();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PreviousActionExecute(TObject *Sender)\r
-{\r
-    p_intf->p_sys->p_playwin->Previous();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::NextActionExecute(TObject *Sender)\r
-{\r
-    p_intf->p_sys->p_playwin->Next();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )\r
-{\r
-    AnsiString Device = "";\r
-    char * psz_current;\r
-    playlist_t * p_playlist;\r
-\r
-    p_playlist = (playlist_t *)vlc_object_find( p_intf,\r
-                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );\r
-    if( p_playlist == NULL )\r
-    {\r
-        return;\r
-    }\r
-\r
-    /*\r
-     * Get the active input\r
-     * Determine whether we can eject a media, ie it's a VCD or DVD\r
-     * If it's neither a VCD nor a DVD, then return\r
-     */\r
-\r
-    vlc_mutex_lock( &p_playlist->object_lock );\r
-    psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;\r
-\r
-    if( psz_current != NULL )\r
-    {\r
-        if( strncmp( psz_current, "dvd", 3 )\r
-            || strncmp( psz_current, "vcd", 3 ) )\r
-        {\r
-            /* Determine the device name by omitting the first 4 characters\r
-             * and keeping 3 characters */\r
-            Device = strdup( ( psz_current + 4 ) );\r
-            Device = Device.SubString( 1, 2 );\r
-        }\r
-    }\r
-\r
-    vlc_mutex_unlock( &p_playlist->object_lock );\r
-    vlc_object_release( p_playlist );\r
-\r
-    if( Device == "" )\r
-    {\r
-        return;\r
-    }\r
-\r
-    /* If there's a stream playing, we aren't allowed to eject ! */\r
-    if( p_intf->p_sys->p_input == NULL )\r
-    {\r
-        msg_Dbg( p_intf, "ejecting %s", Device.c_str() );\r
-\r
-        intf_Eject( p_intf, Device.c_str() );\r
-    }\r
-}\r
-//--------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )\r
-{\r
-    aout_instance_t *p_aout;\r
-    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
-                                                 FIND_ANYWHERE );\r
-    if ( p_aout != NULL )\r
-    {\r
-        aout_VolumeUp( p_aout, 1, NULL );\r
-        vlc_object_release( (vlc_object_t *)p_aout );\r
-    }\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )\r
-{\r
-    aout_instance_t *p_aout;\r
-    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
-                                                 FIND_ANYWHERE );\r
-    if ( p_aout != NULL )\r
-    {\r
-        aout_VolumeDown( p_aout, 1, NULL );\r
-        vlc_object_release( (vlc_object_t *)p_aout );\r
-    }\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )\r
-{\r
-    aout_instance_t *p_aout;\r
-    p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
-                                                 FIND_ANYWHERE );\r
-    if ( p_aout != NULL )\r
-    {\r
-        aout_VolumeMute( p_aout, NULL );\r
-        vlc_object_release( (vlc_object_t *)p_aout );\r
-\r
-//        MenuMute->Checked = ! MenuMute->Checked;\r
-    }\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * External drop handling\r
- *****************************************************************************/\r
-void __fastcall TMainFrameDlg::OnDrop( TMessage &Msg )\r
-{\r
-    /* find the number of files dropped */\r
-    int num_files = DragQueryFile( (HDROP)Msg.WParam, 0xFFFFFFFF,\r
-                                   (LPSTR)NULL, NULL );\r
-\r
-    /* append each file to the playlist */\r
-    for( int i = 0; i < num_files; i++ )\r
-    {\r
-        /* find the length of the filename */\r
-        int name_length = DragQueryFile( (HDROP)Msg.WParam, i, NULL, NULL ) + 1;\r
-\r
-        /* get the filename */\r
-        char *FileName = new char[name_length];\r
-        DragQueryFile( (HDROP)Msg.WParam, i, FileName, name_length );\r
-\r
-        /* add the new file to the playlist */\r
-        if( config_GetInt( p_intf, "enqueue" ) )\r
-        {\r
-            p_intf->p_sys->p_playwin->Add( FileName,\r
-                PLAYLIST_APPEND, PLAYLIST_END );\r
-        }\r
-        else\r
-        {\r
-            p_intf->p_sys->p_playwin->Add( FileName,\r
-                PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );\r
-        }\r
-\r
-        delete[] FileName;\r
-    }\r
-\r
-    DragFinish( (HDROP)Msg.WParam );\r
-    Msg.Result = 0;\r
-}\r
-//--------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * Menu and popup callbacks\r
- *****************************************************************************/\r
-void __fastcall TMainFrameDlg::MenuHideinterfaceClick( TObject *Sender )\r
-{\r
-     this->SendToBack();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )\r
-{\r
-    this->BringToFront();\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )\r
-{\r
-    /* We do nothing, we just need a click on a menu item\r
-     * to close the popup. Don't ask me why... */\r
-    return;\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )\r
-{\r
-    /* TODO */\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * Callbacks for DVD/VCD navigation\r
- ****************************************************************************/\r
-void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender )\r
-{\r
-    input_area_t  * p_area;\r
-    int             i_id;\r
-\r
-    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-    i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;\r
-\r
-    /* Disallow area 0 since it is used for video_ts.vob */\r
-    if( i_id > 0 )\r
-    {\r
-        p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];\r
-        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-\r
-        input_ChangeArea( p_intf->p_sys->p_input, p_area );\r
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
-\r
-        p_intf->p_sys->b_title_update = VLC_TRUE;\r
-        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-        p_intf->p_sys->p_menus->SetupMenus();\r
-    }\r
-\r
-    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender )\r
-{\r
-    input_area_t  * p_area;\r
-    unsigned int    i_id;\r
-\r
-    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-    i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;\r
-\r
-    if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )\r
-    {\r
-        p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];\r
-        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-\r
-        input_ChangeArea( p_intf->p_sys->p_input, p_area );\r
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
-\r
-        p_intf->p_sys->b_title_update = VLC_TRUE;\r
-        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-        p_intf->p_sys->p_menus->SetupMenus();\r
-    }\r
-\r
-    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender )\r
-{\r
-    input_area_t  * p_area;\r
-\r
-    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-    p_area = p_intf->p_sys->p_input->stream.p_selected_area;\r
-\r
-    if( p_area->i_part - 1 > 0 )\r
-    {\r
-        p_area->i_part--;\r
-        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-\r
-        input_ChangeArea( p_intf->p_sys->p_input, p_area );\r
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
-\r
-        p_intf->p_sys->b_chapter_update = VLC_TRUE;\r
-        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-        p_intf->p_sys->p_menus->SetupMenus();\r
-    }\r
-\r
-    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-}\r
-//---------------------------------------------------------------------------\r
-void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )\r
-{\r
-    input_area_t  * p_area;\r
-\r
-    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-    p_area = p_intf->p_sys->p_input->stream.p_selected_area;\r
-\r
-    if( p_area->i_part + 1 < p_area->i_part_nb )\r
-    {\r
-        p_area->i_part++;\r
-        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-\r
-        input_ChangeArea( p_intf->p_sys->p_input, p_area );\r
-        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
-\r
-        p_intf->p_sys->b_chapter_update = VLC_TRUE;\r
-        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-        p_intf->p_sys->p_menus->SetupMenus();\r
-    }\r
-\r
-    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * Callback for the 'go!' button\r
- ****************************************************************************/\r
-void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )\r
-{\r
-    int i_channel;\r
-\r
-    i_channel = SpinEditChannel->Value;\r
-    msg_Dbg( p_intf, "joining channel %d", i_channel );\r
-\r
-    vlc_mutex_lock( &p_intf->change_lock );\r
-    network_ChannelJoin( p_intf, i_channel );\r
-    vlc_mutex_unlock( &p_intf->change_lock );\r
-\r
-//    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * ModeManage: actualise the aspect of the interface whenever the input\r
- *             changes.\r
- *****************************************************************************\r
- * The lock has to be taken before you call the function.\r
- *****************************************************************************/\r
-void __fastcall TMainFrameDlg::ModeManage()\r
-{\r
-    TGroupBox     * ActiveGB;\r
-    int             i_Height;\r
-    bool            b_control;\r
-\r
-    /* hide all boxes */\r
-    GroupBoxFile->Visible = false;\r
-    GroupBoxNetwork->Visible = false;\r
-    GroupBoxDisc->Visible = false;\r
-\r
-    /* hide slider */\r
-    GroupBoxSlider->Hide();\r
-\r
-    /* controls unavailable */\r
-    b_control = 0;\r
-\r
-    /* show the box related to current input mode */\r
-    if( p_intf->p_sys->p_input != NULL )\r
-    {\r
-        switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )\r
-        {\r
-            case INPUT_METHOD_FILE:\r
-                GroupBoxFile->Visible = true;\r
-                ActiveGB = GroupBoxFile;\r
-                LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;\r
-                break;\r
-            case INPUT_METHOD_DISC:\r
-                GroupBoxDisc->Visible = true;\r
-                ActiveGB = GroupBoxDisc;\r
-                break;\r
-            case INPUT_METHOD_NETWORK:\r
-                GroupBoxNetwork->Visible = true;\r
-                ActiveGB = GroupBoxNetwork;\r
-                LabelServer->Caption = p_intf->p_sys->p_input->psz_source;\r
-                if( config_GetInt( p_intf, "network-channel" ) )\r
-                {\r
-                    LabelChannel->Visible = true;\r
-                }\r
-                else\r
-                {\r
-                    LabelChannel->Visible = false;\r
-                }\r
-                break;\r
-            default:\r
-                msg_Warn( p_intf, "cannot determine input method" );\r
-                GroupBoxFile->Visible = true;\r
-                ActiveGB = GroupBoxFile;\r
-                LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;\r
-                break;\r
-        }\r
-\r
-        i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 54;\r
-\r
-        /* initialize and show slider for seekable streams */\r
-        if( p_intf->p_sys->p_input->stream.b_seekable )\r
-        {\r
-            TrackBar->Position = p_intf->p_sys->OldValue = 0;\r
-            GroupBoxSlider->Show();\r
-            i_Height += GroupBoxSlider->Height;\r
-        }\r
-\r
-        /* control buttons for free pace streams */\r
-        b_control = p_intf->p_sys->p_input->stream.b_pace_control;\r
-\r
-        /* get ready for menu regeneration */\r
-        p_intf->p_sys->b_program_update = 1;\r
-        p_intf->p_sys->b_title_update = 1;\r
-        p_intf->p_sys->b_chapter_update = 1;\r
-        p_intf->p_sys->b_audio_update = 1;\r
-        p_intf->p_sys->b_spu_update = 1;\r
-        p_intf->p_sys->i_part = 0;\r
-\r
-        p_intf->p_sys->p_input->stream.b_changed = 0;\r
-        msg_Dbg( p_intf, "stream has changed, refreshing interface" );\r
-    }\r
-    else\r
-    {\r
-        i_Height = StatusBar->Height + ToolBar->Height + 47;\r
-\r
-        if( config_GetInt( p_intf, "network-channel" ) )\r
-        {\r
-            GroupBoxNetwork->Visible = true;\r
-            LabelChannel->Visible = true;\r
-            i_Height += GroupBoxNetwork->Height + 7;\r
-        }\r
-        else\r
-        {\r
-            /* add space between tolbar and statusbar when\r
-             * nothing is displayed; isn't it nicer ? :) */\r
-            i_Height += 17;\r
-        }\r
-\r
-        /* unsensitize menus */\r
-        MenuProgram->Enabled = false;\r
-        MenuTitle->Enabled = false;\r
-        MenuChapter->Enabled = false;\r
-        MenuLanguage->Enabled = false;\r
-        MenuSubtitles->Enabled = false;\r
-        PopupNavigation->Enabled = false;\r
-        PopupLanguage->Enabled = false;\r
-        PopupSubtitles->Enabled = false;\r
-    }\r
-\r
-    /* resize main window */\r
-    this->Height = i_Height;\r
-\r
-    /* set control items */\r
-    ToolButtonBack->Enabled = false;\r
-    ToolButtonEject->Enabled = !b_control;\r
-    StopAction->Enabled = true;\r
-    PauseAction->Enabled = b_control;\r
-    SlowAction->Enabled = b_control;\r
-    FastAction->Enabled = b_control;\r
-    PopupBack->Enabled = false;\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
-/*****************************************************************************\r
- * CreateConfig: create a configuration dialog and save it for further use\r
- *****************************************************************************\r
- * Check if the dialog box is already opened, if so this will save us\r
- * quite a bit of work. (the interface will be destroyed when you actually\r
- * close the main window, but remember that it is only hidden if you\r
- * clicked on the action buttons). This trick also allows us not to\r
- * duplicate identical dialog windows.\r
- *****************************************************************************/\r
-void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name )\r
-{\r
-    TPreferencesDlg *Preferences;\r
-    int i_index, i_pos;\r
-\r
-    i_index = StringListPref->IndexOf( Name );\r
-    if( i_index != -1 )\r
-    {\r
-        /* config dialog already exists */\r
-        Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];\r
-    }\r
-    else\r
-    {\r
-        /* create the config dialog */\r
-        Preferences = new TPreferencesDlg( this, p_intf );\r
-        Preferences->CreateConfigDialog( Name.c_str() );\r
-\r
-        /* save it */\r
-        i_pos = StringListPref->Add( Name );\r
-        StringListPref->Objects[i_pos] = Preferences;\r
-    }\r
-\r
-    /* display the dialog */\r
-    Preferences->Show();\r
-}\r
-//---------------------------------------------------------------------------\r
-\r
-\r
+        vlc_object_release( p_vout );
+    }
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PlaylistActionExecute( TObject *Sender )
+{
+    TPlaylistDlg *p_playwin = p_intf->p_sys->p_playwin;
+    if( p_playwin->Visible )
+    {
+        p_playwin->Hide();
+    }
+    else
+    {
+        p_playwin->UpdateGrid();
+        p_playwin->Show();
+    }
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::MessagesActionExecute( TObject *Sender )
+{
+     p_intf->p_sys->p_messages->Show();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PreferencesActionExecute( TObject *Sender )
+{
+    CreatePreferences( "main" );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::AboutActionExecute( TObject *Sender )
+{
+    TAboutDlg *AboutDlg = new TAboutDlg( this, p_intf );
+    AboutDlg->ShowModal();
+    delete AboutDlg;
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::BackActionExecute( TObject *Sender )
+{
+    /* TODO */
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PlayActionExecute( TObject *Sender )
+{
+    p_intf->p_sys->p_playwin->Play();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PauseActionExecute( TObject *Sender )
+{
+    p_intf->p_sys->p_playwin->Pause();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::StopActionExecute( TObject *Sender )
+{
+    p_intf->p_sys->p_playwin->Stop();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::SlowActionExecute( TObject *Sender )
+{
+    p_intf->p_sys->p_playwin->Slow();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::FastActionExecute( TObject *Sender )
+{
+    p_intf->p_sys->p_playwin->Fast();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PreviousActionExecute(TObject *Sender)
+{
+    p_intf->p_sys->p_playwin->Previous();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::NextActionExecute(TObject *Sender)
+{
+    p_intf->p_sys->p_playwin->Next();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )
+{
+    AnsiString Device = "";
+    char * psz_current;
+    playlist_t * p_playlist;
+
+    p_playlist = (playlist_t *)vlc_object_find( p_intf,
+                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist == NULL )
+    {
+        return;
+    }
+
+    /*
+     * Get the active input
+     * Determine whether we can eject a media, ie it's a VCD or DVD
+     * If it's neither a VCD nor a DVD, then return
+     */
+
+    vlc_mutex_lock( &p_playlist->object_lock );
+    psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;
+
+    if( psz_current != NULL )
+    {
+        if( strncmp( psz_current, "dvd", 3 )
+            || strncmp( psz_current, "vcd", 3 ) )
+        {
+            /* Determine the device name by omitting the first 4 characters
+             * and keeping 3 characters */
+            Device = strdup( ( psz_current + 4 ) );
+            Device = Device.SubString( 1, 2 );
+        }
+    }
+
+    vlc_mutex_unlock( &p_playlist->object_lock );
+    vlc_object_release( p_playlist );
+
+    if( Device == "" )
+    {
+        return;
+    }
+
+    /* If there's a stream playing, we aren't allowed to eject ! */
+    if( p_intf->p_sys->p_input == NULL )
+    {
+        msg_Dbg( p_intf, "ejecting %s", Device.c_str() );
+
+        intf_Eject( p_intf, Device.c_str() );
+    }
+}
+//--------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )
+{
+    aout_VolumeUp( p_intf, 1, NULL );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )
+{
+    aout_VolumeDown( p_intf, 1, NULL );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )
+{
+    aout_VolumeMute( p_intf, NULL );
+//    MenuMute->Checked = ! MenuMute->Checked;
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * External drop handling
+ *****************************************************************************/
+void __fastcall TMainFrameDlg::OnDrop( TMessage &Msg )
+{
+    /* find the number of files dropped */
+    int num_files = DragQueryFile( (HDROP)Msg.WParam, 0xFFFFFFFF,
+                                   (LPSTR)NULL, NULL );
+
+    /* append each file to the playlist */
+    for( int i = 0; i < num_files; i++ )
+    {
+        /* find the length of the filename */
+        int name_length = DragQueryFile( (HDROP)Msg.WParam, i, NULL, NULL ) + 1;
+
+        /* get the filename */
+        char *FileName = new char[name_length];
+        DragQueryFile( (HDROP)Msg.WParam, i, FileName, name_length );
+
+        /* add the new file to the playlist */
+        if( config_GetInt( p_intf, "enqueue" ) )
+        {
+            p_intf->p_sys->p_playwin->Add( FileName,
+                PLAYLIST_APPEND, PLAYLIST_END );
+        }
+        else
+        {
+            p_intf->p_sys->p_playwin->Add( FileName,
+                PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        }
+
+        delete[] FileName;
+    }
+
+    DragFinish( (HDROP)Msg.WParam );
+    Msg.Result = 0;
+}
+//--------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * Menu and popup callbacks
+ *****************************************************************************/
+void __fastcall TMainFrameDlg::MenuHideinterfaceClick( TObject *Sender )
+{
+     this->SendToBack();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )
+{
+    this->BringToFront();
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )
+{
+    /* We do nothing, we just need a click on a menu item
+     * to close the popup. Don't ask me why... */
+    return;
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )
+{
+    /* TODO */
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * Callbacks for DVD/VCD navigation
+ ****************************************************************************/
+void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender )
+{
+    input_area_t  * p_area;
+    int             i_id;
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;
+
+    /* Disallow area 0 since it is used for video_ts.vob */
+    if( i_id > 0 )
+    {
+        p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_title_update = VLC_TRUE;
+        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+        p_intf->p_sys->p_menus->SetupMenus();
+    }
+
+    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender )
+{
+    input_area_t  * p_area;
+    unsigned int    i_id;
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;
+
+    if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
+    {
+        p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_title_update = VLC_TRUE;
+        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+        p_intf->p_sys->p_menus->SetupMenus();
+    }
+
+    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender )
+{
+    input_area_t  * p_area;
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+
+    if( p_area->i_part - 1 > 0 )
+    {
+        p_area->i_part--;
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_chapter_update = VLC_TRUE;
+        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+        p_intf->p_sys->p_menus->SetupMenus();
+    }
+
+    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+}
+//---------------------------------------------------------------------------
+void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )
+{
+    input_area_t  * p_area;
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+
+    if( p_area->i_part + 1 < p_area->i_part_nb )
+    {
+        p_area->i_part++;
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+
+        p_intf->p_sys->b_chapter_update = VLC_TRUE;
+        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+        p_intf->p_sys->p_menus->SetupMenus();
+    }
+
+    vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * Callback for the 'go!' button
+ ****************************************************************************/
+void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )
+{
+    int i_channel;
+
+    i_channel = SpinEditChannel->Value;
+    msg_Dbg( p_intf, "joining channel %d", i_channel );
+
+    vlc_mutex_lock( &p_intf->change_lock );
+    network_ChannelJoin( p_intf, i_channel );
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+//    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * ModeManage: actualise the aspect of the interface whenever the input
+ *             changes.
+ *****************************************************************************
+ * The lock has to be taken before you call the function.
+ *****************************************************************************/
+void __fastcall TMainFrameDlg::ModeManage()
+{
+    TGroupBox     * ActiveGB;
+    int             i_Height;
+    bool            b_control;
+
+    /* hide all boxes */
+    GroupBoxFile->Visible = false;
+    GroupBoxNetwork->Visible = false;
+    GroupBoxDisc->Visible = false;
+
+    /* hide slider */
+    GroupBoxSlider->Hide();
+
+    /* controls unavailable */
+    b_control = 0;
+
+    /* show the box related to current input mode */
+    if( p_intf->p_sys->p_input != NULL )
+    {
+        switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )
+        {
+            case INPUT_METHOD_FILE:
+                GroupBoxFile->Visible = true;
+                ActiveGB = GroupBoxFile;
+                LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;
+                break;
+            case INPUT_METHOD_DISC:
+                GroupBoxDisc->Visible = true;
+                ActiveGB = GroupBoxDisc;
+                break;
+            case INPUT_METHOD_NETWORK:
+                GroupBoxNetwork->Visible = true;
+                ActiveGB = GroupBoxNetwork;
+                LabelServer->Caption = p_intf->p_sys->p_input->psz_source;
+                if( config_GetInt( p_intf, "network-channel" ) )
+                {
+                    LabelChannel->Visible = true;
+                }
+                else
+                {
+                    LabelChannel->Visible = false;
+                }
+                break;
+            default:
+                msg_Warn( p_intf, "cannot determine input method" );
+                GroupBoxFile->Visible = true;
+                ActiveGB = GroupBoxFile;
+                LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;
+                break;
+        }
+
+        i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 54;
+
+        /* initialize and show slider for seekable streams */
+        if( p_intf->p_sys->p_input->stream.b_seekable )
+        {
+            TrackBar->Position = p_intf->p_sys->OldValue = 0;
+            GroupBoxSlider->Show();
+            i_Height += GroupBoxSlider->Height;
+        }
+
+        /* control buttons for free pace streams */
+        b_control = p_intf->p_sys->p_input->stream.b_pace_control;
+
+        /* get ready for menu regeneration */
+        p_intf->p_sys->b_program_update = 1;
+        p_intf->p_sys->b_title_update = 1;
+        p_intf->p_sys->b_chapter_update = 1;
+        p_intf->p_sys->b_audio_update = 1;
+        p_intf->p_sys->b_spu_update = 1;
+        p_intf->p_sys->i_part = 0;
+
+        p_intf->p_sys->p_input->stream.b_changed = 0;
+        msg_Dbg( p_intf, "stream has changed, refreshing interface" );
+    }
+    else
+    {
+        i_Height = StatusBar->Height + ToolBar->Height + 47;
+
+        if( config_GetInt( p_intf, "network-channel" ) )
+        {
+            GroupBoxNetwork->Visible = true;
+            LabelChannel->Visible = true;
+            i_Height += GroupBoxNetwork->Height + 7;
+        }
+        else
+        {
+            /* add space between tolbar and statusbar when
+             * nothing is displayed; isn't it nicer ? :) */
+            i_Height += 17;
+        }
+
+        /* unsensitize menus */
+        MenuProgram->Enabled = false;
+        MenuTitle->Enabled = false;
+        MenuChapter->Enabled = false;
+        MenuLanguage->Enabled = false;
+        MenuSubtitles->Enabled = false;
+        PopupNavigation->Enabled = false;
+        PopupLanguage->Enabled = false;
+        PopupSubtitles->Enabled = false;
+    }
+
+    /* resize main window */
+    this->Height = i_Height;
+
+    /* set control items */
+    ToolButtonBack->Enabled = false;
+    ToolButtonEject->Enabled = !b_control;
+    StopAction->Enabled = true;
+    PauseAction->Enabled = b_control;
+    SlowAction->Enabled = b_control;
+    FastAction->Enabled = b_control;
+    PopupBack->Enabled = false;
+}
+//---------------------------------------------------------------------------
+
+
+/*****************************************************************************
+ * CreateConfig: create a configuration dialog and save it for further use
+ *****************************************************************************
+ * Check if the dialog box is already opened, if so this will save us
+ * quite a bit of work. (the interface will be destroyed when you actually
+ * close the main window, but remember that it is only hidden if you
+ * clicked on the action buttons). This trick also allows us not to
+ * duplicate identical dialog windows.
+ *****************************************************************************/
+void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name )
+{
+    TPreferencesDlg *Preferences;
+    int i_index, i_pos;
+
+    i_index = StringListPref->IndexOf( Name );
+    if( i_index != -1 )
+    {
+        /* config dialog already exists */
+        Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];
+    }
+    else
+    {
+        /* create the config dialog */
+        Preferences = new TPreferencesDlg( this, p_intf );
+        Preferences->CreateConfigDialog( Name.c_str() );
+
+        /* save it */
+        i_pos = StringListPref->Add( Name );
+        StringListPref->Objects[i_pos] = Preferences;
+    }
+
+    /* display the dialog */
+    Preferences->Show();
+}
+//---------------------------------------------------------------------------
+
+