Mercurial > pidgin.yaz
comparison src/gtkrequest.c @ 5496:b7c0be69c749
[gaim-migrate @ 5892]
do_ask_dialog() will soon go the way of the something that goes away a lot.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 23 May 2003 00:48:20 +0000 |
parents | 421020171808 |
children | cce2d7868c78 |
comparison
equal
deleted
inserted
replaced
5495:5b678994929b | 5496:b7c0be69c749 |
---|---|
75 ((GaimRequestInputCb)data->cbs[id])(value, data->user_data); | 75 ((GaimRequestInputCb)data->cbs[id])(value, data->user_data); |
76 | 76 |
77 gaim_request_close(GAIM_REQUEST_INPUT, data); | 77 gaim_request_close(GAIM_REQUEST_INPUT, data); |
78 } | 78 } |
79 | 79 |
80 static void | |
81 __action_response_cb(GtkDialog *dialog, gint id, GaimRequestData *data) | |
82 { | |
83 if (id < data->cb_count && data->cbs[id] != NULL) | |
84 ((GaimRequestActionCb)data->cbs[id])(id, data->user_data); | |
85 | |
86 gaim_request_close(GAIM_REQUEST_INPUT, data); | |
87 } | |
88 | |
80 #define STOCK_ITEMIZE(r, l) \ | 89 #define STOCK_ITEMIZE(r, l) \ |
81 if (!strcmp((r), text)) \ | 90 if (!strcmp((r), text)) \ |
82 return (l); | 91 return (l); |
83 | 92 |
84 static const char * | 93 static const char * |
122 data->cbs = g_new0(GCallback, 2); | 131 data->cbs = g_new0(GCallback, 2); |
123 | 132 |
124 data->cbs[0] = ok_cb; | 133 data->cbs[0] = ok_cb; |
125 data->cbs[1] = cancel_cb; | 134 data->cbs[1] = cancel_cb; |
126 | 135 |
127 #if 0 | |
128 data->dialog = dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
129 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG); | |
130 gtk_window_set_role(GTK_WINDOW(dialog), "input"); | |
131 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
132 #endif | |
133 | |
134 /* Create the dialog. */ | 136 /* Create the dialog. */ |
135 dialog = gtk_dialog_new_with_buttons("", NULL, 0, | 137 dialog = gtk_dialog_new_with_buttons("", NULL, 0, |
136 __text_to_stock(cancel_text), 1, | 138 __text_to_stock(cancel_text), 1, |
137 __text_to_stock(ok_text), 0, | 139 __text_to_stock(ok_text), 0, |
138 NULL); | 140 NULL); |
225 void * | 227 void * |
226 gaim_gtk_request_choice(const char *title, const char *primary, | 228 gaim_gtk_request_choice(const char *title, const char *primary, |
227 const char *secondary, unsigned int default_value, | 229 const char *secondary, unsigned int default_value, |
228 const char *ok_text, GCallback ok_cb, | 230 const char *ok_text, GCallback ok_cb, |
229 const char *cancel_text, GCallback cancel_cb, | 231 const char *cancel_text, GCallback cancel_cb, |
230 void *user_data, va_list args) | 232 void *user_data, size_t choice_count, va_list args) |
231 { | 233 { |
232 return NULL; | 234 return NULL; |
233 } | 235 } |
234 | 236 |
235 void * | 237 void * |
236 gaim_gtk_request_action(const char *title, const char *primary, | 238 gaim_gtk_request_action(const char *title, const char *primary, |
237 const char *secondary, unsigned int default_action, | 239 const char *secondary, unsigned int default_action, |
238 void *user_data, va_list actions) | 240 void *user_data, size_t action_count, va_list actions) |
239 { | 241 { |
240 return NULL; | 242 GaimRequestData *data; |
243 GtkWidget *dialog; | |
244 GtkWidget *vbox; | |
245 GtkWidget *hbox; | |
246 GtkWidget *label; | |
247 GtkWidget *img; | |
248 void **buttons; | |
249 char *label_text; | |
250 int i; | |
251 | |
252 data = g_new0(GaimRequestData, 1); | |
253 data->type = GAIM_REQUEST_ACTION; | |
254 data->user_data = user_data; | |
255 | |
256 data->cb_count = action_count; | |
257 data->cbs = g_new0(GCallback, action_count); | |
258 | |
259 /* Reverse the buttons */ | |
260 buttons = g_new0(void *, action_count * 2); | |
261 | |
262 for (i = 0; i < action_count * 2; i += 2) { | |
263 buttons[(action_count * 2) - i - 2] = va_arg(actions, char *); | |
264 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback); | |
265 } | |
266 | |
267 /* Create the dialog. */ | |
268 data->dialog = dialog = gtk_dialog_new(); | |
269 | |
270 for (i = 0; i < action_count; i++) { | |
271 gaim_debug(GAIM_DEBUG_MISC, "gtkrequest", | |
272 "buttons[2 * %d] = '%s'\n", | |
273 i, buttons[2 * i]); | |
274 gtk_dialog_add_button(GTK_DIALOG(dialog), | |
275 __text_to_stock(buttons[2 * i]), i); | |
276 | |
277 data->cbs[i] = buttons[2 * i + 1]; | |
278 } | |
279 | |
280 g_free(buttons); | |
281 | |
282 g_signal_connect(G_OBJECT(dialog), "response", | |
283 G_CALLBACK(__action_response_cb), data); | |
284 | |
285 /* Setup the dialog */ | |
286 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
287 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
288 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
289 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); | |
290 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); | |
291 | |
292 /* Setup the main horizontal box */ | |
293 hbox = gtk_hbox_new(FALSE, 12); | |
294 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
295 | |
296 /* Dialog icon. */ | |
297 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
298 GTK_ICON_SIZE_DIALOG); | |
299 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
300 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
301 | |
302 /* Vertical box */ | |
303 vbox = gtk_vbox_new(FALSE, 12); | |
304 | |
305 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
306 | |
307 /* Descriptive label */ | |
308 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">" | |
309 "%s</span>\n\n%s", | |
310 primary, (secondary ? secondary : "")); | |
311 | |
312 label = gtk_label_new(NULL); | |
313 | |
314 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
315 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
316 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
317 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
318 | |
319 g_free(label_text); | |
320 | |
321 /* Show everything. */ | |
322 gtk_widget_show_all(dialog); | |
323 | |
324 return data; | |
241 } | 325 } |
242 | 326 |
243 void | 327 void |
244 gaim_gtk_close_request(GaimRequestType type, void *ui_handle) | 328 gaim_gtk_close_request(GaimRequestType type, void *ui_handle) |
245 { | 329 { |