comparison src/multi.c @ 2522:108b3eab22aa

[gaim-migrate @ 2535] i didn't rewrite a good majority of your patch, sean. i changed the logic for when to hide user_frame slightly (remove the ! and flip the hide/show); had each of the generate_*_options take the vbox and create their own frame; and i think that's about it. you new i was going to do that anyway. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 17 Oct 2001 10:11:46 +0000
parents 8208e2016d9b
children 4fc6aac9da94
comparison
equal deleted inserted replaced
2521:f42fceb6a9ea 2522:108b3eab22aa
57 m = m->next; 57 m = m->next;
58 } 58 }
59 return NULL; 59 return NULL;
60 } 60 }
61 61
62 static void generate_prpl_options(struct mod_user *, GtkWidget *); 62 static void generate_protocol_options(struct mod_user *, GtkWidget *);
63 63
64 struct mod_usr_opt { 64 struct mod_usr_opt {
65 struct mod_user *user; 65 struct mod_user *user;
66 int opt; 66 int opt;
67 }; 67 };
307 gtk_widget_show(u->iconsel); 307 gtk_widget_show(u->iconsel);
308 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) { 308 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) {
309 gtk_widget_hide(u->iconsel); 309 gtk_widget_hide(u->iconsel);
310 } 310 }
311 311
312 if ((q->options & OPT_PROTO_BUDDY_ICON) || (q->options & OPT_PROTO_MAIL_CHECK))
313 gtk_widget_show(u->user_frame);
314 else
315 gtk_widget_hide(u->user_frame);
316
312 u->protocol = proto; 317 u->protocol = proto;
313 generate_prpl_options(u, u->main); 318 generate_protocol_options(u, u->main);
314 } 319 }
315 } 320 }
316 321
317 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_user *u) 322 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_user *u)
318 { 323 {
453 gtk_widget_show(reset); 458 gtk_widget_show(reset);
454 459
455 return hbox; 460 return hbox;
456 } 461 }
457 462
458 static void generate_general_options(struct mod_user *u, GtkWidget *book) 463 static void generate_login_options(struct mod_user *u, GtkWidget *box)
459 { 464 {
465 GtkWidget *frame;
460 GtkWidget *vbox; 466 GtkWidget *vbox;
461 GtkWidget *hbox; 467 GtkWidget *hbox;
462 GtkWidget *pwdbox;
463 GtkWidget *label; 468 GtkWidget *label;
464 GtkWidget *name; 469
465 GtkWidget *pass; 470 struct prpl *p;
466 GtkWidget *rempass; 471
467 GtkWidget *checkmail; 472 frame = gtk_frame_new("Login Options");
468 GtkWidget *iconsel; 473 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0);
469 474
470 vbox = gtk_vbox_new(FALSE, 5); 475 vbox = gtk_vbox_new(FALSE, 5);
471 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); 476 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
472 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new(_("General Options"))); 477 gtk_container_add(GTK_CONTAINER(frame), vbox);
473 478
474 hbox = gtk_hbox_new(FALSE, 5); 479 hbox = gtk_hbox_new(FALSE, 5);
475 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 480 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
476 481
477 label = gtk_label_new(_("Screenname:")); 482 label = gtk_label_new(_("Screenname:"));
478 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 483 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
479 484
480 name = gtk_entry_new(); 485 u->name = gtk_entry_new();
481 gtk_box_pack_start(GTK_BOX(hbox), name, TRUE, TRUE, 0); 486 gtk_box_pack_start(GTK_BOX(hbox), u->name, TRUE, TRUE, 0);
482 487
483 pwdbox = gtk_hbox_new(FALSE, 5); 488 u->pwdbox = gtk_hbox_new(FALSE, 5);
484 gtk_box_pack_start(GTK_BOX(vbox), pwdbox, FALSE, FALSE, 0); 489 gtk_box_pack_start(GTK_BOX(vbox), u->pwdbox, FALSE, FALSE, 0);
485 490
486 label = gtk_label_new(_("Password:")); 491 label = gtk_label_new(_("Password:"));
487 gtk_box_pack_start(GTK_BOX(pwdbox), label, FALSE, FALSE, 0); 492 gtk_box_pack_start(GTK_BOX(u->pwdbox), label, FALSE, FALSE, 0);
488 493
489 pass = gtk_entry_new(); 494 u->pass = gtk_entry_new();
490 gtk_box_pack_start(GTK_BOX(pwdbox), pass, TRUE, TRUE, 0); 495 gtk_box_pack_start(GTK_BOX(u->pwdbox), u->pass, TRUE, TRUE, 0);
491 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); 496 gtk_entry_set_visibility(GTK_ENTRY(u->pass), FALSE);
492 497
493 hbox = gtk_hbox_new(FALSE, 5); 498 hbox = gtk_hbox_new(FALSE, 5);
494 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 499 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
495 gtk_widget_show(hbox); 500 gtk_widget_show(hbox);
496 501
497 label = gtk_label_new(_("Protocol:")); 502 label = gtk_label_new(_("Protocol:"));
498 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 503 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
499 504
500 make_protocol_menu(hbox, u); 505 make_protocol_menu(hbox, u);
501 506
502 rempass = acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox); 507 u->rempass = acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox);
503 acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox); 508 acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox);
504 /*acct_button(_("Send KeepAlive packet (6 bytes/second)"), u, OPT_USR_KEEPALV, vbox); */ 509
505 checkmail = acct_button(_("New Mail Notifications"), u, OPT_USR_MAIL_CHECK, vbox); 510 gtk_widget_show_all(frame);
506 511
507 iconsel = build_icon_selection(u, vbox);
508
509 gtk_widget_show_all(vbox);
510
511 u->name = name;
512 u->pwdbox = pwdbox;
513 u->pass = pass;
514 u->rempass = rempass;
515 u->checkmail = checkmail;
516 u->iconsel = iconsel;
517 if (u->user) { 512 if (u->user) {
518 gtk_entry_set_text(GTK_ENTRY(name), u->user->username); 513 gtk_entry_set_text(GTK_ENTRY(u->name), u->user->username);
519 gtk_entry_set_text(GTK_ENTRY(pass), u->user->password); 514 gtk_entry_set_text(GTK_ENTRY(u->pass), u->user->password);
520 gtk_entry_set_editable(GTK_ENTRY(name), FALSE); 515 gtk_entry_set_editable(GTK_ENTRY(u->name), FALSE);
521 } 516 }
522 } 517
523 518 p = find_prpl(u->protocol);
524 static void generate_prpl_options(struct mod_user *u, GtkWidget *book) 519 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) {
520 gtk_widget_hide(u->pwdbox);
521 gtk_widget_hide(u->rempass);
522 }
523 }
524
525 static void generate_user_options(struct mod_user *u, GtkWidget *box)
526 {
527 /* This function will add the appropriate (depending on the current
528 * protocol) widgets to frame and return TRUE if there anything
529 * was added (meaning the frame should be shown)
530 * Eric will most likely change this (as he does all other submitted code)
531 * so that it will accept the vbox as an argument and create, add, and show
532 * the frame itself (like generate_protocol_options). I'd do it myself, but I'm
533 * tired and I don't care. */
534 /* Sean was right. I did do that. I told him I would. */
535
536 GtkWidget *vbox;
537
538 struct prpl *p = find_prpl(u->protocol);
539
540 u->user_frame = gtk_frame_new("User Options");
541 gtk_box_pack_start(GTK_BOX(box), u->user_frame, FALSE, FALSE, 0);
542 gtk_widget_show(u->user_frame);
543
544 vbox = gtk_vbox_new(FALSE, 5);
545 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
546 gtk_container_add(GTK_CONTAINER(u->user_frame), vbox);
547 gtk_widget_show(vbox);
548
549 u->checkmail = acct_button(_("New Mail Notifications"), u, OPT_USR_MAIL_CHECK, vbox);
550 u->iconsel = build_icon_selection(u, vbox);
551
552 if (!p) {
553 gtk_widget_hide(u->user_frame);
554 return;
555 }
556
557 if (!(p->options & OPT_PROTO_MAIL_CHECK))
558 gtk_widget_hide(u->checkmail);
559 if (!(p->options & OPT_PROTO_BUDDY_ICON))
560 gtk_widget_hide(u->iconsel);
561 }
562
563 static void generate_protocol_options(struct mod_user *u, GtkWidget *box)
525 { 564 {
526 struct prpl *p = find_prpl(u->protocol); 565 struct prpl *p = find_prpl(u->protocol);
527 566
528 GList *op, *tmp; 567 GList *op, *tmp;
529 568
532 GtkWidget *label; 571 GtkWidget *label;
533 GtkWidget *entry; 572 GtkWidget *entry;
534 573
535 char buf[256]; 574 char buf[256];
536 575
537 /* page 0 is general, keep it. page 1 is options for our 576 if (u->proto_frame)
538 * particular protocol, so clear it out and make a new one. */ 577 gtk_widget_destroy(u->proto_frame);
539 578 u->proto_frame = NULL;
540 gtk_notebook_remove_page(GTK_NOTEBOOK(book), 1);
541
542 if (!p)
543 return;
544 579
545 if (u->opt_entries) { 580 if (u->opt_entries) {
546 g_list_free(u->opt_entries); 581 g_list_free(u->opt_entries);
547 u->opt_entries = NULL; 582 u->opt_entries = NULL;
548 } 583 }
549 584
585 if (!p)
586 return;
587
550 if (!p->user_opts) 588 if (!p->user_opts)
551 return; 589 return;
552 590
553 tmp = op = (*p->user_opts)(); 591 tmp = op = (*p->user_opts)();
554 592
593 if (!op)
594 return;
595
596 g_snprintf(buf, sizeof(buf), "%s Options", (*p->name)());
597 u->proto_frame = gtk_frame_new(buf);
598 gtk_box_pack_start(GTK_BOX(box), u->proto_frame, FALSE, FALSE, 0);
599 gtk_widget_show(u->proto_frame);
600
555 vbox = gtk_vbox_new(FALSE, 5); 601 vbox = gtk_vbox_new(FALSE, 5);
556 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); 602 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
557 g_snprintf(buf, sizeof(buf), "%s Options", (*p->name)()); 603 gtk_container_add(GTK_CONTAINER(u->proto_frame), vbox);
558 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new(buf));
559 gtk_widget_show(vbox); 604 gtk_widget_show(vbox);
560 605
561 while (op) { 606 while (op) {
562 struct proto_user_opt *puo = op->data; 607 struct proto_user_opt *puo = op->data;
563 608
588 g_list_free(tmp); 633 g_list_free(tmp);
589 } 634 }
590 635
591 static void show_acct_mod(struct aim_user *a) 636 static void show_acct_mod(struct aim_user *a)
592 { 637 {
593 /* here we can have all the aim_user options, including ones not shown in the main acctedit 638 /* This is the fucking modify account dialog. I've fucking seperated it into
594 * window. this can keep the size of the acctedit window small and readable, and make this 639 * three fucking frames:
595 * one the powerful editor. this is where things like name/password are edited, but can 640 * a fucking Login Options frame, a fucking User Options frame and a fucking
596 * also have toggles (and even more complex options) like whether to autologin or whether 641 * Protcol Options frame. This fucking removes the two fucking tabs, which were
597 * to send keepalives or whatever. this would be the perfect place to specify which protocol 642 * quite fucking uneccessary. Fuck. */
598 * to use. make sure to account for the possibility of protocol plugins. */ 643 /* -- SeanEgan */
599 GtkWidget *mod;
600 GtkWidget *box;
601 GtkWidget *book;
602 GtkWidget *hbox; 644 GtkWidget *hbox;
603 GtkWidget *button; 645 GtkWidget *button;
604
605 struct prpl *p;
606 646
607 struct mod_user *u = find_mod_user(a); 647 struct mod_user *u = find_mod_user(a);
608 648
609 if (!u) { 649 if (!u) {
610 u = g_new0(struct mod_user, 1); 650 u = g_new0(struct mod_user, 1);
636 } else { 676 } else {
637 gtk_widget_show(u->mod); 677 gtk_widget_show(u->mod);
638 return; 678 return;
639 } 679 }
640 680
641 mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); 681 u->mod = gtk_window_new(GTK_WINDOW_TOPLEVEL);
642 gtk_window_set_wmclass(GTK_WINDOW(mod), "account", "Gaim"); 682 gtk_window_set_wmclass(GTK_WINDOW(u->mod), "account", "Gaim");
643 gtk_widget_realize(mod); 683 gtk_widget_realize(u->mod);
644 aol_icon(mod->window); 684 aol_icon(u->mod->window);
645 gtk_window_set_title(GTK_WINDOW(mod), _("Gaim - Modify Account")); 685 gtk_window_set_title(GTK_WINDOW(u->mod), _("Gaim - Modify Account"));
646 gtk_window_set_policy(GTK_WINDOW(mod), FALSE, TRUE, TRUE); /* nothing odd here :) */ 686 gtk_window_set_policy(GTK_WINDOW(u->mod), FALSE, TRUE, TRUE); /* nothing odd here :) */
647 gtk_signal_connect(GTK_OBJECT(mod), "destroy", GTK_SIGNAL_FUNC(delmod), u); 687 gtk_signal_connect(GTK_OBJECT(u->mod), "destroy", GTK_SIGNAL_FUNC(delmod), u);
648 688
649 box = gtk_vbox_new(FALSE, 5); 689 u->main = gtk_vbox_new(FALSE, 5);
650 gtk_container_border_width(GTK_CONTAINER(mod), 5); 690 gtk_container_border_width(GTK_CONTAINER(u->main), 5);
651 gtk_container_add(GTK_CONTAINER(mod), box); 691 gtk_container_add(GTK_CONTAINER(u->mod), u->main);
652 gtk_widget_show(box); 692 gtk_widget_show(u->main);
653 693
654 book = gtk_notebook_new(); 694 generate_login_options(u, u->main);
655 gtk_box_pack_start(GTK_BOX(box), book, FALSE, FALSE, 0); 695 generate_user_options(u, u->main);
656 gtk_widget_show(book); 696 generate_protocol_options(u, u->main);
657
658 generate_general_options(u, book);
659 generate_prpl_options(u, book);
660 697
661 hbox = gtk_hbox_new(FALSE, 5); 698 hbox = gtk_hbox_new(FALSE, 5);
662 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); 699 gtk_box_pack_end(GTK_BOX(u->main), hbox, FALSE, FALSE, 0);
663 gtk_widget_show(hbox); 700 gtk_widget_show(hbox);
664 701
665 button = picture_button(mod, _("Cancel"), cancel_xpm); 702 button = picture_button(u->mod, _("Cancel"), cancel_xpm);
666 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); 703 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
667 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_mod), u); 704 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_mod), u);
668 gtk_widget_show(button); 705 gtk_widget_show(button);
669 706
670 button = picture_button(mod, _("OK"), ok_xpm); 707 button = picture_button(u->mod, _("OK"), ok_xpm);
671 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); 708 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
672 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_mod), u); 709 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_mod), u);
673 gtk_widget_show(button); 710 gtk_widget_show(button);
674 711
675 u->mod = mod; 712 gtk_widget_show(u->mod);
676 u->main = book; /* sorry, i think i broke the joke :) */
677
678 p = find_prpl(u->protocol);
679 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) {
680 gtk_widget_hide(u->pwdbox);
681 gtk_widget_hide(u->rempass);
682 }
683 if (p && (!(p->options & OPT_PROTO_MAIL_CHECK)))
684 gtk_widget_hide(u->checkmail);
685 if (p && (!(p->options & OPT_PROTO_BUDDY_ICON)))
686 gtk_widget_hide(u->iconsel);
687
688 gtk_widget_show(mod);
689 } 713 }
690 714
691 static void add_acct(GtkWidget *w, gpointer d) 715 static void add_acct(GtkWidget *w, gpointer d)
692 { 716 {
693 show_acct_mod(NULL); 717 show_acct_mod(NULL);