Commit 89518a71 authored by Clément Stenac's avatar Clément Stenac

Add support for Yes/No questions (Refs:#27)

parent e8279dba
......@@ -74,7 +74,8 @@ struct interaction_dialog_t
#define DIALOG_OK_CANCEL 0x02
#define DIALOG_YES_NO 0x04
#define DIALOG_YES_NO_CANCEL 0x04
#define DIALOG_GOT_ANSWER 0x08
#define DIALOG_CLEAR_NOSHOW 0x08
#define DIALOG_GOT_ANSWER 0x10
/**
* Possible return codes
......@@ -159,6 +160,8 @@ VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );
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*) );
VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) );
VLC_EXPORT( void, intf_InteractionDestroy,( interaction_t *) );
......@@ -332,9 +332,9 @@ void intf_InteractionManage (playlist_t *);
char * mstrtime (char *psz_buffer, mtime_t date);
void aout_FormatPrepare (audio_sample_format_t * p_format);
void spu_DisplaySubpicture (spu_t *, subpicture_t *);
int intf_RunThread (intf_thread_t *);
int httpd_StreamSend (httpd_stream_t *, uint8_t *p_data, int i_data);
decoder_t * input_DecoderNew (input_thread_t *, es_format_t *, vlc_bool_t b_force_decoder);
int intf_RunThread (intf_thread_t *);
xml_t * __xml_Create (vlc_object_t *);
msg_subscription_t* __msg_Subscribe (vlc_object_t *);
const char * VLC_Version (void);
......@@ -387,6 +387,7 @@ vlm_schedule_t * vlm_ScheduleNew (vlm_t *, const char *);
int osd_ShowTextAbsolute (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t);
void net_Close (int fd);
int __vlc_threads_init (vlc_object_t *);
int __intf_UserYesNo (vlc_object_t*, const char*, const char*);
void __vout_CopyPicture (vlc_object_t *p_this, picture_t *p_dst, picture_t *p_src);
void sout_MuxDeleteStream (sout_mux_t *, sout_input_t *);
char * httpd_MsgGet (httpd_message_t *, char *psz_name);
......@@ -861,6 +862,7 @@ struct module_symbols_t
void (*intf_InteractionDestroy_inner) (interaction_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*);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -1277,6 +1279,7 @@ struct module_symbols_t
# define intf_InteractionDestroy (p_symbols)->intf_InteractionDestroy_inner
# define __intf_UserFatal (p_symbols)->__intf_UserFatal_inner
# define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner
# define __intf_UserYesNo (p_symbols)->__intf_UserYesNo_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1696,6 +1699,7 @@ struct module_symbols_t
((p_symbols)->intf_InteractionDestroy_inner) = intf_InteractionDestroy; \
((p_symbols)->__intf_UserFatal_inner) = __intf_UserFatal; \
((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \
((p_symbols)->__intf_UserYesNo_inner) = __intf_UserYesNo; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif /* __PLUGIN__ */
......
......@@ -286,6 +286,8 @@ void __intf_UserFatal( vlc_object_t *p_this,
p_new->i_widgets,
p_widget );
p_new->i_flags |= DIALOG_CLEAR_NOSHOW;
intf_Interact( p_this, p_new );
}
......@@ -295,7 +297,41 @@ void __intf_UserFatal( vlc_object_t *p_this,
* \param psz_description A description
* \param ppsz_login Returned login
* \param ppsz_password Returned password
* \return 1 if user clicked Cancel, 0 if OK
* \return Clicked button code
*/
int __intf_UserYesNo( vlc_object_t *p_this,
const char *psz_title,
const char *psz_description )
{
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_TWOWAY;
p_new->psz_title = strdup( psz_title );
/* Text */
p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) );
p_widget->i_type = WIDGET_TEXT;
p_widget->psz_text = strdup( psz_description );
p_widget->val.psz_string = NULL;
INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets,
p_new->i_widgets, p_widget );
p_new->i_flags = DIALOG_YES_NO_CANCEL;
i_ret = intf_Interact( p_this, p_new );
return i_ret;
}
/** Helper function to ask a yes-no question
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
* \param psz_description A description
* \return Clicked button code
*/
int __intf_UserLoginPassword( vlc_object_t *p_this,
const char *psz_title,
......@@ -348,6 +384,10 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
return i_ret;
}
/**********************************************************************
* The following functions are local
**********************************************************************/
......
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