]> git.sesse.net Git - vlc/commitdiff
Improve dialogs handling
authorClément Stenac <zorglub@videolan.org>
Wed, 7 Dec 2005 09:31:36 +0000 (09:31 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 7 Dec 2005 09:31:36 +0000 (09:31 +0000)
include/vlc_interaction.h
modules/gui/wxwidgets/interface.cpp
src/interface/interaction.c

index 208239bfac6d04358773d0cd56d2d2097ea00da0..2efa7bc05455002636b5d21d850576acae19f03b 100644 (file)
@@ -56,12 +56,23 @@ struct interaction_dialog_t
     int             i_widgets;          //< Nu,ber of dialog widgets
     user_widget_t **pp_widgets;         //< Dialog widgets
 
-    vlc_bool_t      b_have_answer;      //< Has an answer been given ?
     vlc_bool_t      b_reusable;         //< Do we have to reuse this ?
-    vlc_bool_t      b_updated;          //< Update for this one ?
-    vlc_bool_t      b_finished;         //< Hidden by interface
 
     void *          p_private;          //< Private interface data
+    int             i_status;           //< Dialog status;
+};
+
+/**
+ * Possible status
+ */
+enum
+{
+    NEW_DIALOG,
+    SENT_DIALOG,
+    UPDATED_DIALOG,
+    ANSWERED_DIALOG,
+    HIDING_DIALOG,
+    HIDDEN_DIALOG,
 };
 
 /**
@@ -81,6 +92,7 @@ enum
  */
 enum
 {
+    DIALOG_FIRST,
     DIALOG_NOACCESS,
     DIALOG_NOCODEC,
     DIALOG_NOAUDIO,
index 5f1d799913a29da816a3e81b46fe4f185fc2e08e..6c29628c5c2b7f0b121b53e7b2658926d292c141 100644 (file)
 #include "../../../share/vlc16x16.xpm"
 #endif
 
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int DoInteract( intf_thread_t *, interaction_dialog_t *, int );
+
 /*****************************************************************************
  * Local class declarations.
  *****************************************************************************/
@@ -335,6 +340,8 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     extra_frame = 0;
     playlist_manager = 0;
 
+    p_intf->pf_interact = DoInteract;
+
     /* Give our interface a nice little icon */
     SetIcon( wxIcon( vlc_xpm ) );
 
@@ -1155,6 +1162,14 @@ void Interface::TogglePlayButton( int i_playing_status )
     GetToolBar()->ToggleTool( PlayStream_Event, false );
 }
 
+static int DoInteract( intf_thread_t *, interaction_dialog_t *, int )
+{
+    fprintf( stderr, "Doing interaction \n" );
+}
+
+
+
+
 #if wxUSE_DRAG_AND_DROP
 /*****************************************************************************
  * Definition of DragAndDrop class.
index 5103c86617a20187e37b423f8b4fcba8c10d9979..fd5a2f49c977f77cc1b260bc71b1ea89201431a8 100644 (file)
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static void                 intf_InteractionInit( playlist_t *p_playlist );
+static void                  intf_InteractionInit( playlist_t *p_playlist );
 static interaction_t *       intf_InteractionGet( vlc_object_t *p_this );
-static void                 intf_InteractionSearchInterface( interaction_t *
-                                                             p_interaction );
-static int                  intf_WaitAnswer( interaction_t *p_interact,
-                                             interaction_dialog_t *p_dialog );
-static int                  intf_Send( interaction_t *p_interact,
-                                       interaction_dialog_t *p_dialog );
+static void                  intf_InteractionSearchInterface( interaction_t *
+                                                          p_interaction );
+static int                   intf_WaitAnswer( interaction_t *p_interact,
+                             interaction_dialog_t *p_dialog );
+static int                   intf_Send( interaction_t *p_interact,
+                             interaction_dialog_t *p_dialog );
 static interaction_dialog_t *intf_InteractionGetById( vlc_object_t* , int );
 
 /**
@@ -82,7 +82,7 @@ int  __intf_Interact( vlc_object_t *p_this, interaction_dialog_t *
     }
 }
 
-/** 
+/**
  * Destroy the interaction system
  */
 void intf_InteractionDestroy( interaction_t *p_interaction )
@@ -90,10 +90,10 @@ void intf_InteractionDestroy( interaction_t *p_interaction )
     /// \todo Code this, and call it
 }
 
-/** 
+/**
  * The main interaction processing loop
  * This function is called from the playlist loop
- * 
+ *
  * \param p_playlist the parent playlist
  * \return nothing
  */
@@ -125,32 +125,41 @@ void intf_InteractionManage( playlist_t *p_playlist )
     {
         interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index];
 
-        if( p_dialog->b_have_answer )
+        switch( p_dialog->i_status )
         {
+        case ANSWERED_DIALOG:
             /// \todo Signal we have an answer
             // - If have answer, signal what is waiting
             // (vlc_cond ? dangerous in case of pb ?)
 
             // Ask interface to hide it
+            msg_Dbg( p_interaction, "Hiding dialog %i", p_dialog->i_id );
             p_interaction->p_intf->pf_interact( p_interaction->p_intf,
                                                 p_dialog, INTERACT_HIDE );
-
-        }
-
-        if( p_dialog->b_updated )
-        {
-            p_dialog->b_finished = VLC_FALSE;
+            p_dialog->i_status = HIDING_DIALOG;
+            break;
+        case UPDATED_DIALOG:
             p_interaction->p_intf->pf_interact( p_interaction->p_intf,
                                                 p_dialog, INTERACT_UPDATE );
+            p_dialog->i_status = SENT_DIALOG;
+            msg_Dbg( p_interaction, "Updating dialog %i, %i widgets",
+                                    p_dialog->i_id, p_dialog->i_widgets );
+            break;
+        case HIDDEN_DIALOG:
+            if( !p_dialog->b_reusable )
+            {
+                /// \todo Destroy the dialog
+            }
+            break;
+        case NEW_DIALOG:
+            // This is truly a new dialog, send it.
+            p_interaction->p_intf->pf_interact( p_interaction->p_intf,
+                                                p_dialog, INTERACT_NEW );
+            msg_Dbg( p_interaction, "Creating dialog %i, %i widgets",
+                                        p_dialog->i_id, p_dialog->i_widgets );
+            p_dialog->i_status = SENT_DIALOG;
+            break;
         }
-
-        if( p_dialog->b_finished && !p_dialog->b_reusable )
-        {
-            /// \todo Destroy the dialog
-        }
-        // This is truly a new dialog, send it.
-        p_interaction->p_intf->pf_interact( p_interaction->p_intf,
-                                            p_dialog, INTERACT_NEW );
     }
 
     vlc_object_release( p_interaction->p_intf );
@@ -167,7 +176,8 @@ void intf_InteractionManage( playlist_t *p_playlist )
         new->pp_widgets = NULL;                                         \
         new->psz_title = NULL;                                          \
         new->psz_description = NULL;                                    \
-        new->i_id = 0;
+        new->i_id = 0;                                                  \
+        new->i_status = NEW_DIALOG;
 
 #define INTERACT_FREE( new )                                            \
         if( new->psz_title ) free( new->psz_title );                    \
@@ -194,6 +204,11 @@ void __intf_UserFatal( vlc_object_t *p_this, int i_id,
     if( !p_new )
     {
         INTERACT_INIT( p_new );
+        if( i_id > 0 ) p_new->i_id = i_id ;
+    }
+    else
+    {
+        p_new->i_status = UPDATED_DIALOG;
     }
 
     p_new->i_type = INTERACT_FATAL;
@@ -216,7 +231,7 @@ void __intf_UserFatal( vlc_object_t *p_this, int i_id,
 }
 
 #if 0
-/** Helper function to build a progress bar 
+/** Helper function to build a progress bar
  * \param p_this   Parent vlc object
  */
 interaction_dialog_t *__intf_ProgressBuild( vlc_object_t *p_this,