]> git.sesse.net Git - vlc/blob - include/vlc_interaction.h
bf164c421973eb572476d9d7b3fcd0f2316ba584
[vlc] / include / vlc_interaction.h
1 /*****************************************************************************
2  * vlc_interaction.h: structures and function for user interaction
3  *****************************************************************************
4  * Copyright (C) 2005-2006 VideoLAN
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /**
25  * This structure describes an interaction widget
26  */
27 struct user_widget_t
28 {
29     int             i_type;             //< Type identifier;
30     char           *psz_text;           //< Free text
31
32     vlc_value_t     val;
33 };
34
35 /**
36  * Possible widget types
37  */
38 enum
39 {
40     WIDGET_TEXT,                        //< Text display
41     WIDGET_PROGRESS,                    //< A progress bar
42     WIDGET_INPUT_TEXT                   //< Input (backed up by a variable)
43 };
44
45 /**
46  * This structure describes a piece of interaction with the user
47  */
48 struct interaction_dialog_t
49 {
50     int             i_id;               //< Unique ID
51     int             i_type;             //< Type identifier
52     char           *psz_title;          //< Title
53     char           *psz_description;    //< Descriptor string
54
55     int             i_widgets;          //< Number of dialog widgets
56     user_widget_t **pp_widgets;         //< Dialog widgets
57
58     void *          p_private;          //< Private interface data
59
60     int             i_status;           //< Dialog status;
61     int             i_action;           //< Action to perform;
62     int             i_flags;            //< Misc flags
63     int             i_return;           //< Return status
64
65     interaction_t  *p_interaction;      //< Parent interaction object
66     vlc_object_t   *p_parent;           //< The vlc object that asked
67                                         //for interaction
68 };
69
70 /**
71  * Possible flags . Reusable and button types
72  */
73 #define DIALOG_REUSABLE      0x01
74 #define DIALOG_OK_CANCEL     0x02
75 #define DIALOG_YES_NO        0x04
76 #define DIALOG_YES_NO_CANCEL 0x04
77 #define DIALOG_CLEAR_NOSHOW  0x08
78 #define DIALOG_GOT_ANSWER    0x10
79
80 /**
81  * Possible return codes
82  */
83 enum
84 {
85     DIALOG_DEFAULT,
86     DIALOG_OK_YES,
87     DIALOG_NO,
88     DIALOG_CANCELLED
89 };
90
91 /**
92  * Possible status
93  */
94 enum
95 {
96     NEW_DIALOG,                 //< Just created
97     SENT_DIALOG,                //< Sent to interface
98     UPDATED_DIALOG,             //< Update to send
99     ANSWERED_DIALOG,            //< Got "answer"
100     HIDING_DIALOG,              //< Hiding requested
101     HIDDEN_DIALOG,              //< Now hidden. Requesting destruction
102     DESTROYED_DIALOG,           //< Interface has destroyed it
103 };
104
105 /**
106  * Possible interaction types
107  */
108 enum
109 {
110     INTERACT_PROGRESS,          //< Progress bar (in the main interface ?)
111     INTERACT_DIALOG_ONEWAY,     //< Dialog box without feedback
112     INTERACT_DIALOG_TWOWAY,     //< Dialog box with feedback
113 };
114
115 /**
116  * Predefined reusable dialogs
117  */
118 enum
119 {
120     DIALOG_FIRST,
121     DIALOG_ERRORS,
122
123     DIALOG_LAST_PREDEFINED,
124 };
125
126 /**
127  * This structure contains the active interaction dialogs, and is
128  * used by teh manager
129  */
130 struct interaction_t
131 {
132     VLC_COMMON_MEMBERS
133
134     int                         i_dialogs;      //< Number of dialogs
135     interaction_dialog_t      **pp_dialogs;     //< Dialogs
136
137     intf_thread_t              *p_intf;         //< Interface to use
138
139     int                         i_last_id;      //< Last attributed ID
140 };
141 /**
142  * Possible actions
143  */
144 enum
145 {
146     INTERACT_NEW,
147     INTERACT_UPDATE,
148     INTERACT_HIDE,
149     INTERACT_DESTROY
150 };
151
152 /***************************************************************************
153  * Exported symbols
154  ***************************************************************************/
155
156 #define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
157 VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );
158
159 #define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
160 VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) );
161 #define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
162 VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
163 #define intf_UserYesNo( a, b, c ) __intf_UserYesNo( VLC_OBJECT(a),b,c )
164 VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*) );
165
166 #define intf_UserProgress( a, b, c, d ) __intf_UserProgress( VLC_OBJECT(a),b,c, d )
167 VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) );
168
169 #define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d )
170 VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) );
171
172 #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
173 VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));
174
175 VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) );
176 VLC_EXPORT( void, intf_InteractionDestroy,( interaction_t *) );