changeset 1032:643a4d81c18a

[gaim-migrate @ 1042] buddy list menus are based on connections/protocol. pretty spiffy. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 31 Oct 2000 06:09:47 +0000
parents 6df117f1674d
children 099748ff3a0a
files src/aim.c src/buddy.c src/conversation.c src/dialogs.c src/gaim.h src/oscar.c src/prpl.h src/rvous.c src/server.c src/toc.c
diffstat 10 files changed, 116 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/src/aim.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/aim.c	Tue Oct 31 06:09:47 2000 +0000
@@ -437,7 +437,6 @@
 int main(int argc, char *argv[])
 {
 	char opt;
-	int i;
 	int opt_acct = 0, opt_help = 0, opt_version = 0,
 	    opt_user = 0, opt_login = 0, do_login_ret = -1;
 	char *opt_user_arg = NULL, *opt_login_arg = NULL;
--- a/src/buddy.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/buddy.c	Tue Oct 31 06:09:47 2000 +0000
@@ -250,29 +250,12 @@
 	}
 }
 
-void pressed_info(GtkWidget *widget, struct buddy_show *b)
-{
-        serv_get_info(b->name);
-}
-
 void pressed_alias(GtkWidget *widget, struct buddy_show *b)
 {
 	struct buddy *m = find_buddy(connections->data, b->name);
 	alias_dialog(m);
 }
 
-void pressed_dir_info(GtkWidget *widget, struct buddy_show *b)
-{
-        serv_get_dir(b->name);
-
-}
-
-void pressed_away_msg(GtkWidget *widget, struct buddy_show *b)
-{
-        serv_get_away_msg(b->name);
-
-}
-
 void handle_click_buddy(GtkWidget *widget, GdkEventButton *event, struct buddy_show *b)
 {
         if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
@@ -286,10 +269,12 @@
                         c = new_conversation(b->name);
                 }
 	} else if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
-		/* FIXME: first, create a menu of each signed on name. then for each of those,
-		 * make a submenu based on which protocol is being used. this will help clarify
-		 * a lot of the UI and connection issues */
-                GtkWidget *menu, *button;
+		GtkWidget *menu;
+		GtkWidget *button;
+		GtkWidget *menuitem;
+		GtkWidget *conmenu;
+		GSList *cn = b->connlist;
+		struct gaim_connection *g;
 		/* We're gonna make us a menu right here */
 
 		menu = gtk_menu_new();
@@ -300,43 +285,43 @@
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
-		button = gtk_menu_item_new_with_label(_("Info"));
-		gtk_signal_connect(GTK_OBJECT(button), "activate",
-				   GTK_SIGNAL_FUNC(pressed_info), b);
-		gtk_menu_append(GTK_MENU(menu), button);
-		gtk_widget_show(button);
-
 		button = gtk_menu_item_new_with_label(_("Alias"));
 		gtk_signal_connect(GTK_OBJECT(button), "activate",
 				   GTK_SIGNAL_FUNC(pressed_alias), b);
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
-		button = gtk_menu_item_new_with_label(_("Dir Info"));
-		gtk_signal_connect(GTK_OBJECT(button), "activate",
-				   GTK_SIGNAL_FUNC(pressed_dir_info), b);
-		gtk_menu_append(GTK_MENU(menu), button);
-		gtk_widget_show(button);
-
-		button = gtk_menu_item_new_with_label(_("Away Msg"));
-		gtk_signal_connect(GTK_OBJECT(button), "activate",
-				   GTK_SIGNAL_FUNC(pressed_away_msg), b);
-		gtk_menu_append(GTK_MENU(menu), button);
-		gtk_widget_show(button);
-
-		button = gtk_menu_item_new_with_label(_("Toggle Logging"));
-		gtk_signal_connect(GTK_OBJECT(button), "activate",
-				   GTK_SIGNAL_FUNC(log_callback), b->name);
-		gtk_menu_append(GTK_MENU(menu), button);
-		gtk_widget_show(button);
-
+		/* FIXME: for now, we're not going to do buddy pounces from the menu,
+		 * since the person is already online. when we do per-connection pounces,
+		 * then this'll come back
 		button = gtk_menu_item_new_with_label(_("Add Buddy Pounce"));
 		gtk_signal_connect(GTK_OBJECT(button), "activate",
 				   GTK_SIGNAL_FUNC(new_bp_callback), b->name);
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
+		*/
 
-                
+		if (g_slist_length(cn) > 1) {
+			while (cn) {
+				g = (struct gaim_connection *)cn->data;
+				if (g->prpl->action_menu) {
+					menuitem = gtk_menu_item_new_with_label(g->username);
+					gtk_menu_append(GTK_MENU(menu), menuitem);
+					gtk_widget_show(menuitem);
+					
+					conmenu = gtk_menu_new();
+					gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), conmenu);
+					gtk_widget_show(conmenu);
+
+					(*g->prpl->action_menu)(conmenu, g, b->name);
+				}
+				cn = g_slist_next(cn);
+			}
+		} else {
+			g = (struct gaim_connection *)cn->data;
+			if (g->prpl->action_menu)
+				(*g->prpl->action_menu)(menu, g, b->name);
+		}
 		
 		gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
 			       event->button, event->time);
@@ -630,6 +615,8 @@
 	struct buddy *b;
 	char *text[1];
 
+	if (!blist) return;
+
 	gtk_clist_freeze(GTK_CLIST(edittree));
 	gtk_clist_clear(GTK_CLIST(edittree));
 	
@@ -858,7 +845,7 @@
 static void im_callback(GtkWidget *widget, GtkTree *tree)
 {
 	GList *i;
-	struct buddy *b = NULL;
+	struct buddy_show *b = NULL;
 	struct conversation *c;
 	i = GTK_TREE_SELECTION(tree);
 	if (i) {
@@ -882,7 +869,7 @@
 static void info_callback(GtkWidget *widget, GtkTree *tree)
 {
 	GList *i;
-	struct buddy *b = NULL;
+	struct buddy_show *b = NULL;
 	i = GTK_TREE_SELECTION(tree);
 	if (i) {
 		b = gtk_object_get_user_data(GTK_OBJECT(i->data));
@@ -892,7 +879,7 @@
         }
 	if (!b->name)
 		return;
-        serv_get_info(b->name);
+        serv_get_info(b->connlist->data, b->name);
 }
 
 
@@ -1414,11 +1401,11 @@
 		if (b->present == 1) {
 			play_sound(BUDDY_ARRIVE);
 			b->present = 2;
-			if (b->log_timer > 0)
-				gtk_timeout_remove(b->log_timer);
+			if (bs->log_timer > 0)
+				gtk_timeout_remove(bs->log_timer);
 			if (!g_slist_find(bs->connlist, gc))
 				bs->connlist = g_slist_append(bs->connlist, gc);
-			b->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
+			bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
 		} else {
 			if (gc->prpl->list_icon)
 				xpm = (*gc->prpl->list_icon)(b->uc);
@@ -1438,9 +1425,9 @@
 		gs = find_group_show(g->name);
 		bs = find_buddy_show(gs, b->name);
 		bs->connlist = g_slist_remove(bs->connlist, gc);
-		if (b->log_timer > 0)
-			gtk_timeout_remove(b->log_timer);
-		b->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
+		if (bs->log_timer > 0)
+			gtk_timeout_remove(bs->log_timer);
+		bs->log_timer = gtk_timeout_add(10000, (GtkFunction)log_timeout, bs);
 		pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, logout_icon_xpm);
 		gtk_widget_hide(bs->pix);
 		gtk_pixmap_set(GTK_PIXMAP(bs->pix), pm, bm);
--- a/src/conversation.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/conversation.c	Tue Oct 31 06:09:47 2000 +0000
@@ -446,9 +446,9 @@
 	        else
 	                return;
 
-	        serv_get_info(name);
+	        serv_get_info(c->gc, name);
 	} else {
-	        serv_get_info(c->name);
+	        serv_get_info(c->gc, c->name);
 		gtk_widget_grab_focus(c->entry);
 	}
 }
--- a/src/dialogs.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/dialogs.c	Tue Oct 31 06:09:47 2000 +0000
@@ -568,7 +568,9 @@
 		return;
 	}
 	
-	serv_get_info(who);
+	/* FIXME: what do we want to do about this case? */
+	if (connections)
+		serv_get_info(connections->data, who);
 
 	g_free(who);
 }
--- a/src/gaim.h	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/gaim.h	Tue Oct 31 06:09:47 2000 +0000
@@ -202,7 +202,6 @@
 	char *filename;
 	char *description;
 	void *handle;
-	int   remove;
 };
 
 struct gaim_callback {
@@ -220,7 +219,6 @@
 	char name[80];
 	char show[80];
         int present;
-        int log_timer;
 	int evil;
 	time_t signon;
 	time_t idle;
@@ -628,9 +626,9 @@
 extern void serv_touch_idle(struct gaim_connection *);
 extern void serv_finish_login();
 extern void serv_send_im(struct gaim_connection *, char *, char *, int);
-extern void serv_get_info(char *);
-extern void serv_get_away_msg(char *);
-extern void serv_get_dir(char *);
+extern void serv_get_info(struct gaim_connection *, char *);
+extern void serv_get_away_msg(struct gaim_connection *, char *);
+extern void serv_get_dir(struct gaim_connection *, char *);
 extern void serv_set_idle(struct gaim_connection *, int);
 extern void serv_set_info(struct gaim_connection *, char *);
 extern void serv_set_away(char *);
--- a/src/oscar.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/oscar.c	Tue Oct 31 06:09:47 2000 +0000
@@ -1345,10 +1345,39 @@
 	return NULL;
 }
 
+static void oscar_info(GtkObject *obj, char *who) {
+	struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj);
+	serv_get_info(gc, who);
+}
+
+static void oscar_away_msg(GtkObject *obj, char *who) {
+	struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj);
+	serv_get_away_msg(gc, who);
+}
+
+static void oscar_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) {
+	GtkWidget *button;
+
+	button = gtk_menu_item_new_with_label(_("Get Info"));
+	gtk_signal_connect(GTK_OBJECT(button), "activate",
+			   GTK_SIGNAL_FUNC(oscar_info), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+
+	button = gtk_menu_item_new_with_label(_("Get Away Msg"));
+	gtk_signal_connect(GTK_OBJECT(button), "activate",
+			   GTK_SIGNAL_FUNC(oscar_away_msg), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+}
+
 void oscar_init(struct prpl *ret) {
 	ret->protocol = PROTO_OSCAR;
 	ret->name = oscar_name;
 	ret->list_icon = oscar_list_icon;
+	ret->action_menu = oscar_action_menu;
 	ret->login = oscar_login;
 	ret->close = oscar_close;
 	ret->send_im = oscar_send_im;
--- a/src/prpl.h	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/prpl.h	Tue Oct 31 06:09:47 2000 +0000
@@ -39,7 +39,10 @@
 	int protocol;
 	char *(* name)();
 
+	/* returns the XPM associated with the given user class */
 	char **(* list_icon)(int);
+	/* returns a GtkMenu * for use in the buddy list */
+	void (* action_menu)(GtkWidget *, struct gaim_connection *, char *);
 
 	void (* login)		(struct aim_user *);
 	void (* close)		(struct gaim_connection *);
--- a/src/rvous.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/rvous.c	Tue Oct 31 06:09:47 2000 +0000
@@ -67,7 +67,7 @@
 
 static void info_callback(GtkWidget *widget, struct file_transfer *ft)
 {
-        serv_get_info(ft->user);
+	serv_get_info(ft->gc, ft->user);
 }
 
 static void cancel_callback(GtkWidget *widget, struct file_transfer *ft)
--- a/src/server.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/server.c	Tue Oct 31 06:09:47 2000 +0000
@@ -112,36 +112,20 @@
                 serv_touch_idle(gc);
 }
 
-void serv_get_info(char *name)
+void serv_get_info(struct gaim_connection *g, char *name)
 {
-	/* FIXME: getting someone's info? how do you decide something like that? I think that
-	 * the buddy list/UI needs to be really changed before this gets fixed*/
-	struct gaim_connection *g;
-	if (!connections) return;
-	g = connections->data;
-
 	if (g && g->prpl && g->prpl->get_info)
 		(*g->prpl->get_info)(g, name);
 }
 
-void serv_get_away_msg(char *name)
+void serv_get_away_msg(struct gaim_connection *g, char *name)
 {
-	/* FIXME: see the serv_get_info comment above :-P */
-	struct gaim_connection *g;
-	if (!connections) return;
-	g = connections->data;
-
 	if (g && g->prpl && g->prpl->get_away_msg)
 		(*g->prpl->get_away_msg)(g, name);
 }
 
-void serv_get_dir(char *name)
+void serv_get_dir(struct gaim_connection *g, char *name)
 {
-	/* FIXME: see the serv_get_info comment above :-P */
-	struct gaim_connection *g;
-	if (!connections) return;
-	g = connections->data;
-
 	if (g && g->prpl && g->prpl->get_dir)
 		(*g->prpl->get_dir)(g, name);
 }
--- a/src/toc.c	Fri Oct 27 08:10:29 2000 +0000
+++ b/src/toc.c	Tue Oct 31 06:09:47 2000 +0000
@@ -46,7 +46,7 @@
 #include "pixmaps/dt_icon.xpm"
 #include "pixmaps/free_icon.xpm"
 
-#define REVISION "gaim:$Revision: 1040 $"
+#define REVISION "gaim:$Revision: 1042 $"
 
 struct toc_data {
 	int toc_fd;
@@ -1115,10 +1115,39 @@
 	return NULL;
 }
 
+static void toc_info(GtkObject *obj, char *who) {
+	struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj);
+	serv_get_info(gc, who);
+}
+
+static void toc_dir_info(GtkObject *obj, char *who) {
+	struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj);
+	serv_get_dir(gc, who);
+}
+
+static void toc_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) {
+	GtkWidget *button;
+
+	button = gtk_menu_item_new_with_label(_("Get Info"));
+	gtk_signal_connect(GTK_OBJECT(button), "activate",
+			   GTK_SIGNAL_FUNC(toc_info), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+
+	button = gtk_menu_item_new_with_label(_("Get Dir Info"));
+	gtk_signal_connect(GTK_OBJECT(button), "activate",
+			   GTK_SIGNAL_FUNC(toc_dir_info), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
+}
+
 void toc_init(struct prpl *ret) {
         ret->protocol = PROTO_TOC;
         ret->name = toc_name;
 	ret->list_icon = toc_list_icon;
+	ret->action_menu = toc_action_menu;
         ret->login = toc_login;
         ret->close = toc_close;
         ret->send_im = toc_send_im;