changeset 1072:81d19577285a

[gaim-migrate @ 1082] got rid of a few FIXME's and implemented the option to hide (show) empty groups committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 06 Nov 2000 00:30:24 +0000
parents ce12622502c5
children 6b013aff4de3
files FIXME src/buddy.c src/conversation.c src/dialogs.c src/gaim.h src/oscar.c src/prefs.c
diffstat 7 files changed, 97 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/FIXME	Sun Nov 05 22:19:30 2000 +0000
+++ b/FIXME	Mon Nov 06 00:30:24 2000 +0000
@@ -1,7 +1,6 @@
 GAIM: Items to be fixed
 ------------------------
 make moving buddy list work again (adding/removing works)
-not hide empty groups (as an option)
 do Buddy Pounces on a per-connection basis
 get the permit/deny stuff put back
 have per-connection protocol options (e.g. which server to connect to for IRC)
--- a/src/buddy.c	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/buddy.c	Mon Nov 06 00:30:24 2000 +0000
@@ -142,6 +142,46 @@
 }
 
 
+void toggle_show_empty_groups() {
+	if (display_options & OPT_DISP_NO_MT_GRP) {
+		/* remove any group_shows with empty members */
+		GSList *s = shows;
+		struct group_show *g;
+
+		while (s) {
+			g = (struct group_show *)s->data;
+			if (!g_slist_length(g->members)) {
+				shows = g_slist_remove(shows, g);
+				s = shows;
+				gtk_widget_destroy(g->item);
+				g_free(g->name);
+				g_free(g);
+			} else
+				s = g_slist_next(s);
+		}
+
+	} else {
+		/* put back all groups */
+		GSList *c = connections;
+		struct gaim_connection *gc;
+		GSList *m;
+		struct group *g;
+
+		while (c) {
+			gc = (struct gaim_connection *)c->data;
+			m = gc->groups;
+			while (m) {
+				g = (struct group *)m->data;
+				m = g_slist_next(m);
+				if (!find_group_show(g->name))
+					new_group_show(g->name);
+			}
+			c = g_slist_next(c);
+		}
+		
+	}
+}
+
 static void update_num_group(struct group_show *gs) {
 	GSList *c = connections;
 	struct gaim_connection *gc;
@@ -845,6 +885,9 @@
 	
 	build_edit_tree();
 	
+	if (!(display_options & OPT_DISP_NO_MT_GRP) && !find_group_show(group))
+		new_group_show(group);
+
 	return g;
 }
 
@@ -957,7 +1000,16 @@
 
 void add_group_callback(GtkWidget *widget, void *dummy)
 {
-	show_add_group();
+	GtkCTreeNode *node;
+	GList *i;
+	struct gaim_connection *gc = NULL;
+
+	i = GTK_CLIST(edittree)->selection;
+	if (i) {
+		node = i->data;
+		gc = (struct gaim_connection *)gtk_ctree_node_get_row_data(GTK_CTREE(edittree), node);
+	}
+	show_add_group(gc);
 }
 
 static void im_callback(GtkWidget *widget, GtkTree *tree)
@@ -1404,6 +1456,7 @@
 	gtk_widget_show(g->tree);
 
 	shows = g_slist_insert(shows, g, pos);
+	update_num_groups(g);
 	return g;
 }
 
--- a/src/conversation.c	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/conversation.c	Mon Nov 06 00:30:24 2000 +0000
@@ -427,7 +427,7 @@
 	}
 	else
 	{
-        	show_add_buddy(c->gc, c->name, NULL);
+        	if (c->gc) show_add_buddy(c->gc, c->name, NULL);
 	}
 
 	gtk_widget_grab_focus(c->entry);
@@ -436,7 +436,7 @@
 
 void block_callback(GtkWidget *widget, struct conversation *c)
 {
-        show_add_perm(c->name);
+        if (c->gc) show_add_perm(c->gc, c->name);
 	gtk_widget_grab_focus(c->entry);
 }
 
--- a/src/dialogs.c	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/dialogs.c	Mon Nov 06 00:30:24 2000 +0000
@@ -100,12 +100,14 @@
         GtkWidget *window;
         GtkWidget *combo;
         GtkWidget *entry;
+	struct gaim_connection *gc;
 };
 
 struct addperm {
         GtkWidget *window;
         GSList *buttons;
         GtkWidget *entry;
+	struct gaim_connection *gc;
 };
 
 struct addbp {
@@ -569,7 +571,7 @@
 		return;
 	}
 	
-	/* FIXME: what do we want to do about this case? */
+	/* what do we want to do about this case? */
 	if (connections)
 		serv_get_info(connections->data, who);
 
@@ -788,8 +790,8 @@
 
         c = find_conversation(who);
 
-	/* FIXME */
-        add_buddy(connections->data, grp, who, NULL);
+	if (a->gc) add_buddy(a->gc, grp, who, NULL);
+	else if (connections) add_buddy(connections->data, grp, who, NULL);
 
         if (c != NULL) {
 		update_convo_add_button(c);
@@ -814,8 +816,8 @@
 
 	grp = gtk_entry_get_text(GTK_ENTRY(a->entry));
 
-	/* FIXME */
-	add_group(connections->data, grp);
+	if (a->gc) add_group(a->gc, grp);
+	else if (connections) add_group(connections->data, grp);
 
 	build_edit_tree();
 
@@ -852,7 +854,7 @@
 }
 
 
-void show_add_group()
+void show_add_group(struct gaim_connection *gc)
 {
 	GtkWidget *cancel;
 	GtkWidget *add;
@@ -863,6 +865,7 @@
 	GtkWidget *frame;
 
         struct addbuddy *a = g_new0(struct addbuddy, 1);
+	a->gc = gc;
         
         a->window = gtk_window_new(GTK_WINDOW_DIALOG);
 	gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_group", "Gaim");
@@ -937,6 +940,7 @@
 	GtkWidget *frame;
 
         struct addbuddy *a = g_new0(struct addbuddy, 1);
+	a->gc = gc;
         
         a->window = gtk_window_new(GTK_WINDOW_DIALOG);
 	gtk_window_set_wmclass(GTK_WINDOW(a->window), "add_buddy", "Gaim");
@@ -1735,11 +1739,9 @@
         }
 
         if (d) {
-		/* FIXME */
-		serv_add_deny(connections->data, name);
+		serv_add_deny(p->gc, name);
         } else {
-		/* FIXME */
-		serv_add_permit(connections->data, name);
+		serv_add_permit(p->gc, name);
         }
 
 	do_export(0, 0);
@@ -1749,7 +1751,7 @@
 
 
 
-void show_add_perm(char *who)
+void show_add_perm(struct gaim_connection *gc, char *who)
 {
 	GtkWidget *cancel;
 	GtkWidget *add;
@@ -1762,6 +1764,7 @@
 	GtkWidget *frame;
 	
 	struct addperm *p = g_new0(struct addperm, 1);
+	p->gc = gc;
 
         p->window = gtk_window_new(GTK_WINDOW_DIALOG);
 	gtk_container_set_border_width(GTK_CONTAINER(p->window), 5);
--- a/src/gaim.h	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/gaim.h	Mon Nov 06 00:30:24 2000 +0000
@@ -725,6 +725,7 @@
 /* Functions in buddy.c */
 extern void destroy_buddy();
 extern void update_button_pix();
+extern void toggle_show_empty_groups();
 extern void update_all_buddies();
 extern void update_num_groups();
 extern void show_buddy_list();
@@ -819,8 +820,8 @@
 extern void show_im_dialog();
 extern void show_info_dialog();
 extern void show_add_buddy(struct gaim_connection *, char *, char *);
-extern void show_add_group();
-extern void show_add_perm();
+extern void show_add_group(struct gaim_connection *);
+extern void show_add_perm(struct gaim_connection *, char *);
 extern void destroy_all_dialogs();
 extern void show_export_dialog();
 extern void show_import_dialog();
--- a/src/oscar.c	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/oscar.c	Mon Nov 06 00:30:24 2000 +0000
@@ -692,6 +692,7 @@
 	struct gaim_connection *gc = d->gc;
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
 	struct direct_im *dim;
+	char buf[256];
 
 	debug_printf("Accepted DirectIM.\n");
 
@@ -711,6 +712,9 @@
 	}
 
 	if (!(dim->cnv = find_conversation(d->sn))) dim->cnv = new_conversation(d->sn);
+	g_snprintf(buf, sizeof buf, _("<B>Direct IM with %s established</B>"), d->sn);
+	write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL);
+
 	gtk_signal_connect(GTK_OBJECT(dim->cnv->window), "destroy",
 			   GTK_SIGNAL_FUNC(delete_direct_im), dim);
 
@@ -1526,6 +1530,7 @@
 	struct aim_directim_priv *priv;
 	struct aim_conn_t *newconn;
 	struct direct_im *dim;
+	char buf[256];
 
 	va_start(ap, command);
 	newconn = va_arg(ap, struct aim_conn_t *);
@@ -1544,7 +1549,8 @@
 	dim->conn = newconn;
 	dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
 					oscar_callback, dim->conn);
-	/* FIXME: print to screen that this is now direct */
+	g_snprintf(buf, sizeof buf, _("<B>Direct IM with %s established</B>"), priv->sn);
+	write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL);
 
 	aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING,
 				gaim_directim_incoming, 0);
@@ -1582,6 +1588,7 @@
 	struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess);
 	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
 	struct direct_im *dim;
+	char buf[256];
 
 	va_start(ap, command);
 	conn = va_arg(ap, struct aim_conn_t *);
@@ -1595,7 +1602,9 @@
 	gdk_input_remove(dim->watcher);
 	gtk_signal_disconnect_by_data(GTK_OBJECT(dim->cnv->window), dim);
 
-	/* FIXME: need to indicate no longer direct */
+	g_snprintf(buf, sizeof buf, _("<B>Direct IM with %s closed</B>"), sn);
+	if (dim->cnv)
+		write_to_conv(dim->cnv, buf, WFLAG_SYSTEM, NULL);
 
 	aim_conn_kill(sess, &conn);
 
@@ -1629,13 +1638,18 @@
 	dim = g_new0(struct direct_im, 1);
 	dim->gc = gc;
 	g_snprintf(dim->name, sizeof dim->name, "%s", who);
-	od->direct_ims = g_slist_append(od->direct_ims, dim);
 
 	dim->conn = aim_directim_initiate(od->sess, od->conn, NULL, who);
-	dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
-					oscar_callback, dim->conn);
-	aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE,
-				gaim_directim_initiate, 0);
+	if (dim->conn != NULL) {
+		od->direct_ims = g_slist_append(od->direct_ims, dim);
+		dim->watcher = gdk_input_add(dim->conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
+						oscar_callback, dim->conn);
+		aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE,
+					gaim_directim_initiate, 0);
+	} else {
+		do_error_dialog(_("Unable to open Direct IM"), _("Error"));
+		g_free(dim);
+	}
 }
 
 static void oscar_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) {
--- a/src/prefs.c	Sun Nov 05 22:19:30 2000 +0000
+++ b/src/prefs.c	Mon Nov 06 00:30:24 2000 +0000
@@ -1696,6 +1696,9 @@
 	if (blist && ((int)option == OPT_DISP_SHOW_GRPNUM))
 		update_num_groups();
 
+	if (blist && ((int)option == OPT_DISP_NO_MT_GRP))
+		toggle_show_empty_groups();
+
 #ifdef USE_APPLET
 	update_pixmaps();
 #endif