Mercurial > pidgin
annotate src/request.h @ 5563:9eb5b13fd412
[gaim-migrate @ 5965]
Just a taste of what's coming.
Standard "This won't compile" thing. Plugin authors, you're going to hate
me, but that's okay, because I have friends too!
It's really late. My brain resembles that of fish swimming in jello pudding
with neon lights flying around chanting musicals. I'm not on drugs. I'm
just that tired.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 30 May 2003 09:38:29 +0000 |
| parents | cce2d7868c78 |
| children | 11001789cb22 |
| 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, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
56 void *user_data, size_t choice_count, |
|
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
57 va_list choices); |
| 5477 | 58 void *(*request_action)(const char *title, const char *primary, |
| 59 const char *secondary, unsigned int default_action, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
60 void *user_data, size_t action_count, |
|
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
61 va_list actions); |
| 5477 | 62 |
|
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
63 void (*close_request)(GaimRequestType type, void *ui_handle); |
| 5477 | 64 |
| 65 } GaimRequestUiOps; | |
| 66 | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
67 typedef void (*GaimRequestInputCb)(void *, const char *); |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
68 typedef void (*GaimRequestActionCb)(void *, int); |
|
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
69 |
| 5477 | 70 /**************************************************************************/ |
| 71 /** @name Request API */ | |
| 72 /**************************************************************************/ | |
| 73 /*@{*/ | |
| 74 | |
| 75 /** | |
| 76 * Prompts the user for text input. | |
| 77 * | |
| 78 * @param handle The plugin or connection handle. | |
| 79 * @param title The title of the message. | |
| 80 * @param primary The main point of the message. | |
| 81 * @param secondary The secondary information. | |
| 82 * @param default_value The default value. | |
|
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
83 * @param multiline TRUE if the inputted text can span multiple lines. |
| 5477 | 84 * @param ok_text The text for the OK button. |
| 85 * @param ok_cb The callback for the OK button. | |
| 86 * @param cancel_text The text for the cancel button. | |
| 87 * @param cancel_cb The callback for the cancel button. | |
| 88 * @param user_data The data to pass to the callback. | |
| 89 * | |
| 90 * @return A UI-specific handle. | |
| 91 */ | |
| 92 void *gaim_request_input(void *handle, const char *title, | |
| 93 const char *primary, const char *secondary, | |
|
5482
a41149ee8a29
[gaim-migrate @ 5878]
Christian Hammond <chipx86@chipx86.com>
parents:
5477
diff
changeset
|
94 const char *default_value, gboolean multiline, |
| 5477 | 95 const char *ok_text, GCallback ok_cb, |
| 96 const char *cancel_text, GCallback cancel_cb, | |
| 97 void *user_data); | |
| 98 | |
| 99 /** | |
| 100 * Prompts the user for multiple-choice input. | |
| 101 * | |
| 102 * @param handle The plugin or connection handle. | |
| 103 * @param title The title of the message. | |
| 104 * @param primary The main point of the message. | |
| 105 * @param secondary The secondary information. | |
| 106 * @param default_value The default value. | |
| 107 * @param ok_text The text for the OK button. | |
| 108 * @param ok_cb The callback for the OK button. | |
| 109 * @param cancel_text The text for the cancel button. | |
| 110 * @param cancel_cb The callback for the cancel button. | |
| 111 * @param user_data The data to pass to the callback. | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
112 * @param choice_count The number of choices. |
| 5477 | 113 * @param choice The choices. |
| 114 * | |
| 115 * @return A UI-specific handle. | |
| 116 */ | |
| 117 void *gaim_request_choice(void *handle, const char *title, | |
| 118 const char *primary, const char *secondary, | |
| 119 unsigned int default_value, | |
| 120 const char *ok_text, GCallback ok_cb, | |
| 121 const char *cancel_text, GCallback cancel_cb, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
122 void *user_data, size_t choice_count, ...); |
| 5477 | 123 |
| 124 /** | |
| 125 * Prompts the user for multiple-choice input. | |
| 126 * | |
| 127 * @param handle The plugin or connection handle. | |
| 128 * @param title The title of the message. | |
| 129 * @param primary The main point of the message. | |
| 130 * @param secondary The secondary information. | |
| 131 * @param default_value The default value. | |
| 132 * @param ok_text The text for the OK button. | |
| 133 * @param ok_cb The callback for the OK button. | |
| 134 * @param cancel_text The text for the cancel button. | |
| 135 * @param cancel_cb The callback for the cancel button. | |
| 136 * @param user_data The data to pass to the callback. | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
137 * @param choice_count The number of choices. |
| 5477 | 138 * @param choices The choices. |
| 139 * | |
| 140 * @return A UI-specific handle. | |
| 141 */ | |
| 142 void *gaim_request_choice_varg(void *handle, const char *title, | |
| 143 const char *primary, const char *secondary, | |
| 144 unsigned int default_value, | |
| 145 const char *ok_text, GCallback ok_cb, | |
| 146 const char *cancel_text, GCallback cancel_cb, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
147 void *user_data, size_t choice_count, |
|
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
148 va_list choices); |
| 5477 | 149 |
| 150 /** | |
| 151 * Prompts the user for an action. | |
| 152 * | |
| 153 * This is often represented as a dialog with a button for each action. | |
| 154 * | |
| 155 * @param handle The plugin or connection handle. | |
| 156 * @param title The title of the message. | |
| 157 * @param primary The main point of the message. | |
| 158 * @param secondary The secondary information. | |
| 159 * @param default_action The default value. | |
| 160 * @param user_data The data to pass to the callback. | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
161 * @param action_count The number of actions. |
| 5477 | 162 * @param action The first action. |
| 163 * | |
| 164 * @return A UI-specific handle. | |
| 165 */ | |
| 166 void *gaim_request_action(void *handle, const char *title, | |
| 167 const char *primary, const char *secondary, | |
| 168 unsigned int default_action, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
169 void *user_data, size_t action_count, ...); |
| 5477 | 170 |
| 171 /** | |
| 172 * Prompts the user for an action. | |
| 173 * | |
| 174 * This is often represented as a dialog with a button for each action. | |
| 175 * | |
| 176 * @param handle The plugin or connection handle. | |
| 177 * @param title The title of the message. | |
| 178 * @param primary The main point of the message. | |
| 179 * @param secondary The secondary information. | |
| 180 * @param default_action The default value. | |
| 181 * @param user_data The data to pass to the callback. | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
182 * @param action_count The number of actions. |
| 5477 | 183 * @param actions A list of actions and callbacks. |
| 184 * | |
| 185 * @return A UI-specific handle. | |
| 186 */ | |
| 187 void *gaim_request_action_varg(void *handle, const char *title, | |
| 188 const char *primary, const char *secondary, | |
| 189 unsigned int default_action, | |
|
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
190 void *user_data, size_t action_count, |
|
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5482
diff
changeset
|
191 va_list actions); |
| 5477 | 192 |
| 193 /** | |
| 194 * Closes a request. | |
| 195 * | |
| 196 * This should be used only by the UI operation functions and part of the | |
| 197 * core. | |
| 198 * | |
| 199 * @param type The request type. | |
| 200 * @param uihandle The request UI handle. | |
| 201 */ | |
| 202 void gaim_request_close(GaimRequestType type, void *uihandle); | |
| 203 | |
| 204 /** | |
| 205 * Closes all requests registered with the specified handle. | |
| 206 * | |
| 207 * @param handle The handle. | |
| 208 */ | |
| 209 void gaim_request_close_with_handle(void *handle); | |
| 210 | |
| 211 /** | |
| 212 * A wrapper for gaim_request_action() that uses Yes and No buttons. | |
| 213 */ | |
| 214 #define gaim_request_yes_no(handle, title, primary, secondary, \ | |
| 215 default_action, user_data, yes_cb, no_cb) \ | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
216 gaim_request_action((handle), (title), (primary), (secondary), \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
217 (default_action), (user_data), 2, \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
218 _("Yes"), (yes_cb), _("No"), (no_cb)) |
| 5477 | 219 |
| 220 /** | |
| 221 * A wrapper for gaim_request_action() that uses OK and Cancel buttons. | |
| 222 */ | |
| 223 #define gaim_request_ok_cancel(handle, title, primary, secondary, \ | |
| 224 default_action, user_data, ok_cb, cancel_cb) \ | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
225 gaim_request_action((handle), (title), (primary), (secondary), \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
226 (default_action), (user_data), 2, \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
227 _("OK"), (ok_cb), _("Cancel"), (cancel_cb)) |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
228 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
229 /** |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
230 * A wrapper for gaim_request_action() that uses Accept and Cancel buttons. |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
231 */ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
232 #define gaim_request_accept_cancel(handle, title, primary, secondary, \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
233 default_action, user_data, accept_cb, \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
234 cancel_cb) \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
235 gaim_request_action((handle), (title), (primary), (secondary), \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
236 (default_action), (user_data), 2, \ |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
237 _("Accept"), (accept_cb), _("Cancel"), (cancel_cb)) |
| 5477 | 238 |
| 239 /*@}*/ | |
| 240 | |
| 241 /**************************************************************************/ | |
| 242 /** @name UI Operations API */ | |
| 243 /**************************************************************************/ | |
| 244 /*@{*/ | |
| 245 | |
| 246 /** | |
| 247 * Sets the UI operations structure to be used when displaying a | |
| 248 * request. | |
| 249 * | |
| 250 * @param ops The UI operations structure. | |
| 251 */ | |
| 252 void gaim_set_request_ui_ops(GaimRequestUiOps *ops); | |
| 253 | |
| 254 /** | |
| 255 * Returns the UI operations structure to be used when displaying a | |
| 256 * request. | |
| 257 * | |
| 258 * @param ops The UI operations structure. | |
| 259 */ | |
| 260 GaimRequestUiOps *gaim_get_request_ui_ops(void); | |
| 261 | |
| 262 /*@}*/ | |
| 263 | |
| 264 #endif /* _GAIM_REQUEST_H_ */ |
