console/gntrequest.c

changeset 14124
181ebb961493
parent 14121
3d8804b82150
child 14125
2a14281b124b
equal deleted inserted replaced
14123:7ae9b90ecf6f 14124:181ebb961493
276 gaim_request_field_list_set_selected(field, list); 276 gaim_request_field_list_set_selected(field, list);
277 g_list_free(list); 277 g_list_free(list);
278 } 278 }
279 else if (type == GAIM_REQUEST_FIELD_ACCOUNT) 279 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
280 { 280 {
281 GntWidget *combo = field->ui_data;
282 GaimAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
283 gaim_request_field_account_set_value(field, acc);
281 } 284 }
282 } 285 }
283 } 286 }
284 287
285 if (callback) 288 if (callback)
291 gaim_request_close(GAIM_REQUEST_FIELDS, button); 294 gaim_request_close(GAIM_REQUEST_FIELDS, button);
292 } 295 }
293 296
294 static void * 297 static void *
295 gg_request_fields(const char *title, const char *primary, 298 gg_request_fields(const char *title, const char *primary,
296 const char *secondary, GaimRequestFields *fields, 299 const char *secondary, GaimRequestFields *allfields,
297 const char *ok, GCallback ok_cb, 300 const char *ok, GCallback ok_cb,
298 const char *cancel, GCallback cancel_cb, 301 const char *cancel, GCallback cancel_cb,
299 void *userdata) 302 void *userdata)
300 { 303 {
301 GntWidget *window, *box; 304 GntWidget *window, *box;
302 GList *list; 305 GList *grlist;
303 306
304 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS); 307 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS);
305 308
306 /* This is how it's going to work: the request-groups are going to be 309 /* This is how it's going to work: the request-groups are going to be
307 * stacked vertically one after the other. A GntLine will be separating 310 * stacked vertically one after the other. A GntLine will be separating
308 * the groups. */ 311 * the groups. */
309 box = gnt_vbox_new(FALSE); 312 box = gnt_vbox_new(FALSE);
310 gnt_box_set_pad(GNT_BOX(box), 0); 313 gnt_box_set_pad(GNT_BOX(box), 0);
311 gnt_box_set_fill(GNT_BOX(box), TRUE); 314 gnt_box_set_fill(GNT_BOX(box), TRUE);
312 for (list = gaim_request_fields_get_groups(fields); list; list = list->next) 315 for (grlist = gaim_request_fields_get_groups(allfields); grlist; grlist = grlist->next)
313 { 316 {
314 GaimRequestFieldGroup *group = list->data; 317 GaimRequestFieldGroup *group = grlist->data;
315 GList *fields = gaim_request_field_group_get_fields(group); 318 GList *fields = gaim_request_field_group_get_fields(group);
316 GntWidget *hbox; 319 GntWidget *hbox;
317 320 const char *title = gaim_request_field_group_get_title(group);
318 gnt_box_add_widget(GNT_BOX(box), 321
319 gnt_label_new_with_format(gaim_request_field_group_get_title(group), 322 if (title)
320 GNT_TEXT_FLAG_BOLD)); 323 gnt_box_add_widget(GNT_BOX(box),
324 gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD));
321 325
322 for (; fields ; fields = fields->next) 326 for (; fields ; fields = fields->next)
323 { 327 {
328 /* XXX: Break each of the fields into a separate function? */
324 GaimRequestField *field = fields->data; 329 GaimRequestField *field = fields->data;
325 GaimRequestFieldType type = gaim_request_field_get_type(field); 330 GaimRequestFieldType type = gaim_request_field_get_type(field);
326 const char *label = gaim_request_field_get_label(field); 331 const char *label = gaim_request_field_get_label(field);
327 332
328 hbox = gnt_hbox_new(FALSE); 333 hbox = gnt_hbox_new(TRUE); /* hrm */
329 gnt_box_set_pad(GNT_BOX(hbox), 0);
330 gnt_box_add_widget(GNT_BOX(box), hbox); 334 gnt_box_add_widget(GNT_BOX(box), hbox);
331 335
332 if (type != GAIM_REQUEST_FIELD_BOOLEAN) 336 if (type != GAIM_REQUEST_FIELD_BOOLEAN && label)
333 { 337 {
334 GntWidget *l = gnt_label_new(label); 338 GntWidget *l = gnt_label_new(label);
335 gnt_widget_set_size(l, 0, 1); 339 gnt_widget_set_size(l, 0, 1);
336 gnt_box_add_widget(GNT_BOX(hbox), l); 340 gnt_box_add_widget(GNT_BOX(hbox), l);
337 } 341 }
415 if (gaim_request_field_list_is_selected(field, text)) 419 if (gaim_request_field_list_is_selected(field, text))
416 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key); 420 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key);
417 } 421 }
418 } 422 }
419 } 423 }
420 #if 0
421 else if (type == GAIM_REQUEST_FIELD_ACCOUNT) 424 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
422 { 425 {
423 /* XXX: remember to set the field->ui_data */ 426 gboolean all;
424 } 427 GaimAccount *def;
425 #endif 428 GList *list;
429 GntWidget *combo = gnt_combo_box_new();
430 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
431 gnt_box_add_widget(GNT_BOX(hbox), combo);
432 field->ui_data = combo;
433
434 all = gaim_request_field_account_get_show_all(field);
435 def = gaim_request_field_account_get_default_value(field);
436
437 if (all)
438 list = gaim_accounts_get_all();
439 else
440 list = gaim_connections_get_all();
441
442 for (; list; list = list->next)
443 {
444 GaimAccount *account;
445 char *text;
446
447 if (all)
448 account = list->data;
449 else
450 account = gaim_connection_get_account(list->data);
451
452 text = g_strdup_printf("%s (%s)",
453 gaim_account_get_username(account),
454 gaim_account_get_protocol_name(account));
455 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
456 g_free(text);
457 if (account == def)
458 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
459 }
460 gnt_widget_set_size(combo, 20, 3); /* ew */
461 }
426 else 462 else
427 { 463 {
428 gnt_box_add_widget(GNT_BOX(hbox), 464 gnt_box_add_widget(GNT_BOX(hbox),
429 gnt_label_new_with_format(_("Not implemented yet."), 465 gnt_label_new_with_format(_("Not implemented yet."),
430 GNT_TEXT_FLAG_BOLD)); 466 GNT_TEXT_FLAG_BOLD));
431 } 467 }
432 } 468 }
433 if (list->next) 469 if (grlist->next)
434 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new()); 470 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
435 } 471 }
436 gnt_box_add_widget(GNT_BOX(window), box); 472 gnt_box_add_widget(GNT_BOX(window), box);
437 473
438 box = setup_button_box(userdata, request_fields_cb, fields, 474 box = setup_button_box(userdata, request_fields_cb, allfields,
439 ok, ok_cb, cancel, cancel_cb, NULL); 475 ok, ok_cb, cancel, cancel_cb, NULL);
440 gnt_box_add_widget(GNT_BOX(window), box); 476 gnt_box_add_widget(GNT_BOX(window), box);
441 477
442 gnt_widget_show(window); 478 gnt_widget_show(window);
443 479

mercurial