Mercurial > pidgin
annotate src/request.h @ 5482:a41149ee8a29
[gaim-migrate @ 5878]
Added multiline support.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 22 May 2003 10:22:18 +0000 |
parents | e8e498255369 |
children | b7c0be69c749 |
rev | line source |
---|---|
5477 | 1 /** |
2 * @file request.h Request API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #ifndef _GAIM_REQUEST_H_ | |
24 #define _GAIM_REQUEST_H_ | |
25 | |
26 #include <stdlib.h> | |
27 #include <glib-object.h> | |
28 #include <glib.h> | |
29 | |
30 /** | |
31 * Request types. | |
32 */ | |
33 typedef enum | |
34 { | |
35 GAIM_REQUEST_INPUT = 0, /**< Text input request. */ | |
36 GAIM_REQUEST_CHOICE, /**< Multiple-choice request. */ | |
37 GAIM_REQUEST_ACTION /**< Action request. */ | |
38 | |
39 } GaimRequestType; | |
40 | |
41 /** | |
42 * Request UI operations. | |
43 */ | |
44 typedef struct | |
45 { | |
46 void *(*request_input)(const char *title, const char *primary, | |
47 const char *secondary, const char *default_value, | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
48 gboolean multiline, |
5477 | 49 const char *ok_text, GCallback ok_cb, |
50 const char *cancel_text, GCallback cancel_cb, | |
51 void *user_data); | |
52 void *(*request_choice)(const char *title, const char *primary, | |
53 const char *secondary, unsigned int default_value, | |
54 const char *ok_text, GCallback ok_cb, | |
55 const char *cancel_text, GCallback cancel_cb, | |
56 void *user_data, va_list args); | |
57 void *(*request_action)(const char *title, const char *primary, | |
58 const char *secondary, unsigned int default_action, | |
59 void *user_data, va_list actions); | |
60 | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
61 void (*close_request)(GaimRequestType type, void *ui_handle); |
5477 | 62 |
63 } GaimRequestUiOps; | |
64 | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
65 typedef void (*GaimRequestInputCb)(const char *, void *); |
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
66 |
5477 | 67 /**************************************************************************/ |
68 /** @name Request API */ | |
69 /**************************************************************************/ | |
70 /*@{*/ | |
71 | |
72 /** | |
73 * Prompts the user for text input. | |
74 * | |
75 * @param handle The plugin or connection handle. | |
76 * @param title The title of the message. | |
77 * @param primary The main point of the message. | |
78 * @param secondary The secondary information. | |
79 * @param default_value The default value. | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
80 * @param multiline TRUE if the inputted text can span multiple lines. |
5477 | 81 * @param ok_text The text for the OK button. |
82 * @param ok_cb The callback for the OK button. | |
83 * @param cancel_text The text for the cancel button. | |
84 * @param cancel_cb The callback for the cancel button. | |
85 * @param user_data The data to pass to the callback. | |
86 * | |
87 * @return A UI-specific handle. | |
88 */ | |
89 void *gaim_request_input(void *handle, const char *title, | |
90 const char *primary, const char *secondary, | |
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
91 const char *default_value, gboolean multiline, |
5477 | 92 const char *ok_text, GCallback ok_cb, |
93 const char *cancel_text, GCallback cancel_cb, | |
94 void *user_data); | |
95 | |
96 /** | |
97 * Prompts the user for multiple-choice input. | |
98 * | |
99 * @param handle The plugin or connection handle. | |
100 * @param title The title of the message. | |
101 * @param primary The main point of the message. | |
102 * @param secondary The secondary information. | |
103 * @param default_value The default value. | |
104 * @param ok_text The text for the OK button. | |
105 * @param ok_cb The callback for the OK button. | |
106 * @param cancel_text The text for the cancel button. | |
107 * @param cancel_cb The callback for the cancel button. | |
108 * @param user_data The data to pass to the callback. | |
109 * @param choice The choices. | |
110 * | |
111 * @return A UI-specific handle. | |
112 */ | |
113 void *gaim_request_choice(void *handle, const char *title, | |
114 const char *primary, const char *secondary, | |
115 unsigned int default_value, | |
116 const char *ok_text, GCallback ok_cb, | |
117 const char *cancel_text, GCallback cancel_cb, | |
118 void *user_data, | |
119 const char *choice, ...); | |
120 | |
121 /** | |
122 * Prompts the user for multiple-choice input. | |
123 * | |
124 * @param handle The plugin or connection handle. | |
125 * @param title The title of the message. | |
126 * @param primary The main point of the message. | |
127 * @param secondary The secondary information. | |
128 * @param default_value The default value. | |
129 * @param ok_text The text for the OK button. | |
130 * @param ok_cb The callback for the OK button. | |
131 * @param cancel_text The text for the cancel button. | |
132 * @param cancel_cb The callback for the cancel button. | |
133 * @param user_data The data to pass to the callback. | |
134 * @param choices The choices. | |
135 * | |
136 * @return A UI-specific handle. | |
137 */ | |
138 void *gaim_request_choice_varg(void *handle, const char *title, | |
139 const char *primary, const char *secondary, | |
140 unsigned int default_value, | |
141 const char *ok_text, GCallback ok_cb, | |
142 const char *cancel_text, GCallback cancel_cb, | |
143 void *user_data, va_list choices); | |
144 | |
145 /** | |
146 * Prompts the user for an action. | |
147 * | |
148 * This is often represented as a dialog with a button for each action. | |
149 * | |
150 * @param handle The plugin or connection handle. | |
151 * @param title The title of the message. | |
152 * @param primary The main point of the message. | |
153 * @param secondary The secondary information. | |
154 * @param default_action The default value. | |
155 * @param user_data The data to pass to the callback. | |
156 * @param action The first action. | |
157 * | |
158 * @return A UI-specific handle. | |
159 */ | |
160 void *gaim_request_action(void *handle, const char *title, | |
161 const char *primary, const char *secondary, | |
162 unsigned int default_action, | |
163 void *user_data, const char *action, ...); | |
164 | |
165 /** | |
166 * Prompts the user for an action. | |
167 * | |
168 * This is often represented as a dialog with a button for each action. | |
169 * | |
170 * @param handle The plugin or connection handle. | |
171 * @param title The title of the message. | |
172 * @param primary The main point of the message. | |
173 * @param secondary The secondary information. | |
174 * @param default_action The default value. | |
175 * @param user_data The data to pass to the callback. | |
176 * @param actions A list of actions and callbacks. | |
177 * | |
178 * @return A UI-specific handle. | |
179 */ | |
180 void *gaim_request_action_varg(void *handle, const char *title, | |
181 const char *primary, const char *secondary, | |
182 unsigned int default_action, | |
183 void *user_data, va_list actions); | |
184 | |
185 /** | |
186 * Closes a request. | |
187 * | |
188 * This should be used only by the UI operation functions and part of the | |
189 * core. | |
190 * | |
191 * @param type The request type. | |
192 * @param uihandle The request UI handle. | |
193 */ | |
194 void gaim_request_close(GaimRequestType type, void *uihandle); | |
195 | |
196 /** | |
197 * Closes all requests registered with the specified handle. | |
198 * | |
199 * @param handle The handle. | |
200 */ | |
201 void gaim_request_close_with_handle(void *handle); | |
202 | |
203 /** | |
204 * A wrapper for gaim_request_action() that uses Yes and No buttons. | |
205 */ | |
206 #define gaim_request_yes_no(handle, title, primary, secondary, \ | |
207 default_action, user_data, yes_cb, no_cb) \ | |
208 gaim_request_action((handle), (title), (primary), (secondary) \ | |
209 (default_action), (user_data), \ | |
210 _("Yes"), (yes_cb), _("No"), (no_cb), NULL) | |
211 | |
212 /** | |
213 * A wrapper for gaim_request_action() that uses OK and Cancel buttons. | |
214 */ | |
215 #define gaim_request_ok_cancel(handle, title, primary, secondary, \ | |
216 default_action, user_data, ok_cb, cancel_cb) \ | |
217 gaim_request_action((handle), (title), (primary), (secondary) \ | |
218 (default_action), (user_data), \ | |
219 _("OK"), (ok_cb), _("Cancel"), (cancel_cb), NULL) | |
220 | |
221 /*@}*/ | |
222 | |
223 /**************************************************************************/ | |
224 /** @name UI Operations API */ | |
225 /**************************************************************************/ | |
226 /*@{*/ | |
227 | |
228 /** | |
229 * Sets the UI operations structure to be used when displaying a | |
230 * request. | |
231 * | |
232 * @param ops The UI operations structure. | |
233 */ | |
234 void gaim_set_request_ui_ops(GaimRequestUiOps *ops); | |
235 | |
236 /** | |
237 * Returns the UI operations structure to be used when displaying a | |
238 * request. | |
239 * | |
240 * @param ops The UI operations structure. | |
241 */ | |
242 GaimRequestUiOps *gaim_get_request_ui_ops(void); | |
243 | |
244 /*@}*/ | |
245 | |
246 #endif /* _GAIM_REQUEST_H_ */ |