]> git.sesse.net Git - vlc/commitdiff
Change backgroundwidget and mediainfo-dialog to use THEMIM
authorIlkka Ollakka <ileoo@videolan.org>
Thu, 13 Dec 2007 08:13:56 +0000 (08:13 +0000)
committerIlkka Ollakka <ileoo@videolan.org>
Thu, 13 Dec 2007 08:13:56 +0000 (08:13 +0000)
inputChanged-signal instead of polling.

I think that iteration-count for this one is still under 10 ;)

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/dialogs/mediainfo.cpp
modules/gui/qt4/dialogs/mediainfo.hpp

index 1c173139c6dfd15985c3f479949f02025cc33bd8..8eaa7ad483eefb4b7101db0e1a671d496fec878f 100644 (file)
@@ -50,8 +50,6 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
                         unsigned int *, unsigned int * );
 static void DoRelease( intf_thread_t *, void * );
 static int DoControl( intf_thread_t *, void *, int, va_list );
-static int ItemChanged( vlc_object_t *, const char *,
-                        vlc_value_t, vlc_value_t, void * );
 
 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
 {
@@ -149,34 +147,16 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
 
     resize( 300, 150 );
     updateGeometry();
-    i_runs = 0;
-    b_need_update = VLC_FALSE;
-    var_AddCallback( THEPL, "item-change", ItemChanged, this );
-    ON_TIMEOUT( update() );
+    CONNECT( THEMIM, inputChanged( input_thread_t *), this, update( input_thread_t * ) );
 }
 
 BackgroundWidget::~BackgroundWidget()
 {
-    var_DelCallback( THEPL, "item-change", ItemChanged, this );
 }
 
-static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
-        vlc_value_t oldval, vlc_value_t newval, void *param )
-{
-    BackgroundWidget *p_d = (BackgroundWidget*)param;
-    p_d->b_need_update = VLC_TRUE;
-    return VLC_SUCCESS;
-}
 
-void BackgroundWidget::update()
+void BackgroundWidget::update( input_thread_t *p_input )
 {
-    /* Timer runs at 150 ms, dont' update more than once every 750ms */
-    i_runs++;
-    if( i_runs % 6 != 0 ) return;
-
-    /* Get Input and clear if non-existant */
-    input_thread_t *p_input =
-                     MainInputManager::getInstance( p_intf )->getInput();
     if( !p_input || p_input->b_dead )
     {
         label->setPixmap( QPixmap( ":/vlc128.png" ) );
@@ -184,23 +164,19 @@ void BackgroundWidget::update()
     }
 
 
-    if( b_need_update )
+    vlc_object_yield( p_input );
+    char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
+    vlc_object_release( p_input );
+    QString url = qfu( psz_arturl );
+    QString arturl = url.replace( "file://",QString("" ) );
+    if( arturl.isNull() )
+        label->setPixmap( QPixmap( ":/vlc128.png" ) );
+    else
     {
-        vlc_object_yield( p_input );
-        char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
-        vlc_object_release( p_input );
-        QString url = qfu( psz_arturl );
-        QString arturl = url.replace( "file://",QString("" ) );
-        if( arturl.isNull() )
-            label->setPixmap( QPixmap( ":/vlc128.png" ) );
-        else
-        {
-            label->setPixmap( QPixmap( arturl ) );
-            msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
-        }
-        free( psz_arturl );
+        label->setPixmap( QPixmap( arturl ) );
+        msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
     }
-    b_need_update = false;
+    free( psz_arturl );
 }
 
 QSize BackgroundWidget::sizeHint() const
index e72522a8746ed51b09885e1aabe28d9e43eeba39..3516f2e2e6783c914bfc638634f112bd0b4ad87c 100644 (file)
@@ -90,7 +90,7 @@ private:
     int i_runs;
 public slots:
     void toggle(){ TOGGLEV( this ); }
-    void update( void );
+    void update( input_thread_t * );
 };
 
 class VisualSelector : public QFrame
index 78839586721ad13d370931920f8b6fa8dad858e3..fc69d0e71d849c3deb1ebca5a62460789afea24b 100644 (file)
@@ -31,8 +31,6 @@
 #include <QLineEdit>
 #include <QLabel>
 
-static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
-                        vlc_value_t oldval, vlc_value_t newval, void *param );
 MediaInfoDialog *MediaInfoDialog::instance = NULL;
 
 MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
@@ -92,18 +90,13 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
 
     CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
 
-    /* Create the main Update function with a time (150ms) */
-    if( mainInput ) {
-        ON_TIMEOUT( updateOnTimeOut() );
-        var_AddCallback( THEPL, "item-change", ItemChanged, this );
-    }
+    CONNECT( THEMIM, inputChanged( input_thread_t * ), this, update( input_thread_t * ) );
+    /* Call update by hand, so info is shown from current item too */
+    update( input_GetItem(THEMIM->getInput()), true, true );
 }
 
 MediaInfoDialog::~MediaInfoDialog()
 {
-    if( mainInput ) {
-        var_DelCallback( THEPL, "item-change", ItemChanged, this );
-    }
     writeSettings( "mediainfo" );
 }
 
@@ -124,23 +117,9 @@ void MediaInfoDialog::saveMeta()
     saveMetaButton->hide();
 }
 
-static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
-        vlc_value_t oldval, vlc_value_t newval, void *param )
-{
-    MediaInfoDialog *p_d = (MediaInfoDialog *)param;
-    p_d->b_need_update = VLC_TRUE;
-    return VLC_SUCCESS;
-}
-
-/* Function called on TimeOut */
-void MediaInfoDialog::updateOnTimeOut()
+/* Function called on inputChanged-update*/
+void MediaInfoDialog::update( input_thread_t *p_input )
 {
-    /* Timer runs at 150 ms, dont' update more than 2 times per second */
-    i_runs++;
-    if( i_runs % 4 != 0 ) return;
-
-    /* Get Input and clear if non-existant */
-    input_thread_t *p_input = THEMIM->getInput();
     if( !p_input || p_input->b_dead )
     {
         if( !b_cleaned )
index 91e380ffb61a7a36f61ffd8db1217e3f14387eee..76ad847d2fab4d0b492278867c8494512162a02a 100644 (file)
@@ -83,7 +83,7 @@ private:
     QLineEdit *uriLine;
 
 public slots:
-    void updateOnTimeOut();
+    void update( input_thread_t * );
     void update( input_item_t *, bool, bool );
 
 private slots: