changeset 8230:4e354776ae2a

[gaim-migrate @ 8953] "Well sf seems to be in read only mode. This patch makes the progress bar in the room list dialog pulse slower. Previously it pulsed every time a new room was received, and had a pulse step of 10 until 100 rooms were downloaded, and then switched to a pulse step of 100. Now it pulses every time a room is received but no more than once every 100ms. And the pulse step stays constant at 10. This should fix the "my connection is so far the progress bar is sucking up all my cpu" problem some lucky individuals have had. Since my connection isn't that fast, I'm not completely sure how well it works, but it seems good to me. Simguy tells me it's better. If you want to test you'll need to download the list on undernet on irc, or something like that. Other protocols tend to download it too fast to really see the progress bar. --Tim Ringenbach" committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 11 Feb 2004 22:34:55 +0000
parents a74ff5569c86
children f50c059b6384
files src/gtkroomlist.c
diffstat 1 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkroomlist.c	Wed Feb 11 19:40:07 2004 +0000
+++ b/src/gtkroomlist.c	Wed Feb 11 22:34:55 2004 +0000
@@ -54,6 +54,10 @@
 
 	GaimAccount *account;
 	GaimRoomlist *roomlist;
+
+	gboolean pg_needs_pulse;
+	gboolean pg_to_active;
+	guint pg_update_to;
 };
 
 enum {
@@ -73,6 +77,15 @@
 	if (dialog->roomlist && gaim_roomlist_get_in_progress(dialog->roomlist))
 		gaim_roomlist_cancel_get_list(dialog->roomlist);
 
+	if (dialog->roomlist) {
+		if (dialog->pg_to_active) {
+			g_source_remove(dialog->pg_update_to);
+			dialog->pg_to_active = FALSE;
+			/* yes, that's right, unref it twice. */
+			gaim_roomlist_unref(dialog->roomlist);
+		}
+	}
+
 	/* free stuff here */
 	if (dialog->roomlist)
 		gaim_roomlist_unref(dialog->roomlist);
@@ -565,6 +578,22 @@
 	g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list);
 }
 
+static gboolean gaim_gtk_progress_bar_pulse(gpointer data)
+{
+	GaimRoomlist *list = data;
+	GaimGtkRoomlist *rl = list->ui_data;
+
+	if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) {
+		rl->dialog->pg_to_active = FALSE;
+		gaim_roomlist_unref(list);
+		return FALSE;
+	}
+
+	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
+	rl->dialog->pg_needs_pulse = FALSE;
+	return TRUE;
+}
+
 static void gaim_gtk_roomlist_add_room(GaimRoomlist *list, GaimRoomlistRoom *room)
 {
 	GaimGtkRoomlist *rl= list->ui_data;
@@ -580,10 +609,14 @@
 		rl->num_rooms++;
 
 	if (rl->dialog) {
-		if (rl->total_rooms > 100)
-			gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(rl->dialog->progress),
-			                                0.01);
-		gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
+		if (!rl->dialog->pg_to_active) {
+			rl->dialog->pg_to_active = TRUE;
+			gaim_roomlist_ref(list);
+			rl->dialog->pg_update_to = g_timeout_add(100, gaim_gtk_progress_bar_pulse, list);
+			gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
+		} else {
+			rl->dialog->pg_needs_pulse = TRUE;
+		}
 	}
 	if (room->parent) {
 		parentrr = g_hash_table_lookup(rl->cats, room->parent);
@@ -643,6 +676,7 @@
 		gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE);
 		gtk_widget_set_sensitive(rl->dialog->list_button, FALSE);
 	} else {
+		rl->dialog->pg_needs_pulse = FALSE;
 		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0);
 		if (rl->dialog->account_widget)
 			gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE);