comparison src/gtkaccount.c @ 5660:1709a545a7bd

[gaim-migrate @ 6074] The Protocol Options is back! ... sort of. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 02 Jun 2003 09:44:42 +0000
parents 060fb5fd081d
children b596002ff81e
comparison
equal deleted inserted replaced
5659:6b3214ab8632 5660:1709a545a7bd
93 GtkWidget *user_frame; 93 GtkWidget *user_frame;
94 GtkWidget *new_mail_check; 94 GtkWidget *new_mail_check;
95 GtkWidget *buddy_icon_hbox; 95 GtkWidget *buddy_icon_hbox;
96 GtkWidget *buddy_icon_entry; 96 GtkWidget *buddy_icon_entry;
97 97
98 /* Protocol Options */
99 GtkWidget *protocol_frame;
100 GtkWidget *register_check;
101
98 GtkSizeGroup *sg; 102 GtkSizeGroup *sg;
99 103
100 } AccountPrefsDialog; 104 } AccountPrefsDialog;
101 105
102 106
365 gtk_widget_hide(dialog->user_frame); 369 gtk_widget_hide(dialog->user_frame);
366 } 370 }
367 } 371 }
368 372
369 static void 373 static void
374 __add_protocol_options_frame(AccountPrefsDialog *dialog, GtkWidget *parent)
375 {
376 GaimAccountOption *option;
377 GtkWidget *frame;
378 GtkWidget *vbox;
379 GtkWidget *check;
380 GtkWidget *entry;
381 GList *l;
382 char buf[1024];
383 char *title;
384 const char *str_value;
385 gboolean bool_value;
386 int int_value;
387
388 if (dialog->protocol_frame != NULL)
389 gtk_widget_destroy(dialog->protocol_frame);
390
391 if (dialog->prpl_info == NULL ||
392 dialog->prpl_info->protocol_options == NULL) {
393
394 return;
395 }
396
397 /* Build the protocol options frame. */
398 g_snprintf(buf, sizeof(buf), _("%s Options"), dialog->plugin->info->name);
399
400 frame = gaim_gtk_make_frame(parent, _("Protocol Options"));
401 dialog->protocol_frame =
402 gtk_widget_get_parent(gtk_widget_get_parent(frame));
403
404 gtk_box_reorder_child(GTK_BOX(parent), dialog->protocol_frame, 0);
405 gtk_widget_show(dialog->protocol_frame);
406
407 /* Main vbox */
408 vbox = gtk_vbox_new(FALSE, 6);
409 gtk_container_add(GTK_CONTAINER(frame), vbox);
410 gtk_widget_show(vbox);
411
412 for (l = dialog->prpl_info->protocol_options; l != NULL; l = l->next) {
413 option = (GaimAccountOption *)l->data;
414
415 switch (gaim_account_option_get_type(option)) {
416 case GAIM_PREF_BOOLEAN:
417 bool_value = gaim_account_get_bool(dialog->account,
418 gaim_account_option_get_setting(option),
419 gaim_account_option_get_default_bool(option));
420
421 check = gtk_check_button_new_with_label(
422 gaim_account_option_get_text(option));
423
424 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
425 bool_value);
426
427 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
428 gtk_widget_show(check);
429 break;
430
431 case GAIM_PREF_INT:
432 int_value = gaim_account_get_int(dialog->account,
433 gaim_account_option_get_setting(option),
434 gaim_account_option_get_default_int(option));
435
436 g_snprintf(buf, sizeof(buf), "%d", int_value);
437
438 entry = gtk_entry_new();
439 gtk_entry_set_text(GTK_ENTRY(entry), buf);
440
441 title = g_strdup_printf("%s:",
442 gaim_account_option_get_text(option));
443
444 __add_pref_box(dialog, vbox, title, entry);
445
446 g_free(title);
447 break;
448
449 case GAIM_PREF_STRING:
450 str_value = gaim_account_get_string(dialog->account,
451 gaim_account_option_get_setting(option),
452 gaim_account_option_get_default_string(option));
453
454 entry = gtk_entry_new();
455 gtk_entry_set_text(GTK_ENTRY(entry), str_value);
456
457 title = g_strdup_printf("%s:",
458 gaim_account_option_get_text(option));
459
460 __add_pref_box(dialog, vbox, title, entry);
461
462 g_free(title);
463 break;
464
465 default:
466 break;
467 }
468 }
469
470 /* Register user */
471 if (dialog->prpl_info->register_user != NULL) {
472 dialog->register_check =
473 gtk_check_button_new_with_label(_("Register with your server"));
474
475 gtk_box_pack_start(GTK_BOX(vbox), dialog->register_check,
476 FALSE, FALSE, 0);
477 gtk_widget_show(dialog->register_check);
478 }
479 }
480
481 static void
370 __show_account_prefs(AccountPrefsDialogType type, GaimAccount *account) 482 __show_account_prefs(AccountPrefsDialogType type, GaimAccount *account)
371 { 483 {
372 AccountPrefsDialog *dialog; 484 AccountPrefsDialog *dialog;
373 GtkWidget *win; 485 GtkWidget *win;
374 GtkWidget *vbox; 486 GtkWidget *vbox;
375 GtkWidget *bbox; 487 GtkWidget *bbox;
488 GtkWidget *dbox;
376 GtkWidget *disclosure; 489 GtkWidget *disclosure;
377 GtkWidget *sep; 490 GtkWidget *sep;
378 GtkWidget *button; 491 GtkWidget *button;
379 492
380 dialog = g_new0(AccountPrefsDialog, 1); 493 dialog = g_new0(AccountPrefsDialog, 1);
421 /* Add the disclosure */ 534 /* Add the disclosure */
422 disclosure = gaim_disclosure_new(_("Show more options"), 535 disclosure = gaim_disclosure_new(_("Show more options"),
423 _("Show fewer options")); 536 _("Show fewer options"));
424 gtk_box_pack_start(GTK_BOX(vbox), disclosure, FALSE, FALSE, 0); 537 gtk_box_pack_start(GTK_BOX(vbox), disclosure, FALSE, FALSE, 0);
425 gtk_widget_show(disclosure); 538 gtk_widget_show(disclosure);
539
540 /* Setup the box that the disclosure will cover. */
541 dbox = gtk_vbox_new(FALSE, 0);
542 gtk_box_pack_start(GTK_BOX(vbox), dbox, FALSE, FALSE, 0);
543 gtk_widget_show(dbox);
544
545 gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), dbox);
546
547 /** Setup the bottom frames. */
548 __add_protocol_options_frame(dialog, dbox);
426 549
427 /* Separator... */ 550 /* Separator... */
428 sep = gtk_hseparator_new(); 551 sep = gtk_hseparator_new();
429 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); 552 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
430 gtk_widget_show(sep); 553 gtk_widget_show(sep);