[PATCH] : small thinkos in balsa-index.c
- From: Emmanuel <e allaud wanadoo fr>
- To: balsa-list gnome org
- Subject: [PATCH] : small thinkos in balsa-index.c
- Date: Wed, 7 Nov 2001 18:04:13 +0100
Hi all,
time to hunt the "last line" bug in the message list :)
Here is a small patch for balsa-index.c (against 1.2.2, sorry).
Moreover the last line bug is not easily reproducible, suggesting a pretty
well hidden bug. argh...
Questions :
in balsa_index_set_first_new_message we locate the first new
message but we only record the message pointer, not the row. After the
moveto_handler will have to relocate the good according to the message
pointer. Seems pretty inefficient for me because we could store the row
during the search in balsa_index_set_first_new_message? Or are we doing
that because this row could have changed between the search and the call
to moveto_handler (I think that in fact this is the reason because in
balsa_index_del we set also the first_new_message pointer, but I want a
confirmation on that)?
in balsa_index_get_largest_selected : why do we use this code?
i = gtk_clist_find_row_from_data(clist,
LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data(GTK_CTREE(clist),
list->data)));
because list->data is just the row number, isn't it ? Or we must do that
because of ctree subtility I missed :)
Content :
* small cosmetic changes in balsa_index_get_selected_rows
* in date_compare : just delete the if statement and do return
t2-t1, a little bit more efficient
* in balsa_index_refresh :
we used twice gtk_clist_find_row_from_data, this was
useless and time consuming
I put i=-1 instead of i=0 to have i being the last row
index (before we had i=last row index +1)
--- balsa-1.2.2/src/balsa-index.c Wed Oct 31 13:09:35 2001
+++ balsa-1.2.2-new/src/balsa-index.c Wed Nov 7 17:56:26 2001
@@ -410,12 +410,7 @@
t1 = m1->date;
t2 = m2->date;
- if (t1 < t2)
- return 1;
- if (t1 > t2)
- return -1;
-
- return 0;
+ return t2-t1;
}
@@ -1436,26 +1431,21 @@
{
GList *list_of_selected_rows;
GtkCList *clist;
- guint nb_selected_rows;
- GtkCTreeNode **selected_rows;
- guint row_count;
+ GtkCTreeNode ** current_row;
clist = GTK_CLIST(bindex->ctree);
/* retreive the selection */
list_of_selected_rows = clist->selection;
- nb_selected_rows = g_list_length(list_of_selected_rows);
+ *nb_rows = g_list_length(list_of_selected_rows);
- selected_rows = (GtkCTreeNode **) g_malloc(nb_selected_rows * sizeof(GtkCTreeNode *));
- for (row_count = 0; row_count < nb_selected_rows; row_count++) {
- selected_rows[row_count] = (GtkCTreeNode *) (list_of_selected_rows->data);
- list_of_selected_rows = list_of_selected_rows->next;
+ current_row=*rows = (GtkCTreeNode **) g_malloc(*nb_rows * sizeof(GtkCTreeNode *));
+ for (;list_of_selected_rows;) {
+ *current_row = (GtkCTreeNode *) (list_of_selected_rows->data);
+ current_row++;
+ list_of_selected_rows = g_list_next(list_of_selected_rows);
}
- /* return the result of the search */
- *nb_rows = nb_selected_rows;
- *rows = selected_rows;
-
return;
}
@@ -1490,10 +1480,10 @@
gtk_clist_clear(clist);
list = bindex->mailbox_node->mailbox->message_list;
- i = 0;
+ i = -1;
while (list) {
balsa_index_add(bindex, LIBBALSA_MESSAGE(list->data));
- list = list->next;
+ list = g_list_next(list);
i++;
}
@@ -1508,9 +1498,7 @@
newrow = -1;
if (newrow >= 0) {
- gtk_clist_select_row(clist,
- gtk_clist_find_row_from_data(clist, old_message),
- -1);
+ gtk_clist_select_row(clist, newrow, -1);
i = newrow;
} else {
gtk_clist_select_row(clist, i, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]