changeset 2564:552a56d334ec

[gaim-migrate @ 2577] Once upon a midnight dreary, robbie coded weak and weary... committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 21 Oct 2001 00:15:55 +0000
parents 29d09f9ce85f
children f2a5ed215713
files src/buddy.c src/dialogs.c
diffstat 2 files changed, 42 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Sun Oct 21 00:14:41 2001 +0000
+++ b/src/buddy.c	Sun Oct 21 00:15:55 2001 +0000
@@ -91,9 +91,6 @@
 void BuddyTickerLogonTimeout(gpointer data);
 void BuddyTickerLogoutTimeout(gpointer data);
 
-/* Predefine some functions */
-static void new_bp_callback(GtkWidget *w, char *name);
-
 struct buddy_show {
 	GtkWidget *item;
 	GtkWidget *pix;
@@ -117,6 +114,8 @@
 };
 static GSList *shows = NULL;
 
+/* Predefine some functions */
+static void new_bp_callback(GtkWidget *w, struct buddy_show *bs);
 static struct group_show *find_group_show(char *group);
 static struct buddy_show *find_buddy_show(struct group_show *gs, char *name);
 static int group_number(char *group);
@@ -623,7 +622,7 @@
 
 		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_SIGNAL_FUNC(new_bp_callback), b);
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
@@ -779,7 +778,7 @@
 
 		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_SIGNAL_FUNC(new_bp_callback), b);
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
@@ -1508,9 +1507,27 @@
 	g_free(who);
 }
 
-static void new_bp_callback(GtkWidget *w, char *name)
+static void new_bp_callback(GtkWidget *w, struct buddy_show *bs)
 {
-	show_new_bp(name);
+	struct gaim_connection *c = NULL;
+	struct buddy *b = NULL;
+	
+	if (bs) {
+		/* I really only care about the first account. If they've got multiple
+		 * accounts in here then, as eric would say, butt fuck them. */
+		c = (struct gaim_connection *)bs->connlist->data;
+
+		b = find_buddy(c, bs->name);
+		
+		if (!b) {
+			/* What the hell? */
+			return;
+		}
+
+		show_new_bp(bs->name, c, b->idle, b->uc & UC_UNAVAILABLE);
+	} else {
+		show_new_bp(NULL, NULL, 0, 0);
+	}
 }
 
 void do_bp_menu()
--- a/src/dialogs.c	Sun Oct 21 00:14:41 2001 +0000
+++ b/src/dialogs.c	Sun Oct 21 00:15:55 2001 +0000
@@ -1026,13 +1026,15 @@
 	b->user = u;
 }
 
-static GtkWidget *pounce_user_menu(struct addbp *b)
+static GtkWidget *pounce_user_menu(struct addbp *b, struct gaim_connection *gc)
 {
 	GtkWidget *optmenu;
 	GtkWidget *menu;
 	GtkWidget *opt;
 	GSList *u = aim_users;
 	struct aim_user *a;
+	int count = 0;
+	int place = 0;
 
 	optmenu = gtk_option_menu_new();
 
@@ -1051,13 +1053,19 @@
 		gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(pounce_choose), b);
 		gtk_menu_append(GTK_MENU(menu), opt);
 		gtk_widget_show(opt);
+
+		if (a->gc == gc) {
+			gtk_menu_item_activate(GTK_MENU_ITEM(opt));
+			place = count;
+		}
+
+		count++;
+			
 		u = u->next;
 	}
 
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
-	gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu),
-				    g_slist_index(aim_users,
-						 ((struct gaim_connection *)connections->data)->user));
+	gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), place);
 	b->user = ((struct gaim_connection *)connections->data)->user;
 
 	b->menu = optmenu;
@@ -1066,7 +1074,7 @@
 }
 
 
-void show_new_bp(char *name)
+void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away)
 {
 	GtkWidget *label;
 	GtkWidget *bbox;
@@ -1109,7 +1117,7 @@
 	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
 	gtk_widget_show(label);
 
-	optmenu = pounce_user_menu(b);
+	optmenu = pounce_user_menu(b, gc);
 	gtk_table_attach(GTK_TABLE(table), optmenu, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
 	gtk_widget_show(optmenu);
 
@@ -1144,10 +1152,14 @@
 	gtk_widget_show(b->p_signon);
 
 	b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away"));
+	if (away)
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE);
 	gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
 	gtk_widget_show(b->p_unaway);
 
 	b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle"));
+	if (idle)
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE);
 	gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
 	gtk_widget_show(b->p_unidle);