Mercurial > pidgin.yaz
comparison src/gtkroomlist.c @ 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 | 12055bae7f59 |
children | ef881489396e |
comparison
equal
deleted
inserted
replaced
8229:a74ff5569c86 | 8230:4e354776ae2a |
---|---|
52 GtkWidget *join_button; | 52 GtkWidget *join_button; |
53 GtkWidget *close_button; | 53 GtkWidget *close_button; |
54 | 54 |
55 GaimAccount *account; | 55 GaimAccount *account; |
56 GaimRoomlist *roomlist; | 56 GaimRoomlist *roomlist; |
57 | |
58 gboolean pg_needs_pulse; | |
59 gboolean pg_to_active; | |
60 guint pg_update_to; | |
57 }; | 61 }; |
58 | 62 |
59 enum { | 63 enum { |
60 NAME_COLUMN = 0, | 64 NAME_COLUMN = 0, |
61 ROOM_COLUMN, | 65 ROOM_COLUMN, |
70 | 74 |
71 dialog = (GaimGtkRoomlistDialog *) d; | 75 dialog = (GaimGtkRoomlistDialog *) d; |
72 | 76 |
73 if (dialog->roomlist && gaim_roomlist_get_in_progress(dialog->roomlist)) | 77 if (dialog->roomlist && gaim_roomlist_get_in_progress(dialog->roomlist)) |
74 gaim_roomlist_cancel_get_list(dialog->roomlist); | 78 gaim_roomlist_cancel_get_list(dialog->roomlist); |
79 | |
80 if (dialog->roomlist) { | |
81 if (dialog->pg_to_active) { | |
82 g_source_remove(dialog->pg_update_to); | |
83 dialog->pg_to_active = FALSE; | |
84 /* yes, that's right, unref it twice. */ | |
85 gaim_roomlist_unref(dialog->roomlist); | |
86 } | |
87 } | |
75 | 88 |
76 /* free stuff here */ | 89 /* free stuff here */ |
77 if (dialog->roomlist) | 90 if (dialog->roomlist) |
78 gaim_roomlist_unref(dialog->roomlist); | 91 gaim_roomlist_unref(dialog->roomlist); |
79 g_free(dialog); | 92 g_free(dialog); |
563 g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list); | 576 g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list); |
564 g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list); | 577 g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list); |
565 g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list); | 578 g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list); |
566 } | 579 } |
567 | 580 |
581 static gboolean gaim_gtk_progress_bar_pulse(gpointer data) | |
582 { | |
583 GaimRoomlist *list = data; | |
584 GaimGtkRoomlist *rl = list->ui_data; | |
585 | |
586 if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) { | |
587 rl->dialog->pg_to_active = FALSE; | |
588 gaim_roomlist_unref(list); | |
589 return FALSE; | |
590 } | |
591 | |
592 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); | |
593 rl->dialog->pg_needs_pulse = FALSE; | |
594 return TRUE; | |
595 } | |
596 | |
568 static void gaim_gtk_roomlist_add_room(GaimRoomlist *list, GaimRoomlistRoom *room) | 597 static void gaim_gtk_roomlist_add_room(GaimRoomlist *list, GaimRoomlistRoom *room) |
569 { | 598 { |
570 GaimGtkRoomlist *rl= list->ui_data; | 599 GaimGtkRoomlist *rl= list->ui_data; |
571 GtkTreeRowReference *rr, *parentrr = NULL; | 600 GtkTreeRowReference *rr, *parentrr = NULL; |
572 GtkTreePath *path; | 601 GtkTreePath *path; |
578 rl->total_rooms++; | 607 rl->total_rooms++; |
579 if (room->type == GAIM_ROOMLIST_ROOMTYPE_ROOM) | 608 if (room->type == GAIM_ROOMLIST_ROOMTYPE_ROOM) |
580 rl->num_rooms++; | 609 rl->num_rooms++; |
581 | 610 |
582 if (rl->dialog) { | 611 if (rl->dialog) { |
583 if (rl->total_rooms > 100) | 612 if (!rl->dialog->pg_to_active) { |
584 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(rl->dialog->progress), | 613 rl->dialog->pg_to_active = TRUE; |
585 0.01); | 614 gaim_roomlist_ref(list); |
586 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); | 615 rl->dialog->pg_update_to = g_timeout_add(100, gaim_gtk_progress_bar_pulse, list); |
616 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); | |
617 } else { | |
618 rl->dialog->pg_needs_pulse = TRUE; | |
619 } | |
587 } | 620 } |
588 if (room->parent) { | 621 if (room->parent) { |
589 parentrr = g_hash_table_lookup(rl->cats, room->parent); | 622 parentrr = g_hash_table_lookup(rl->cats, room->parent); |
590 path = gtk_tree_row_reference_get_path(parentrr); | 623 path = gtk_tree_row_reference_get_path(parentrr); |
591 if (path) { | 624 if (path) { |
641 if (rl->dialog->account_widget) | 674 if (rl->dialog->account_widget) |
642 gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE); | 675 gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE); |
643 gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE); | 676 gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE); |
644 gtk_widget_set_sensitive(rl->dialog->list_button, FALSE); | 677 gtk_widget_set_sensitive(rl->dialog->list_button, FALSE); |
645 } else { | 678 } else { |
679 rl->dialog->pg_needs_pulse = FALSE; | |
646 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0); | 680 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0); |
647 if (rl->dialog->account_widget) | 681 if (rl->dialog->account_widget) |
648 gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE); | 682 gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE); |
649 gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE); | 683 gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE); |
650 gtk_widget_set_sensitive(rl->dialog->list_button, TRUE); | 684 gtk_widget_set_sensitive(rl->dialog->list_button, TRUE); |