changeset 7483:4a416ff9cb4f

[gaim-migrate @ 8096] This is Daniel Atallah's patch to make the reconnect button on the disconnection dialog work. Plus a wee bit of voodoo from me. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 12 Nov 2003 04:56:41 +0000
parents 9b69fdd148fc
children 5b83ed21f070
files src/gtkconn.c
diffstat 1 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconn.c	Wed Nov 12 01:22:45 2003 +0000
+++ b/src/gtkconn.c	Wed Nov 12 04:56:41 2003 +0000
@@ -277,6 +277,10 @@
 
 static void disconnect_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
 {
+	GtkTreeIter iter;
+	GValue val = { 0, };
+	GtkTreeSelection *sel = NULL;
+	GtkTreeModel *model = NULL;
 	GaimAccount *account = NULL;
 	
 	switch(id) {
@@ -286,8 +290,25 @@
 		disconnect_window = NULL;
 		break;
 	case GTK_RESPONSE_ACCEPT:
-		
+		model = gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview));
+		/*
+		 * If we have more than one account disconnection displayed, then 
+		 * the scroll window is visible and we should use the selected 
+		 * account to reconnect.
+		 */
+		if (GTK_WIDGET_VISIBLE(disconnect_window->sw)) {
+			sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(disconnect_window->treeview));
+			if (!gtk_tree_selection_get_selected(sel, &model, &iter))
+				return;
+		} else {
+			/* There is only one account disconnection, so reconnect to it. */
+			if (!gtk_tree_model_get_iter_first(model, &iter))
+				return;
+		}
+		gtk_tree_model_get_value (model, &iter, 4, &val);
+		account = g_value_get_pointer(&val);
 		gaim_account_connect(account);
+		g_value_unset(&val);
 		break;
 	}
 }
@@ -315,6 +336,8 @@
 	GtkTreeViewColumn *col;
 	GtkListStore *list_store;
 	GtkTreeIter iter;
+	GValue val = { 0, };
+	GaimAccount *account = NULL;
 	
 	icon =  create_prpl_icon(gaim_connection_get_account(gc));
 	scale = gdk_pixbuf_scale_simple(icon, 16, 16, GDK_INTERP_BILINEAR);
@@ -399,6 +422,15 @@
 				  G_CALLBACK (disconnect_tree_cb), list_store);
 	} else {
 		list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(disconnect_window->treeview)));
+
+		gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
+		do {
+			gtk_tree_model_get_value(GTK_TREE_MODEL(list_store), &iter, 4, &val);
+			account = g_value_get_pointer(&val);
+			if (account == gaim_connection_get_account(gc))
+				gtk_list_store_remove(list_store, &iter);
+		} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter));
+
 		gtk_list_store_append (list_store, &iter);
 		gtk_list_store_set(list_store, &iter,
 				   0, scale,