]> git.sesse.net Git - vlc/commitdiff
* ./plugins/kde/*: the KDE interface now works again.
authorSam Hocevar <sam@videolan.org>
Mon, 1 Jul 2002 17:39:27 +0000 (17:39 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 1 Jul 2002 17:39:27 +0000 (17:39 +0000)
plugins/kde/kde.cpp
plugins/kde/kde_disc.cpp
plugins/kde/kde_interface.cpp
plugins/kde/kde_interface.h
plugins/kde/kde_menu.cpp
plugins/kde/kde_net.cpp
plugins/kde/kde_preferences.cpp

index 04fb6262a17f1f8291bc53392fe402fb7cf8830c..92b8c65976fcef6ba3bba5cfeb0fd7588bfdcc6d 100644 (file)
@@ -2,7 +2,7 @@
  * kde.cpp : KDE plugin for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: kde.cpp,v 1.13 2002/06/01 12:31:59 sam Exp $
+ * $Id: kde.cpp,v 1.14 2002/07/01 17:39:27 sam Exp $
  *
  * Authors: Andres Krapf <dae@chez.com> Sun Mar 25 2001
  *
@@ -116,9 +116,12 @@ KThread::KThread(intf_thread_t *p_intf)
     this->p_intf = p_intf;
 
     p_intf->p_sys->p_about =
-        new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
-            "This is the VideoLAN client, a DVD and MPEG player. It can play MPEG and MPEG 2 files from a file or from a network source.", KAboutData::License_GPL,
-            "(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team", 0, 0, "dae@chez.com");
+      new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
+         _("This is the VideoLAN client, a DVD and MPEG player. It can play "
+           "MPEG and MPEG 2 files from a file or from a network source."),
+         KAboutData::License_GPL,
+         _("(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team"),
+         0, 0, "");
 
     char *authors[][2] = {
         { "the VideoLAN Team", "<videolan@videolan.org>" },
@@ -136,6 +139,8 @@ KThread::KThread(intf_thread_t *p_intf)
     p_intf->p_sys->p_app = new KApplication();
     p_intf->p_sys->p_window = new KInterface(p_intf);
     p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
+
+    p_intf->p_sys->p_input = NULL;
 }
 
 /*****************************************************************************
@@ -143,6 +148,11 @@ KThread::KThread(intf_thread_t *p_intf)
  *****************************************************************************/
 KThread::~KThread()
 {
+    if( p_intf->p_sys->p_input )
+    {
+        vlc_object_release( p_intf->p_sys->p_input );
+    }
+
     /* XXX: can be deleted if the user closed the window ! */
     //delete p_intf->p_sys->p_window;
 
index a5475ee535e9bd8fe71aded283673172e18f78cd..86e0a08c5c8534b47acc37ba87fd157fdb789582 100644 (file)
@@ -37,14 +37,14 @@ KDiskDialog::KDiskDialog( QWidget *parent, const char *name )
     QVGroupBox *startVBox = new QVGroupBox( "Starting position", deviceSelectHBox );
 
     QHBox *titleHBox = new QHBox( startVBox );
-    QLabel *titleLabel = new QLabel( "Title ", titleHBox );
+    new QLabel( "Title ", titleHBox );
     fTitle = new QSpinBox( titleHBox );
     QHBox *chapterHBox = new QHBox( startVBox );
-    QLabel *chapterLabel = new QLabel( "Chapter ", chapterHBox );
+    new QLabel( "Chapter ", chapterHBox );
     fChapter = new QSpinBox( chapterHBox );
 
     QHBox *deviceNameHBox = new QHBox( pageVBox );
-    QLabel *deviceNameLabel = new QLabel( "Device name ", deviceNameHBox );
+    new QLabel( "Device name ", deviceNameHBox );
     fLineEdit = new KLineEdit( "/dev/dvd", deviceNameHBox );
 }
 
index 6c2996408cabfb7a686fdb20ce62fe9bd5ee64a4..14a3ff3c2f7c75e82764a736c0ae1d222ec41882 100644 (file)
@@ -136,14 +136,23 @@ void KInterface::initStatusBar()
 
 void KInterface::slotFileOpen()
 {
+    playlist_t *p_playlist;
+
     slotStatusMsg( i18n( "Opening file..." ) );
     KURL url=KFileDialog::getOpenURL( QString::null,
             i18n( "*|All files" ), this, i18n( "Open File..." ) );
 
     if( !url.isEmpty() )
     {
-        fileOpenRecent->addURL( url );
-        intf_PlaylistAdd( p_intf->p_vlc->p_playlist, PLAYLIST_END, url.path() );
+        p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+        if( p_playlist )
+        {
+            fileOpenRecent->addURL( url );
+            playlist_Add( p_playlist, url.path(),
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+            vlc_object_release( p_playlist );
+        }
     }
 
     slotStatusMsg( i18n( "Ready." ) );
@@ -167,7 +176,7 @@ void KInterface::slotFileClose()
 void KInterface::slotFileQuit()
 {
     slotStatusMsg(i18n("Exiting..."));
-    p_intf->p_sys->p_app->quit();
+    p_intf->p_vlc->b_die = 1;
     slotStatusMsg(i18n("Ready."));
 }
 
@@ -223,6 +232,18 @@ void KInterface::slotManage()
 {
     vlc_mutex_lock( &p_intf->change_lock );
 
+    /* Update the input */
+    if( p_intf->p_sys->p_input == NULL )
+    {
+        p_intf->p_sys->p_input = (input_thread_t *)
+                vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
+    }
+    else if( p_intf->p_sys->p_input->b_dead )
+    {
+        vlc_object_release( p_intf->p_sys->p_input );
+        p_intf->p_sys->p_input = NULL;
+    }
+
     /* If the "display popup" flag has changed */
     if( p_intf->b_menu_change )
     {
@@ -232,7 +253,7 @@ void KInterface::slotManage()
 
     /* Update language/chapter menus after user request */
 #if 0
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL && p_intf->p_sys->p_window != NULL &&
+    if( p_intf->p_sys->p_input != NULL && p_intf->p_sys->p_window != NULL &&
         p_intf->p_sys->b_menus_update )
     {
 //        GnomeSetupMenu( p_intf );
@@ -240,17 +261,14 @@ void KInterface::slotManage()
 #endif
 
     /* Manage the slider */
-#define p_area p_intf->p_vlc->p_input_bank->pp_input[0]->stream.p_selected_area
-    if( (p_intf->p_vlc->p_input_bank->pp_input[0] != NULL) && (p_area->i_size != 0 ))
+#define p_area p_intf->p_sys->p_input->stream.p_selected_area
+    if( p_intf->p_sys->p_input && p_area->i_size )
     {
        fSlider->setValue( ( 10000. * p_area->i_tell ) / p_area->i_size );
     }
 #undef p_area
 
-    /* Manage core vlc functions through the callback */
-    p_intf->pf_manage(p_intf);
-
-    if( p_intf->p_vlc->b_die )
+    if( p_intf->b_die )
     {
         p_intf->p_sys->p_app->quit();
     }
@@ -260,33 +278,37 @@ void KInterface::slotManage()
 
 void KInterface::slotSliderMoved( int position )
 {
-// XXX is this locking really useful ?
-    vlc_mutex_lock( &p_intf->change_lock );
+    if( p_intf->p_sys->p_input )
+    {
+        // XXX is this locking really useful ?
+        vlc_mutex_lock( &p_intf->change_lock );
 
-    off_t i_seek = ( position * p_intf->p_vlc->p_input_bank->pp_input[0]->stream.p_selected_area->i_size ) / 10000;
-    input_Seek( p_intf->p_vlc->p_input_bank->pp_input[0]->p_this, i_seek, INPUT_SEEK_SET );
+        off_t i_seek = ( position * p_intf->p_sys->p_input->stream.p_selected_area->i_size ) / 10000;
+        input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET );
 
-    vlc_mutex_unlock( &p_intf->change_lock );
+        vlc_mutex_unlock( &p_intf->change_lock );
+    }
 }
 
 void KInterface::slotSliderChanged( int position )
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    if( p_intf->p_sys->p_input != NULL )
     {
         char psz_time[ OFFSETTOTIME_MAX_SIZE ];
 
-        vlc_mutex_lock( &p_intf->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
+        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
 
-#define p_area p_intf->p_vlc->p_input_bank->pp_input[0]->stream.p_selected_area
-        statusBar()->changeItem( input_OffsetToTime( p_intf->p_vlc->p_input_bank->pp_input[0], psz_time, ( p_area->i_size * position ) / 10000 ), ID_DATE );
+#define p_area p_intf->p_sys->p_input->stream.p_selected_area
+        statusBar()->changeItem( input_OffsetToTime( p_intf->p_sys->p_input, psz_time, ( p_area->i_size * position ) / 10000 ), ID_DATE );
 #undef p_area
 
-        vlc_mutex_unlock( &p_intf->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
      }
 }
 
 void KInterface::slotOpenDisk()
 {
+    playlist_t *p_playlist;
     int r = fDiskDialog->exec();
     if ( r )
     {
@@ -301,20 +323,21 @@ void KInterface::slotOpenDisk()
         source += ',';
         source += fDiskDialog->chapter();
 
-        // add it to playlist
-        intf_PlaylistAdd( p_intf->p_vlc->p_playlist, PLAYLIST_END, source.latin1() );
-
-        // Select added item and switch to disk interface
-        intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, p_intf->p_vlc->p_playlist->i_size-2 );
-        if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+        p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+        if( p_playlist )
         {
-            p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
+            // add it to playlist
+            playlist_Add( p_playlist, source.latin1(),
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+            vlc_object_release( p_playlist );
         }
     }
 }
 
 void KInterface::slotOpenStream()
 {
+    playlist_t *p_playlist;
     int r = fNetDialog->exec();
     if ( r )
     {
@@ -326,47 +349,42 @@ void KInterface::slotOpenStream()
         source += ":";
         source += QString().setNum( fNetDialog->port() );
 
-        // add it to playlist
-        intf_PlaylistAdd( p_intf->p_vlc->p_playlist, PLAYLIST_END, source.latin1() );
-        intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, p_intf->p_vlc->p_playlist->i_size-2 );
-
-        if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+        p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+        if( p_playlist )
         {
-            p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
+            // add it to playlist
+            playlist_Add( p_playlist, source.latin1(),
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+            vlc_object_release( p_playlist );
         }
     }
 }
 
 void KInterface::slotPlay()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    if( p_intf->p_sys->p_input )
     {
-        input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_PLAY );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
     }
 }
 
 void KInterface::slotPause()
 {
-    if ( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    if ( p_intf->p_sys->p_input )
     {
-        input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
     }
 }
 
 void KInterface::slotStop()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    playlist_t *p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist )
     {
-        /* end playing item */
-        p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
-
-        /* update playlist */
-        vlc_mutex_lock( &p_intf->p_vlc->p_playlist->change_lock );
-
-        p_intf->p_vlc->p_playlist->i_index--;
-        p_intf->p_vlc->p_playlist->b_stopped = 1;
-
-        vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
+        playlist_Stop( p_playlist );
+        vlc_object_release( p_playlist );
     }
 }
 
@@ -377,37 +395,39 @@ void KInterface::slotBackward()
 
 void KInterface::slotPrev()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    playlist_t *p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist )
     {
-        /* FIXME: temporary hack */
-        intf_PlaylistPrev( p_intf->p_vlc->p_playlist );
-        intf_PlaylistPrev( p_intf->p_vlc->p_playlist );
-        p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
+        playlist_Prev( p_playlist );
+        vlc_object_release( p_playlist );
     }
 }
 
 void KInterface::slotNext()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    playlist_t *p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist )
     {
-        /* FIXME: temporary hack */
-        p_intf->p_vlc->p_input_bank->pp_input[0]->b_eof = 1;
+        playlist_Next( p_playlist );
+        vlc_object_release( p_playlist );
     }
 }
 
 void KInterface::slotSlow()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    if( p_intf->p_sys->p_input != NULL )
     {
-        input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_SLOWER );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
     }
 }
 
 void KInterface::slotFast()
 {
-    if( p_intf->p_vlc->p_input_bank->pp_input[0] != NULL )
+    if( p_intf->p_sys->p_input != NULL )
     {
-        input_SetStatus( p_intf->p_vlc->p_input_bank->pp_input[0], INPUT_STATUS_FASTER );
+        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
     }
 }
 
@@ -420,7 +440,15 @@ void KInterface::dropEvent( QDropEvent *event )
 {
     KURL::List urlList;
 
-    if ( KURLDrag::decode( event, urlList ) ) {
+    playlist_t *p_playlist = (playlist_t *)
+            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    if( p_playlist == NULL )
+    {
+        return;
+    }
+
+    if ( KURLDrag::decode( event, urlList ) )
+    {
         for ( KURL::List::ConstIterator i = urlList.begin(); i != urlList.end(); i++ )
         {
             // XXX add a private function to add a KURL with checking
@@ -428,8 +456,11 @@ void KInterface::dropEvent( QDropEvent *event )
             if( !(*i).isEmpty() )
             {
                 fileOpenRecent->addURL( *i );
-                intf_PlaylistAdd( p_intf->p_vlc->p_playlist, PLAYLIST_END, (*i).path() );
+                playlist_Add( p_playlist, (*i).path(),
+                          PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
             }
         }
     }
+
+    vlc_object_release( p_playlist );
 }
index c3494bf0831af60befe80b4a416886b205b8d790..0442286e7f6d5a41a9e49b69ae7ad1eeac7bcc36 100644 (file)
@@ -143,6 +143,8 @@ struct intf_sys_s
     KApplication *p_app;
     KInterface   *p_window;
     KAboutData   *p_about;
+
+    input_thread_t *p_input;
 };
 
 #endif /* _KDE_INTERFACE_H_ */
index 6dd666aaddd1acba92d6937805d877e064ffeee5..f18345d6b500c226ddf30dc5f22733959d41dc32 100644 (file)
@@ -6,6 +6,7 @@
     email                : dae@chez.com
  ***************************************************************************/
 
+#include "kde_interface.h"
 #include "kde_menu.h"
 
 #include <kaction.h>
@@ -29,14 +30,14 @@ void KTitleMenu::regenerateSlot()
     fLanguageList = new KActionMenu( "Language", 0, this );
 
     int i_item = 0;
-    vlc_mutex_lock( &fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
+    vlc_mutex_lock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
 
-    for( int i = 0 ; i < fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.i_es_number ; i++ )
+    for( int i = 0 ; i < fInterfaceThread->p_sys->p_input->stream.i_es_number ; i++ )
     {
-        if( fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.pp_es[i]->i_cat /* == i_cat */ )
+        if( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->i_cat /* == i_cat */ )
         {
             i_item++;
-            QString language( fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.pp_es[i]->psz_desc );
+            QString language( fInterfaceThread->p_sys->p_input->stream.pp_es[i]->psz_desc );
             if ( QString::null == language )
             {
                 language += i18n( "Language" );
@@ -45,7 +46,7 @@ void KTitleMenu::regenerateSlot()
             KRadioAction *action = new KRadioAction( language, 0, this, "language_action" );
             fLanguageList->insert( action );
 
-            if( /* p_es == */ fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.pp_es[i] )
+            if( /* p_es == */ fInterfaceThread->p_sys->p_input->stream.pp_es[i] )
             {
                 /* don't lose p_item when we append into menu */
                 //p_item_active = p_item;
@@ -53,7 +54,7 @@ void KTitleMenu::regenerateSlot()
         }
     }
 
-    vlc_mutex_unlock( &fInterfaceThread->p_vlc->p_input_bank->pp_input[0]->stream.stream_lock );
+    vlc_mutex_unlock( &fInterfaceThread->p_sys->p_input->stream.stream_lock );
 
 #if 0
     /* link the new menu to the menubar item */
index 0f1d510ff785481d0c3e1d498e1e2792ee6c586c..4ccf836cac61992d00df49913e26c94a372cfdd0 100644 (file)
@@ -39,10 +39,10 @@ KNetDialog::KNetDialog( QWidget *parent, const char *name )
     QVGroupBox *serverVBox = new QVGroupBox( "Starting position", layout );
 
     QHBox *titleHBox = new QHBox( serverVBox );
-    QLabel *titleLabel = new QLabel( "Address ", titleHBox );
+    new QLabel( "Address ", titleHBox );
     fAddress = new KLineEdit( "vls", titleHBox );
     QHBox *portHBox = new QHBox( serverVBox );
-    QLabel *portLabel = new QLabel( "Port ", portHBox );
+    new QLabel( "Port ", portHBox );
     fPort = new QSpinBox( 0, 65535, 1, portHBox );
 }
 
index cb492521617cf27bab38aeacb27ac21a11590e35..f3605b2cb63307e5cbc44d1f616a9a6f0f7cfb25 100644 (file)
@@ -41,7 +41,7 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
          p_module = p_module->next )
     {
 
-        if( psz_module_name && !strcmp( psz_module_name, p_module->psz_name ) )
+        if( psz_module_name && !strcmp( psz_module_name, p_module->psz_object_name ) )
             break;
     }
     if( !p_module ) return;
@@ -100,7 +100,7 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
                      p_module_bis = p_module_bis->next ) {
                     if( p_module_bis->i_capabilities & (1 << p_item->i_value)){
                         new QListViewItem(item_frame->getListView(),
-                                          p_module_bis->psz_name,
+                                          p_module_bis->psz_object_name,
                                           p_module_bis->psz_longname);
                     }
                 }
@@ -211,7 +211,7 @@ bool KPreferences::isConfigureable(QString module)
     for( p_module = p_intf->p_vlc->module_bank.first ;
          p_module != NULL ;
          p_module = p_module->next ) {
-        if( !module.compare( p_module->psz_name ) ) {
+        if( !module.compare( p_module->psz_object_name ) ) {
             return p_module->i_config_items != 0;
         }
     }