comparison src/dialogs.c @ 1030:38452403563b

[gaim-migrate @ 1040] updating the buddy list to work better with multiple connections. there are still a bunch of things fucked up with this but i wanted more people to start working on it than just me, especially since i won't be here this weekend. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 27 Oct 2000 07:53:32 +0000
parents 91b7377e7b45
children 643a4d81c18a
comparison
equal deleted inserted replaced
1029:740c6f933fe0 1030:38452403563b
775 775
776 void do_add_buddy(GtkWidget *w, struct addbuddy *a) 776 void do_add_buddy(GtkWidget *w, struct addbuddy *a)
777 { 777 {
778 char *grp, *who; 778 char *grp, *who;
779 struct conversation *c; 779 struct conversation *c;
780 GSList *n = connections;
781 struct gaim_connection *g;
780 782
781 who = gtk_entry_get_text(GTK_ENTRY(a->entry)); 783 who = gtk_entry_get_text(GTK_ENTRY(a->entry));
782 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry)); 784 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry));
783 785
784 c = find_conversation(who); 786 c = find_conversation(who);
785 787
786 add_buddy(grp, who, NULL); 788 /* FIXME */
789 add_buddy(connections->data, grp, who, NULL);
787 790
788 if (c != NULL) { 791 if (c != NULL) {
789 int dispstyle = set_dispstyle(0); 792 update_convo_add_button(c);
790 GtkWidget *parent = c->add->parent;
791 gtk_widget_destroy(c->add);
792 c->add = picture_button2(c->window, _("Remove"), gnome_remove_xpm, dispstyle);
793 gtk_signal_connect(GTK_OBJECT(c->add), "clicked", GTK_SIGNAL_FUNC(add_callback), c);
794 gtk_box_pack_end(GTK_BOX(parent), c->add, dispstyle, dispstyle, 0);
795 gtk_box_reorder_child(GTK_BOX(parent), c->add, 2);
796 gtk_widget_show(c->add);
797 } 793 }
798 794
799 build_edit_tree(); 795 build_edit_tree();
800 796
801 serv_save_config(); 797 while (n) {
802 798 g = (struct gaim_connection *)n->data;
803 serv_add_buddy(who); 799 serv_add_buddy(g, who);
800 n = n->next;
801 }
804 802
805 do_export( (GtkWidget *) NULL, 0 ); 803 do_export( (GtkWidget *) NULL, 0 );
806 804
807 update_num_groups();
808
809 destroy_dialog(NULL, a->window); 805 destroy_dialog(NULL, a->window);
810 } 806 }
811 807
812 void do_add_group(GtkWidget *w, struct addbuddy *a) 808 void do_add_group(GtkWidget *w, struct addbuddy *a)
813 { 809 {
814 char *grp; 810 char *grp;
815 811
816 grp = gtk_entry_get_text(GTK_ENTRY(a->entry)); 812 grp = gtk_entry_get_text(GTK_ENTRY(a->entry));
817 813
818 add_group(grp); 814 /* FIXME */
815 add_group(connections->data, grp);
819 816
820 build_edit_tree(); 817 build_edit_tree();
821 818
822 serv_save_config();
823
824 do_export( (GtkWidget *) NULL, 0 ); 819 do_export( (GtkWidget *) NULL, 0 );
825 820
826 update_num_groups();
827
828 destroy_dialog(NULL, a->window); 821 destroy_dialog(NULL, a->window);
829 } 822 }
830 823
831 824
832 static GList *groups_tree() 825 static GList *groups_tree(struct gaim_connection *gc)
833 { 826 {
834 GList *tmp=NULL; 827 GList *tmp=NULL;
835 char *tmp2; 828 char *tmp2;
836 struct group *g; 829 struct group *g;
837 GSList *grp = groups; 830 GSList *grp = gc->groups;
838 831
839 if (!grp) { 832 if (!grp) {
840 tmp2 = g_strdup(_("Buddies")); 833 tmp2 = g_strdup(_("Buddies"));
841 tmp = g_list_append(tmp, tmp2); 834 tmp = g_list_append(tmp, tmp2);
842 } else { 835 } else {
928 aol_icon(a->window->window); 921 aol_icon(a->window->window);
929 922
930 gtk_widget_show(a->window); 923 gtk_widget_show(a->window);
931 } 924 }
932 925
933 void show_add_buddy(char *buddy, char *group) 926 void show_add_buddy(struct gaim_connection *gc, char *buddy, char *group)
934 { 927 {
935 GtkWidget *cancel; 928 GtkWidget *cancel;
936 GtkWidget *add; 929 GtkWidget *add;
937 GtkWidget *label; 930 GtkWidget *label;
938 GtkWidget *bbox; 931 GtkWidget *bbox;
954 vbox = gtk_vbox_new(FALSE, 5); 947 vbox = gtk_vbox_new(FALSE, 5);
955 948
956 a->entry = gtk_entry_new(); 949 a->entry = gtk_entry_new();
957 a->combo = gtk_combo_new(); 950 a->combo = gtk_combo_new();
958 /* Fix the combo box */ 951 /* Fix the combo box */
959 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree()); 952 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree(gc ? gc : connections->data));
960 /* Put the buttons in the box */ 953 /* Put the buttons in the box */
961 954
962 add = picture_button(a->window, _("Add"), add_xpm); 955 add = picture_button(a->window, _("Add"), add_xpm);
963 cancel = picture_button(a->window, _("Cancel"), cancel_xpm); 956 cancel = picture_button(a->window, _("Cancel"), cancel_xpm);
964 957
1455 1448
1456 vbox = gtk_vbox_new(FALSE, 5); 1449 vbox = gtk_vbox_new(FALSE, 5);
1457 gtk_container_add(GTK_CONTAINER(frame), vbox); 1450 gtk_container_add(GTK_CONTAINER(frame), vbox);
1458 gtk_widget_show(vbox); 1451 gtk_widget_show(vbox);
1459 1452
1453 #ifndef NO_MULTI
1460 passwd_multi_menu(vbox, b); 1454 passwd_multi_menu(vbox, b);
1455 #else
1456 b->gc = connections->data;
1457 #endif
1461 1458
1462 /* First Line */ 1459 /* First Line */
1463 hbox = gtk_hbox_new(FALSE, 5); 1460 hbox = gtk_hbox_new(FALSE, 5);
1464 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); 1461 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
1465 gtk_widget_show(hbox); 1462 gtk_widget_show(hbox);
1731 } 1728 }
1732 buttons = buttons->next; 1729 buttons = buttons->next;
1733 } 1730 }
1734 1731
1735 if (d) { 1732 if (d) {
1736 GList *d = deny; 1733 /* FIXME */
1737 char *n = g_strdup(normalize(name)); 1734 serv_add_deny(connections->data, name);
1738 while (d) {
1739 if (!strcmp(n, normalize(d->data)))
1740 break;
1741 d = d->next;
1742 }
1743 g_free(n);
1744 if (!d) {
1745 deny = g_list_append(deny, name);
1746 serv_add_deny(name);
1747 }
1748 } else { 1735 } else {
1749 GList *d = permit; 1736 /* FIXME */
1750 char *n = g_strdup(normalize(name)); 1737 serv_add_permit(connections->data, name);
1751 while (d) {
1752 if (!strcmp(n, normalize(d->data)))
1753 break;
1754 d = d->next;
1755 }
1756 g_free(n);
1757 if (!d) {
1758 permit = g_list_append(permit, name);
1759 serv_add_permit(name);
1760 }
1761 } 1738 }
1762 1739
1763
1764
1765 build_permit_tree();
1766
1767 serv_save_config();
1768 do_export(0, 0); 1740 do_export(0, 0);
1769 1741
1770 destroy_dialog(NULL, p->window); 1742 destroy_dialog(NULL, p->window);
1771 } 1743 }
1772 1744
2695 2667
2696 if ( show_dialog == 1 ) { 2668 if ( show_dialog == 1 ) {
2697 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog)); 2669 file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog));
2698 strncpy( path, file, PATHSIZE - 1 ); 2670 strncpy( path, file, PATHSIZE - 1 );
2699 if ((f = fopen(path,"w"))) { 2671 if ((f = fopen(path,"w"))) {
2700 serv_build_config(buf, 8192 - 1, TRUE); 2672 toc_build_config(connections->data, buf, 8192 - 1, TRUE);
2701 fprintf(f, "%s\n", buf); 2673 fprintf(f, "%s\n", buf);
2702 fclose(f); 2674 fclose(f);
2703 chmod(buf, S_IRUSR | S_IWUSR); 2675 chmod(buf, S_IRUSR | S_IWUSR);
2704 } else { 2676 } else {
2705 g_snprintf(buf, BUF_LONG / 2, _("Error writing file %s"), file); 2677 g_snprintf(buf, BUF_LONG / 2, _("Error writing file %s"), file);
2731 g_screenname[i] = '\0'; 2703 g_screenname[i] = '\0';
2732 sprintf( path, "%s/.gaim/%s.blist", file, g_screenname); 2704 sprintf( path, "%s/.gaim/%s.blist", file, g_screenname);
2733 if ((f = fopen(path,"w"))) { 2705 if ((f = fopen(path,"w"))) {
2734 sprintf(debug_buff, "writing %s\n", path); 2706 sprintf(debug_buff, "writing %s\n", path);
2735 debug_print(debug_buff); 2707 debug_print(debug_buff);
2736 serv_build_config(buf, 8192 - 1, TRUE); 2708 toc_build_config(g, buf, 8192 - 1, TRUE);
2737 fprintf(f, "%s\n", buf); 2709 fprintf(f, "%s\n", buf);
2738 fclose(f); 2710 fclose(f);
2739 chmod(buf, S_IRUSR | S_IWUSR); 2711 chmod(buf, S_IRUSR | S_IWUSR);
2740 } else { 2712 } else {
2741 sprintf(debug_buff, "unable to write %s\n", path); 2713 sprintf(debug_buff, "unable to write %s\n", path);
2869 return; 2841 return;
2870 } 2842 }
2871 2843
2872 parse_toc_buddy_list(gc, buf, 1); 2844 parse_toc_buddy_list(gc, buf, 1);
2873 2845
2874 serv_save_config();
2875
2876 build_edit_tree(); 2846 build_edit_tree();
2877 build_permit_tree();
2878 2847
2879 fclose( f ); 2848 fclose( f );
2880 2849
2881 if ( !gc ) { 2850 if ( !gc ) {
2882 /* save what we just did to cache */ 2851 /* save what we just did to cache */
3231 static void do_alias(GtkWidget *w, gpointer n) 3200 static void do_alias(GtkWidget *w, gpointer n)
3232 { 3201 {
3233 char *name, *who; 3202 char *name, *who;
3234 struct buddy *b; 3203 struct buddy *b;
3235 name = g_strdup(gtk_entry_get_text(GTK_ENTRY(aliasentry))); 3204 name = g_strdup(gtk_entry_get_text(GTK_ENTRY(aliasentry)));
3236 if ((b = find_buddy(name)) == NULL) { 3205 /* FIXME */
3206 if ((b = find_buddy(connections->data, name)) == NULL) {
3237 g_free(name); 3207 g_free(name);
3238 destroy_dialog(aliasdlg, aliasdlg); 3208 destroy_dialog(aliasdlg, aliasdlg);
3239 return; 3209 return;
3240 } 3210 }
3241 g_snprintf(b->show, sizeof(b->show), "%s", gtk_entry_get_text(GTK_ENTRY(aliasname))); 3211 g_snprintf(b->show, sizeof(b->show), "%s", gtk_entry_get_text(GTK_ENTRY(aliasname)));
3242 do_export(0, 0); 3212 do_export(0, 0);
3243 who = g_malloc(sizeof(b->show) + 10); 3213 who = g_malloc(sizeof(b->show) + 10);
3244 strcpy(who, b->show); 3214 strcpy(who, b->show);
3245 gtk_label_set(GTK_LABEL(b->label), who); 3215 /* FIXME */
3216 /* gtk_label_set(GTK_LABEL(b->label), who); */
3246 g_free(who); 3217 g_free(who);
3247 set_buddy(b); 3218 /* set_buddy(b); */
3248 g_free(name); 3219 g_free(name);
3249 destroy_dialog(aliasdlg, aliasdlg); 3220 destroy_dialog(aliasdlg, aliasdlg);
3250 } 3221 }
3251 3222
3252 void alias_dialog(struct buddy *b) 3223 void alias_dialog(struct buddy *b)