]> git.sesse.net Git - vlc/commitdiff
* Some Qt interaction stuff
authorClément Stenac <zorglub@videolan.org>
Thu, 3 Aug 2006 06:10:57 +0000 (06:10 +0000)
committerClément Stenac <zorglub@videolan.org>
Thu, 3 Aug 2006 06:10:57 +0000 (06:10 +0000)
* More useless interaction cleanup
* Small fix for make beautifier

extras/make.pl
include/vlc_interaction.h
modules/demux/avi/avi.c
modules/demux/avi/libavi.c
modules/gui/qt4/dialogs/interaction.cpp
modules/gui/qt4/util/qvlcframe.hpp
modules/gui/wxwidgets/dialogs/interaction.cpp
src/interface/interaction.c

index 38850c2bd1082759cce16152bd8a6759b4169497..c4b2bd4bfee3f23e1e8c85b66286fe403b389c0e 100755 (executable)
@@ -23,30 +23,30 @@ while(<STDIN>)
      $line = $_;
      chomp $line;
      # Skip entering/leaving directories and incomplete lines
-     if( 
+     if(
        $line =~ /make\[([0-9]*)\]:.*/ ||
-#        $line =~ /.*\s\\$/ || 
-        $line =~ /^test\s\-z\s/ || 
+#       $line =~ /.*\s\\$/ ||
+        $line =~ /^test\s\-z\s/ ||
         $line =~ /^Making\sclean\sin\s\./ ||
        $line =~ /then\smv\s-f/ ||
+       $line =~ /.*make\s\s.*/ ||
         $line =~ /make\s\sall-recursive/ ||
         $line =~ /[A-z0-9-]*ar\s[A-z0-9]*\s([A-z0-9\-_\/\.]*)\s.*/ ||
         $line =~ /^[A-z0-9-]*ranlib\s[A-z0-9-_]*plugin(.*)/ ||
         $line =~ /^touch.*/ ||
         $line =~ /^srcdir=.*/ ||
-        $line =~ /^.* (lib[A-z0-9-_]*plugin.so).*/ || 
+        $line =~ /^.* (lib[A-z0-9-_]*plugin.so).*/ ||
         $line =~ s/^rm\s\-f\s(.*)//g )
      {}
-     # Info 
-     elsif( 
+     # Info
+     elsif(
           $line =~ s/^.* (lib.*\.so).*/ LINK    : $1/g ||
           $line =~ s/^.* (lib.*\.o)\s\.\/(.*)/ COMPILE : $2/g ||
           $line =~ s/^.* (lib.*\.o)\s`.*`(.*);\ \\/ COMPILE : $2/ ||
+          $line =~ s/.*\-o\s([^\s]*)\s`.*`([^\s]*);.*/ COMPILE : $2/g ||
           $line =~ s/^[A-z0-9-]*ranlib\s(.*)/ RANLIB  : $1/g ||
           $line =~ s/^Making\sall\sin\s(.*)/MAKE     : $1/g ||
-          $line =~ s/^Making\sclean\sin\s(.*)/CLEAN  : $1/g ||
-          $line =~ s/.*\-o\s([^\s]*)\s.*/ BUILD   : $1/g)
-
+          $line =~ s/^Making\sclean\sin\s(.*)/CLEAN  : $1/g  )
      {
        print $info.$line.$reset."\n";
      }
@@ -63,10 +63,9 @@ while(<STDIN>)
      {
        print $error.$line.$reset."\n";
      }
-     # Print unmatched lines 
+     # Print unmatched lines
      else
      {
        print $line."\n";
      }
-
 }
index ca73bac1c0308ba6f5e931e0eae51175ae7e9b8d..63bb0c9085a6d66fef7102255172a4f559baff38 100644 (file)
@@ -81,19 +81,17 @@ struct interaction_dialog_t
 };
 
 /**
- * Possible flags . Reusable and button types
+ * Possible flags . Dialog types
  */
-#define DIALOG_REUSABLE             0x01
-#define DIALOG_YES_NO_CANCEL        0x04
-#define DIALOG_CLEAR_NOSHOW         0x08
-#define DIALOG_GOT_ANSWER           0x10
-#define DIALOG_LOGIN_PW_OK_CANCEL   0x20
-#define DIALOG_BLOCKING_ERROR       0x24
-#define DIALOG_NONBLOCKING_ERROR    0x200
-#define DIALOG_USER_PROGRESS        0x40
-#define DIALOG_PSZ_INPUT_OK_CANCEL      0x80
+#define DIALOG_GOT_ANSWER           0x01
+#define DIALOG_YES_NO_CANCEL        0x02
+#define DIALOG_LOGIN_PW_OK_CANCEL   0x04
+#define DIALOG_PSZ_INPUT_OK_CANCEL  0x08
+#define DIALOG_BLOCKING_ERROR       0x10
+#define DIALOG_NONBLOCKING_ERROR    0x20
+#define DIALOG_WARNING              0x40
+#define DIALOG_USER_PROGRESS        0x80
 #define DIALOG_INTF_PROGRESS        0x100
-#define DIALOG_WARNING              0x400
 
 /**
  * Possible return codes
index 0a588913134069ab815f5060627bc4c71c0336b8..4a50ff64d7e04fbc27d462d1a028353ae77e3dc8 100644 (file)
@@ -559,7 +559,7 @@ aviindex:
                         _( "This AVI file is broken. Seeking will not "
                         "work correctly.\nDo you want to "
                         "try to repair it (this might take a long time) ?" ),
-                        _( "Repair" ), _( "Don't repair" ), NULL );
+                        _( "Repair" ), _( "Don't repair" ), _( "Cancel") );
             if( i_create == DIALOG_OK_YES )
             {
                 b_index = VLC_TRUE;
index dfad97e63ba0517f7705c04cf9e151240f68590e..b9c3a14d86a9d503b0ce860ff9211f1f6d35aece 100644 (file)
@@ -30,9 +30,6 @@
 
 #define AVI_DEBUG 1
 
-#define FREE( p ) \
-    if( p ) {free( p ); p = NULL; }
-
 #define __EVEN( x ) ( (x)&0x01 ? (x)+1 : (x) )
 
 static vlc_fourcc_t GetFOURCC( byte_t *p_buff )
@@ -417,11 +414,11 @@ static void AVI_ChunkFree_strf( avi_chunk_t *p_chk )
     avi_chunk_strf_t *p_strf = (avi_chunk_strf_t*)p_chk;
     if( p_strf->common.i_cat == AUDIO_ES )
     {
-        FREE( p_strf->auds.p_wf );
+        FREENULL( p_strf->auds.p_wf );
     }
     else if( p_strf->common.i_cat == VIDEO_ES )
     {
-        FREE( p_strf->vids.p_bih );
+        FREENULL( p_strf->vids.p_bih );
     }
 }
 
@@ -471,7 +468,7 @@ static void AVI_ChunkFree_idx1( avi_chunk_t *p_chk )
 {
     p_chk->idx1.i_entry_count = 0;
     p_chk->idx1.i_entry_max   = 0;
-    FREE( p_chk->idx1.entry )
+    FREENULL( p_chk->idx1.entry )
 }
 
 
@@ -556,9 +553,9 @@ static void AVI_ChunkFree_indx( avi_chunk_t *p_chk )
 {
     avi_chunk_indx_t *p_indx = (avi_chunk_indx_t*)p_chk;
 
-    FREE( p_indx->idx.std );
-    FREE( p_indx->idx.field );
-    FREE( p_indx->idx.super );
+    FREENULL( p_indx->idx.std );
+    FREENULL( p_indx->idx.field );
+    FREENULL( p_indx->idx.super );
 }
 
 
@@ -629,8 +626,8 @@ static int AVI_ChunkRead_strz( stream_t *s, avi_chunk_t *p_chk )
 static void AVI_ChunkFree_strz( avi_chunk_t *p_chk )
 {
     avi_chunk_STRING_t *p_strz = (avi_chunk_STRING_t*)p_chk;
-    FREE( p_strz->p_type );
-    FREE( p_strz->p_str );
+    FREENULL( p_strz->p_type );
+    FREENULL( p_strz->p_str );
 }
 
 static int AVI_ChunkRead_nothing( stream_t *s, avi_chunk_t *p_chk )
index e9fe3d41034b0d69d17ffbb25c6305b96389f765..bac8714a9c88e071e724e8d45959e71116aaa1c0 100644 (file)
@@ -20,6 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
 
+#include <QMessageBox>
 #include "dialogs/interaction.hpp"
 #include "util/qvlcframe.hpp"
 #include <vlc/intf.h>
@@ -29,15 +30,14 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
                          interaction_dialog_t *_p_dialog ) : QWidget( 0 ),
                           p_intf( _p_intf), p_dialog( _p_dialog )
 {
-    QVBoxLayout *layout = new QVBoxLayout;
+    QVBoxLayout *layout = new QVBoxLayout( this );
+    int i_ret = -1;
     uiLogin = NULL;
     uiProgress = NULL;
     uiInput = NULL;
 
-
     if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
     {
-
     }
     else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
     {
@@ -45,9 +45,15 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     }
     else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
     {
-        description = new QLabel( 0 );
-        description->setText( qfu(p_dialog->psz_description) );
-        layout->addWidget(description);
+        i_ret = QMessageBox::question( this,
+              qfu( p_dialog->psz_title), qfu( p_dialog->psz_description ),
+              p_dialog->psz_default_button ?
+                    qfu( p_dialog->psz_default_button ) : QString::null,
+              p_dialog->psz_alternate_button ?
+                    qfu( p_dialog->psz_alternate_button ) : QString::null,
+              p_dialog->psz_other_button ?
+                    qfu( p_dialog->psz_other_button ) : QString::null, 0,
+              p_dialog->psz_other_button ? 2 : -1 );
     }
     else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
     {
@@ -65,19 +71,30 @@ InteractionDialog::InteractionDialog( intf_thread_t *_p_intf,
     else
         msg_Err( p_intf, "unknown dialog type" );
 
-    QVLCFrame::doButtons( this, layout,
-                          defaultButton, p_dialog->psz_default_button,
-                          altButton, p_dialog->psz_alternate_button,
-                          otherButton, p_dialog->psz_other_button );
-    if( p_dialog->psz_default_button )
-        connect( defaultButton, SIGNAL( clicked() ), this, SLOT( defaultB() ) );
-    if( p_dialog->psz_alternate_button )
-        connect( altButton, SIGNAL( clicked() ), this, SLOT( altB() ) );
-    if( p_dialog->psz_other_button )
-        connect( otherButton, SIGNAL( clicked() ), this, SLOT( otherB() ) );
-    setLayout( layout );
-    setWindowTitle( qfu( p_dialog->psz_title ) );
+    /* We used a message box */
+    if( i_ret != -1 )
+    {
+        if( i_ret == 0 ) Finish( DIALOG_OK_YES );
+        else if ( i_ret == 1 ) Finish( DIALOG_NO );
+        else Finish( DIALOG_CANCELLED );
+    }
+    else
+    /* Custom box, finish it */
+    {
+        QVLCFrame::doButtons( this, layout,
+                              &defaultButton, p_dialog->psz_default_button,
+                              &altButton, p_dialog->psz_alternate_button,
+                              &otherButton, p_dialog->psz_other_button );
+        if( p_dialog->psz_default_button )
+            connect( defaultButton, SIGNAL( clicked() ),
+                     this, SLOT( defaultB() ) );
+        if( p_dialog->psz_alternate_button )
+            connect( altButton, SIGNAL( clicked() ), this, SLOT( altB() ) );
+        if( p_dialog->psz_other_button )
+            connect( otherButton, SIGNAL( clicked() ), this, SLOT( otherB() ) );
+        setLayout( layout );
+        setWindowTitle( qfu( p_dialog->psz_title ) );
+    }
 }
 
 void InteractionDialog::Update()
@@ -106,7 +123,7 @@ void InteractionDialog::otherB()
 
 void InteractionDialog::Finish( int i_ret )
 {
-    vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); 
+    vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
 
     if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
     {
@@ -123,5 +140,5 @@ void InteractionDialog::Finish( int i_ret )
     p_dialog->i_status = ANSWERED_DIALOG;
     p_dialog->i_return = i_ret;
     hide();
-    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 
+    vlc_mutex_unlock( &p_dialog->p_interaction->object_lock );
 }
index 3daff2d75a7771ec6602998381f5a6adee9a122d..c7b5af4300e0c8e4539a8ef4c7a339a8ce1bf06d 100644 (file)
@@ -57,9 +57,9 @@ public:
 #endif
     }
     static void doButtons( QWidget *w, QBoxLayout *l,
-                           QPushButton *defaul, char *psz_default,
-                           QPushButton *alt, char *psz_alt,
-                           QPushButton *other, char *psz_other )
+                           QPushButton **defaul, char *psz_default,
+                           QPushButton **alt, char *psz_alt,
+                           QPushButton **other, char *psz_other )
     {
 #ifdef QT42
 #else
@@ -70,21 +70,21 @@ public:
 
         if( psz_default )
         {
-            defaul = new QPushButton;
-            buttons_layout->addWidget( defaul );
-            defaul->setText( qfu( psz_default ) );
+            *defaul = new QPushButton(0);
+            buttons_layout->addWidget( *defaul );
+            (*defaul)->setText( qfu( psz_default ) );
         }
         if( psz_alt )
         {
-            alt = new QPushButton;
-            buttons_layout->addWidget( alt );
-            alt->setText( qfu( psz_alt ) );
+            *alt = new QPushButton(0);
+            buttons_layout->addWidget( *alt );
+            (*alt)->setText( qfu( psz_alt ) );
         }
         if( psz_other )
         {
-            other = new QPushButton;
-            buttons_layout->addWidget( other );
-            other->setText( qfu( psz_other ) );
+            *other = new QPushButton( 0 );
+            buttons_layout->addWidget( *other );
+            (*other)->setText( qfu( psz_other ) );
         }
         l->addLayout( buttons_layout );
 #endif
index 8caf481437dead7d564c6e0ef87e86c719c8915f..f446061205ca3971e8a1e712587162174862987b 100644 (file)
@@ -178,6 +178,7 @@ void InteractionDialog::Render()
         buttons_sizer->AddButton( no );
         buttons_sizer->AddButton( cancel );
     }
+#if 0
     else if( p_dialog->i_flags & DIALOG_CLEAR_NOSHOW )
     {
         wxCheckBox *noshow = new wxCheckBox( buttons_panel,
@@ -196,6 +197,7 @@ void InteractionDialog::Render()
         buttons_sizer->AddButton( close );
         buttons_sizer->SetAffirmativeButton( close );
     }
+#endif
     widgets_sizer->Layout();
     widgets_panel->SetSizerAndFit( widgets_sizer );
     buttons_sizer->Realize();
index a6b624c06a7755d4b869e5bd325612e9cdeb7296..1c5565acfcedd884c93ab1541b9d6d962e6abe7f 100644 (file)
@@ -136,13 +136,10 @@ void intf_InteractionManage( playlist_t *p_playlist )
             break;
         case HIDDEN_DIALOG:
             if( !(p_dialog->i_flags & DIALOG_GOT_ANSWER) ) break;
-            if( !(p_dialog->i_flags & DIALOG_REUSABLE) )
-            {
-                p_dialog->i_action = INTERACT_DESTROY;
-                val.p_address = p_dialog;
-                if( p_interaction->p_intf )
-                    var_Set( p_interaction->p_intf, "interaction", val );
-            }
+            p_dialog->i_action = INTERACT_DESTROY;
+            val.p_address = p_dialog;
+            if( p_interaction->p_intf )
+                var_Set( p_interaction->p_intf, "interaction", val );
             break;
         case DESTROYED_DIALOG:
             // Interface has now destroyed it, remove it
@@ -175,6 +172,7 @@ void intf_InteractionManage( playlist_t *p_playlist )
         memset( p_new, 0, sizeof( interaction_dialog_t ) );               \
         p_new->b_cancelled = VLC_FALSE;                                   \
         p_new->i_status = NEW_DIALOG;                                     \
+        p_new->i_flags = 0; \
         p_new->i_type = INTERACT_DIALOG_##type;                           \
         p_new->psz_returned[0] = NULL;                                    \
         p_new->psz_returned[1] = NULL;
@@ -196,7 +194,7 @@ int __intf_UserFatal( vlc_object_t *p_this, vlc_bool_t b_blocking,
 {
     va_list args;
     DIALOG_INIT( ONEWAY );
-    
+
     p_new->psz_title = strdup( psz_title );
     FORMAT_DESC;