changeset 1037:1c663beef29d

[gaim-migrate @ 1047] out of chaos i have established order. i must be god. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 31 Oct 2000 09:48:42 +0000
parents faa5afc2b89e
children daad2440a642
files FIXME plugins/Makefile.am src/buddy.c
diffstat 3 files changed, 65 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/FIXME	Tue Oct 31 09:17:03 2000 +0000
+++ b/FIXME	Tue Oct 31 09:48:42 2000 +0000
@@ -10,7 +10,7 @@
 	    `--Zilding
 
    Need to enforce that Buddies comes before Friends, and EWarmenhoven comes before RobFlynn.
-   See appropriate FIXME comments in buddy.c.
+   See appropriate FIXME comments in buddy.c. DONE
 
 2. Need to make it so that when the buddy list is edited the main window properly reflects that.
 
--- a/plugins/Makefile.am	Tue Oct 31 09:17:03 2000 +0000
+++ b/plugins/Makefile.am	Tue Oct 31 09:48:42 2000 +0000
@@ -1,7 +1,7 @@
-LDFLAGS += $(LDADD) $(LIBS) -ggdb -shared
+LDFLAGS += $(LDADD) $(LIBS) -shared
 SUFFIXES = .c .so
 .c.so:
-	$(CC) $(CFLAGS) -I../src -DVERSION=\"$(VERSION)\" -fPIC -DPIC -o $@ $< $(LDFLAGS) $(PLUGIN_LIBS)
+	$(CC) $(CFLAGS) -I../src -DVERSION=\"$(VERSION)\" -fPIC -o $@ $< $(LDFLAGS) $(PLUGIN_LIBS)
 
 if PLUGINS
 plugin_DATA = autorecon.so iconaway.so notify.so spellchk.so lagmeter.so
--- a/src/buddy.c	Tue Oct 31 09:17:03 2000 +0000
+++ b/src/buddy.c	Tue Oct 31 09:48:42 2000 +0000
@@ -1253,14 +1253,70 @@
 	return b;
 }
 
+static int group_number(char *group) {
+	GSList *c = connections;
+	struct gaim_connection *g;
+	GSList *m;
+	struct group *p;
+	int pos = 0;
+
+	while (c) {
+		g = (struct gaim_connection *)c->data;
+		m = g->groups;
+		while (m) {
+			p = (struct group *)m->data;
+			if (!strcmp(p->name, group))
+				return pos;
+			if (find_group_show(p->name))
+				pos++;
+			m = m->next;
+		}
+		c = c->next;
+	}
+	/* um..... we'll never get here */
+	return -1;
+}
+
+static int buddy_number(char *group, char *buddy) {
+	GSList *c = connections;
+	struct gaim_connection *g;
+	struct group *p;
+	GSList *z;
+	struct buddy *b;
+	int pos = 0;
+	char *tmp1 = g_strdup(normalize(buddy));
+	struct group_show *gs = find_group_show(group);
+
+	while (c) {
+		g = (struct gaim_connection *)c->data;
+		p = find_group(g, group);
+		z = p->members;
+		while (z) {
+			b = (struct buddy *)z->data;
+			if (!strcmp(tmp1, normalize(b->name))) {
+				g_free(tmp1);
+				return pos;
+			}
+			if (find_buddy_show(gs, b->name))
+				pos++;
+			z = z->next;
+		}
+		c = c->next;
+	}
+	/* we shouldn't ever get here */
+	debug_printf("got to bad place in buddy_number\n");
+	g_free(tmp1);
+	return -1;
+}
+
 static struct group_show *new_group_show(char *group) {
 	struct group_show *g = g_new0(struct group_show, 1);
+	int pos = group_number(group);
 
 	g->name = g_strdup(group);
 
 	g->item = gtk_tree_item_new();
-	/* FIXME */
-	gtk_tree_append(GTK_TREE(buddies), g->item);
+	gtk_tree_insert(GTK_TREE(buddies), g->item, pos);
 	gtk_signal_connect(GTK_OBJECT(g->item), "button_press_event",
 			   GTK_SIGNAL_FUNC(handle_click_group), NULL);
 	gtk_widget_show(g->item);
@@ -1275,8 +1331,7 @@
 	gtk_tree_item_expand(GTK_TREE_ITEM(g->item));
 	gtk_widget_show(g->tree);
 
-	/* FIXME */
-	shows = g_slist_append(shows, g);
+	shows = g_slist_insert(shows, g, pos);
 	return g;
 }
 
@@ -1285,13 +1340,13 @@
 	GtkWidget *box;
 	GdkPixmap *pm;
 	GdkBitmap *bm;
+	int pos = buddy_number(gs->name, buddy->name);
 
 	b->name = g_strdup(buddy->name);
 	b->show = g_strdup(buddy->show);
 
 	b->item = gtk_tree_item_new();
-	/* FIXME */
-	gtk_tree_append(GTK_TREE(gs->tree), b->item);
+	gtk_tree_insert(GTK_TREE(gs->tree), b->item, pos);
 	gtk_object_set_user_data(GTK_OBJECT(b->item), b);
 	gtk_signal_connect(GTK_OBJECT(b->item), "button_press_event",
 			   GTK_SIGNAL_FUNC(handle_click_buddy), b);
@@ -1313,8 +1368,7 @@
 	gtk_box_pack_start(GTK_BOX(box), b->label, TRUE, TRUE, 1);
 	gtk_widget_show(b->label);
 
-	/* FIXME */
-	gs->members = g_slist_append(gs->members, b);
+	gs->members = g_slist_insert(gs->members, b, pos);
 	return b;
 }