Commit 7224b1db authored by Clément Stenac's avatar Clément Stenac

Add support for progress bars

parent 82447676
......@@ -156,12 +156,21 @@ enum
#define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );
#define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( a,c,d, ## e )
#define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) );
#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( a,b,c,d,e)
VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
#define intf_UserYesNo( a, b, c ) __intf_UserYesNo( a,b,c )
VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*) );
#define intf_UserProgress( a, b, c, d ) __intf_UserProgress( a,b,c, d )
VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) );
#define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( a,b,c, d )
VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) );
#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));
VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) );
VLC_EXPORT( void, intf_InteractionDestroy,( interaction_t *) );
......@@ -76,6 +76,7 @@ int __aout_VolumeGet (vlc_object_t *, audio_volume_t *);
void spu_DestroySubpicture (spu_t *, subpicture_t *);
int aout_CheckChannelReorder (const uint32_t *, const uint32_t *, uint32_t, int, int *);
void stream_DemuxSend (stream_t *s, block_t *p_block);
void __intf_UserHide (vlc_object_t *, int);
int __config_LoadConfigFile (vlc_object_t *, const char *);
int vlc_asprintf (char **, const char *, ...);
int __var_Change (vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t *);
......@@ -118,6 +119,7 @@ void vout_SynchroDecode (vout_synchro_t *);
int playlist_Delete (playlist_t *, int);
void aout_FiltersPlay (aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer);
char* httpd_ClientIP (httpd_client_t *cl, char *psz_ip);
int __intf_UserProgress (vlc_object_t*, const char*, const char*, float);
void httpd_FileDelete (httpd_file_t *);
module_t * __module_Need (vlc_object_t *, const char *, const char *, vlc_bool_t);
const char * VLC_Changeset (void);
......@@ -201,6 +203,7 @@ int sout_AccessOutWrite (sout_access_out_t *, block_t *);
struct dirent * vlc_readdir_wrapper (void *);
void config_UnsetCallbacks (module_config_t *);
void vout_SynchroRelease (vout_synchro_t *);
void __intf_UserProgressUpdate (vlc_object_t*, int, const char*, float);
void __msg_Generic (vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5);
int vlc_closedir_wrapper (void *);
int playlist_ServicesDiscoveryAdd (playlist_t *, const char *);
......@@ -863,6 +866,9 @@ struct module_symbols_t
void (*__intf_UserFatal_inner) (vlc_object_t*, const char*, const char*, ...);
int (*__intf_UserLoginPassword_inner) (vlc_object_t*, const char*, const char*, char **, char **);
int (*__intf_UserYesNo_inner) (vlc_object_t*, const char*, const char*);
int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float);
void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
void (*__intf_UserHide_inner) (vlc_object_t *, int);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1280,6 +1286,9 @@ struct module_symbols_t
# define __intf_UserFatal (p_symbols)->__intf_UserFatal_inner
# define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner
# define __intf_UserYesNo (p_symbols)->__intf_UserYesNo_inner
# define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner
# define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1700,6 +1709,9 @@ struct module_symbols_t
((p_symbols)->__intf_UserFatal_inner) = __intf_UserFatal; \
((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \
((p_symbols)->__intf_UserYesNo_inner) = __intf_UserYesNo; \
((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \
((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif /* __PLUGIN__ */
......
......@@ -325,6 +325,71 @@ int __intf_UserYesNo( vlc_object_t *p_this,
return i_ret;
}
/** Helper function to make a progressbar box
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
* \param psz_status Current status
* \param f_position Current position (0.0->100.0)
* \return Dialog id, to give to UserProgressUpdate
*/
int __intf_UserProgress( vlc_object_t *p_this,
const char *psz_title,
const char *psz_status,
float f_pos )
{
int i_ret;
interaction_dialog_t *p_new = NULL;
user_widget_t *p_widget = NULL;
INTERACT_INIT( p_new );
p_new->i_type = INTERACT_DIALOG_ONEWAY;
p_new->psz_title = strdup( psz_title );
/* Progress bar */
p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) );
p_widget->i_type = WIDGET_PROGRESS;
p_widget->psz_text = strdup( psz_status );
p_widget->val.f_float = f_pos;
INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets,
p_new->i_widgets, p_widget );
i_ret = intf_Interact( p_this, p_new );
return p_new->i_id;
}
/** Update a progress bar
* \param p_this Parent vlc_object
* \param i_id Identifier of the dialog
* \param psz_status New status
* \param f_position New position (0.0->100.0)
* \return nothing
*/
void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id,
const char *psz_status, float f_pos )
{
interaction_t *p_interaction = intf_InteractionGet( p_this );
interaction_dialog_t *p_dialog;
if( !p_interaction ) return;
vlc_mutex_lock( &p_interaction->object_lock );
p_dialog = intf_InteractionGetById( p_this, i_id );
if( !p_dialog ) return;
if( p_dialog->pp_widgets[0]->psz_text )
free( p_dialog->pp_widgets[0]->psz_text );
p_dialog->pp_widgets[0]->psz_text = strdup( psz_status );
p_dialog->pp_widgets[0]->val.f_float = f_pos;
p_dialog->i_status = UPDATED_DIALOG;
vlc_mutex_unlock( &p_interaction->object_lock) ;
}
/** Helper function to ask a yes-no question
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
......@@ -382,7 +447,26 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
return i_ret;
}
/** Hide an interaction dialog
* \param p_this the parent vlc object
* \param i_id the id of the item to hide
* \return nothing
*/
void __intf_UserHide( vlc_object_t *p_this, int i_id )
{
interaction_t *p_interaction = intf_InteractionGet( p_this );
interaction_dialog_t *p_dialog;
if( !p_interaction ) return;
vlc_mutex_lock( &p_interaction->object_lock );
p_dialog = intf_InteractionGetById( p_this, i_id );
if( !p_dialog ) return;
p_dialog->i_status = ANSWERED_DIALOG;
vlc_mutex_unlock( &p_interaction->object_lock );
}
......@@ -568,7 +652,10 @@ static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog )
{
user_widget_t *p_widget = p_dialog->pp_widgets[i];
FREE( p_widget->psz_text );
if( p_widget->i_type == WIDGET_INPUT_TEXT )
{
FREE( p_widget->val.psz_string );
}
REMOVE_ELEM( p_dialog->pp_widgets, p_dialog->i_widgets, i );
free( p_widget );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment