comparison src/buddy.c @ 1070:b288f17c2fb2

[gaim-migrate @ 1080] numbers in groups. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 05 Nov 2000 13:22:01 +0000
parents 5d4926907b21
children 81d19577285a
comparison
equal deleted inserted replaced
1069:5d4926907b21 1070:b288f17c2fb2
90 90
91 /* stuff for actual display of buddy list */ 91 /* stuff for actual display of buddy list */
92 struct group_show { 92 struct group_show {
93 GtkWidget *item; 93 GtkWidget *item;
94 GtkWidget *label; 94 GtkWidget *label;
95 GtkWidget *count;
96 GtkWidget *tree; 95 GtkWidget *tree;
97 GSList *members; 96 GSList *members;
98 char *name; 97 char *name;
99 }; 98 };
100 static GSList *shows = NULL; 99 static GSList *shows = NULL;
140 gtk_container_add(GTK_CONTAINER(button), label); 139 gtk_container_add(GTK_CONTAINER(button), label);
141 } 140 }
142 141
143 } 142 }
144 143
144
145 static void update_num_group(struct group_show *gs) {
146 GSList *c = connections;
147 struct gaim_connection *gc;
148 struct group *g;
149 struct buddy_show *b;
150 int total = 0, on = 0;
151 char buf[256];
152
153 while (c) {
154 gc = (struct gaim_connection *)c->data;
155 g = find_group(gc, gs->name);
156 if (g) {
157 total += g_slist_length(g->members);
158 }
159 c = g_slist_next(c);
160 }
161
162 c = gs->members;
163 while (c) {
164 b = (struct buddy_show *)c->data;
165 on += g_slist_length(b->connlist);
166 c = g_slist_next(c);
167 }
168
169 if (display_options & OPT_DISP_SHOW_GRPNUM)
170 g_snprintf(buf, sizeof buf, "%s (%d/%d)", gs->name, on, total);
171 else
172 g_snprintf(buf, sizeof buf, "%s", gs->name);
173
174 gtk_label_set_text(GTK_LABEL(gs->label), buf);
175 }
176
177 void update_num_groups() {
178 GSList *s = shows;
179 struct group_show *g;
180
181 while (s) {
182 g = (struct group_show *)s->data;
183 update_num_group(g);
184 s = g_slist_next(s);
185 }
186 }
145 187
146 void update_button_pix() 188 void update_button_pix()
147 { 189 {
148 190
149 adjust_pic(addbutton, _("Add"), (gchar **)gnome_add_xpm); 191 adjust_pic(addbutton, _("Add"), (gchar **)gnome_add_xpm);
405 if (gs) { 447 if (gs) {
406 bs = find_buddy_show(gs, rem_b->name); 448 bs = find_buddy_show(gs, rem_b->name);
407 if (bs) { 449 if (bs) {
408 if (g_slist_find(bs->connlist, gc)) { 450 if (g_slist_find(bs->connlist, gc)) {
409 bs->connlist = g_slist_remove(bs->connlist, gc); 451 bs->connlist = g_slist_remove(bs->connlist, gc);
452 update_num_group(gs);
410 if (!g_slist_length(bs->connlist)) { 453 if (!g_slist_length(bs->connlist)) {
411 gs->members = g_slist_remove(gs->members, bs); 454 gs->members = g_slist_remove(gs->members, bs);
412 if (bs->log_timer > 0) 455 if (bs->log_timer > 0)
413 gtk_timeout_remove(bs->log_timer); 456 gtk_timeout_remove(bs->log_timer);
414 gtk_widget_destroy(bs->item); 457 gtk_widget_destroy(bs->item);
675 } 718 }
676 719
677 do_export( (GtkWidget *) NULL, 0 ); 720 do_export( (GtkWidget *) NULL, 0 );
678 721
679 redo_buddy_list(); 722 redo_buddy_list();
723 update_num_groups();
680 } 724 }
681 725
682 726
683 727
684 void build_edit_tree() 728 void build_edit_tree()
1399 b->idle = gtk_label_new(""); 1443 b->idle = gtk_label_new("");
1400 gtk_box_pack_start(GTK_BOX(box), b->idle, FALSE, FALSE, 1); 1444 gtk_box_pack_start(GTK_BOX(box), b->idle, FALSE, FALSE, 1);
1401 gtk_widget_show(b->idle); 1445 gtk_widget_show(b->idle);
1402 1446
1403 gs->members = g_slist_insert(gs->members, b, pos); 1447 gs->members = g_slist_insert(gs->members, b, pos);
1448 update_num_group(gs);
1404 return b; 1449 return b;
1405 } 1450 }
1406 1451
1407 static struct group_show *find_gs_by_bs(struct buddy_show *b) { 1452 static struct group_show *find_gs_by_bs(struct buddy_show *b) {
1408 GSList *m, *n; 1453 GSList *m, *n;
1622 b->present = 2; 1667 b->present = 2;
1623 if (bs->log_timer > 0) 1668 if (bs->log_timer > 0)
1624 gtk_timeout_remove(bs->log_timer); 1669 gtk_timeout_remove(bs->log_timer);
1625 if (!g_slist_find(bs->connlist, gc)) 1670 if (!g_slist_find(bs->connlist, gc))
1626 bs->connlist = g_slist_append(bs->connlist, gc); 1671 bs->connlist = g_slist_append(bs->connlist, gc);
1672 update_num_group(gs);
1627 bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs); 1673 bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
1628 if (display_options & OPT_DISP_SHOW_LOGON) { 1674 if (display_options & OPT_DISP_SHOW_LOGON) {
1629 struct conversation *c = find_conversation(b->name); 1675 struct conversation *c = find_conversation(b->name);
1630 if (c) { 1676 if (c) {
1631 char tmp[1024]; 1677 char tmp[1024];
1655 if (!gs) return; 1701 if (!gs) return;
1656 bs = find_buddy_show(gs, b->name); 1702 bs = find_buddy_show(gs, b->name);
1657 if (!bs) return; 1703 if (!bs) return;
1658 play_sound(BUDDY_LEAVE); 1704 play_sound(BUDDY_LEAVE);
1659 bs->connlist = g_slist_remove(bs->connlist, gc); 1705 bs->connlist = g_slist_remove(bs->connlist, gc);
1706 update_num_group(gs);
1660 if (bs->log_timer > 0) 1707 if (bs->log_timer > 0)
1661 gtk_timeout_remove(bs->log_timer); 1708 gtk_timeout_remove(bs->log_timer);
1662 bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs); 1709 bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
1663 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, logout_icon_xpm); 1710 pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, logout_icon_xpm);
1664 gtk_widget_hide(bs->pix); 1711 gtk_widget_hide(bs->pix);