Re: Wish list - more sentboxes



Here's a different way to handle the `From-To' issue: when you click on 
the `From' column, it cycles through:
   From  Ascending
   From  Descending
   To    Ascending
   To    Descending
(The column title is `From' or `To'--sort order isn't shown.)  The 
column is initialized to `From, Ascending' except `if (mailbox == 
balsa_app.sentbox || mailbox == balsa_app.draftbox || mailbox == 
balsa_app.outbox)', when it is `To, Ascending'.

That way, any mailbox can be switched to showing the recipient with at 
most four mouse clicks (one to select `From', one to reverse sort 
order, one to reverse sort order again and toggle to `To', and one more 
to reselect the original sort column, say `Date').  Of course, it's not 
remembered when you close and reopen the mailbox...but at least it 
avoids inferring mailbox characteristics from the name!

Comments?
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/src/balsa-index.c balsa-index/src/balsa-index.c
--- balsa-cvs/src/balsa-index.c	Wed Oct 24 07:56:05 2001
+++ balsa-index/src/balsa-index.c	Fri Oct 26 08:42:42 2001
@@ -282,14 +282,16 @@
 	NULL,
 	NULL,
 	NULL,
+	NULL,
 	NULL
     };
 
     /* FIXME: */
     titles[3] = _("From");
-    titles[4] = _("Subject");
-    titles[5] = _("Date");
-    titles[6] = _("Size");
+    titles[4] = _("To");
+    titles[5] = _("Subject");
+    titles[6] = _("Date");
+    titles[7] = _("Size");
 
     bindex->mailbox_node = NULL;
     adj = gtk_adjustment_new (0.0, 0.0, 10.0, 1.0, 1.0, 1.0);
@@ -303,27 +305,30 @@
                                     GTK_POLICY_AUTOMATIC);
     
     /* create the clist */
-    bindex->ctree = GTK_CTREE (gtk_ctree_new_with_titles (7, 4, titles));
+    bindex->ctree = GTK_CTREE (gtk_ctree_new_with_titles (8, 5, titles));
     clist = GTK_CLIST(bindex->ctree);
     gtk_container_add (GTK_CONTAINER (bindex), GTK_WIDGET (bindex->ctree));
 
     gtk_signal_connect(GTK_OBJECT(clist), "click_column",
 		       GTK_SIGNAL_FUNC(clist_click_column), bindex);
+    /* Make `To' column invisible */
+    gtk_clist_set_column_visibility(clist, 4, FALSE);
 
     gtk_clist_set_selection_mode(clist, GTK_SELECTION_EXTENDED);
     gtk_clist_set_column_justification(clist, 0, GTK_JUSTIFY_RIGHT);
     gtk_clist_set_column_justification(clist, 1, GTK_JUSTIFY_CENTER);
     gtk_clist_set_column_justification(clist, 2, GTK_JUSTIFY_CENTER);
-    gtk_clist_set_column_justification(clist, 6, GTK_JUSTIFY_RIGHT);
+    gtk_clist_set_column_justification(clist, 7, GTK_JUSTIFY_RIGHT);
 
     /* Set the width of any new columns to the current column widths being used */
     gtk_clist_set_column_width(clist, 0, balsa_app.index_num_width);
     gtk_clist_set_column_width(clist, 1, balsa_app.index_status_width);
     gtk_clist_set_column_width(clist, 2, balsa_app.index_attachment_width);
     gtk_clist_set_column_width(clist, 3, balsa_app.index_from_width);
-    gtk_clist_set_column_width(clist, 4, balsa_app.index_subject_width);
-    gtk_clist_set_column_width(clist, 5, balsa_app.index_date_width);
-    gtk_clist_set_column_width(clist, 6, balsa_app.index_size_width);
+    gtk_clist_set_column_width(clist, 4, balsa_app.index_from_width);
+    gtk_clist_set_column_width(clist, 5, balsa_app.index_subject_width);
+    gtk_clist_set_column_width(clist, 6, balsa_app.index_date_width);
+    gtk_clist_set_column_width(clist, 7, balsa_app.index_size_width);
     font = gtk_widget_get_style (GTK_WIDGET(clist))->font;
     row_height = font->ascent + font->descent+2;
     
@@ -331,7 +336,7 @@
 	gtk_clist_set_row_height(clist, 16);
 
     /* Set default sorting behaviour */
-    gtk_clist_set_sort_column(clist, 5);
+    gtk_clist_set_sort_column(clist, 6);
     gtk_clist_set_compare_func(clist, date_compare);
     gtk_clist_set_sort_type(clist, GTK_SORT_DESCENDING);
 
@@ -498,9 +503,21 @@
     gint h;
     GtkSortType sort_type = clist->sort_type;
 
+    gtk_clist_freeze(clist);
     if (column == clist->sort_column)
+    {
+        /* click on current sort column: reverse sort order */
+        if ((column == 3 || column == 4)
+            && sort_type == GTK_SORT_DESCENDING) {
+            /* toggle from/to */
+            gtk_clist_set_column_visibility(clist, column, FALSE);
+            column = (column == 3) ? 4 : 3;
+            gtk_clist_set_column_visibility(clist, column, TRUE);
+        }
+            /* toggle sort order */
 	sort_type = (sort_type == GTK_SORT_ASCENDING) ?
 	    GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
+    }
 	
     balsa_index_set_sort_order(BALSA_INDEX(data), column, sort_type);
     gtk_clist_sort(clist);
@@ -509,6 +526,8 @@
     if ((h = balsa_index_get_largest_selected(clist)) >= 0 &&
 	gtk_clist_row_is_visible(clist, h) != GTK_VISIBILITY_FULL)
 	gtk_clist_moveto(clist, h, 0, 1.0, 0.0);
+
+    gtk_clist_thaw(clist);
 }
 
 
@@ -636,12 +655,12 @@
      */
     bindex->mailbox_node = mbnode;
     /*
-     * rename "from" column to "to" for outgoing mail
+     * switch visibility of `From' and `To' columns
      */
     if (mailbox == balsa_app.sentbox ||
 	mailbox == balsa_app.draftbox || mailbox == balsa_app.outbox) {
-
-	gtk_clist_set_column_title(GTK_CLIST(bindex->ctree), 3, _("To"));
+	gtk_clist_set_column_visibility(GTK_CLIST(bindex->ctree), 3, FALSE);
+	gtk_clist_set_column_visibility(GTK_CLIST(bindex->ctree), 4, TRUE);
     }
 
     gtk_signal_connect(GTK_OBJECT(mailbox), "message-status-changed",
@@ -681,11 +700,10 @@
 balsa_index_add(BalsaIndex * bindex, LibBalsaMessage * message)
 {
     gchar buff1[32];
-    gchar *text[7];
+    gchar *text[8];
     gchar *name_str=NULL;
     GtkCTreeNode *node;
     GList *list;
-    LibBalsaAddress *addy = NULL;
     LibBalsaMailbox* mailbox;
     gboolean append_dots;
     
@@ -702,42 +720,34 @@
     text[1] = NULL;		/* flags */
     text[2] = NULL;		/* attachments */
 
-
+    text[3] =
+        message->from ? (gchar *) libbalsa_address_get_name(message-> from)
+                      : "";
     append_dots = FALSE;
-    if (mailbox == balsa_app.sentbox ||
-	mailbox == balsa_app.draftbox ||
-	mailbox == balsa_app.outbox) {
-	if (message->to_list) {
-	    list = g_list_first(message->to_list);
-	    addy = list->data;
-	    append_dots = list->next != NULL;
-	}
-    } else {
-	if (message->from)
-	    addy = message->from;
+    if (message->to_list) {
+        list = g_list_first(message->to_list);
+        append_dots = list->next != NULL;
+	name_str=(gchar *)libbalsa_address_get_name(list->data);
     }
 
-    if (addy)
-	name_str=(gchar *)libbalsa_address_get_name(addy);
-    
     if(!name_str)		/* !addy, or addy contained no name/address */
 	name_str = "";
 
-    text[3] = append_dots ? g_strconcat(name_str, ",...", NULL)
+    text[4] = append_dots ? g_strconcat(name_str, ",...", NULL)
 	: name_str; 
 
-    text[4] = (gchar*)LIBBALSA_MESSAGE_GET_SUBJECT(message);
-    text[5] =
-	libbalsa_message_date_to_gchar(message, balsa_app.date_string);
+    text[5] = (gchar*)LIBBALSA_MESSAGE_GET_SUBJECT(message);
     text[6] =
+	libbalsa_message_date_to_gchar(message, balsa_app.date_string);
+    text[7] =
 	libbalsa_message_size_to_gchar(message, balsa_app.line_length);
 
     node = gtk_ctree_insert_node(GTK_CTREE(bindex->ctree), NULL, NULL, 
                                  text, 2, NULL, NULL, NULL, NULL, 
                                  FALSE, TRUE);
-    if(append_dots) g_free(text[3]);
-    g_free(text[5]);
+    if(append_dots) g_free(text[4]);
     g_free(text[6]);
+    g_free(text[7]);
 
     gtk_ctree_node_set_row_data (GTK_CTREE (bindex->ctree), node, 
                                  (gpointer) message);
@@ -1331,14 +1341,18 @@
 	break;
 
     case 4:
-	balsa_app.index_subject_width = width;
+	balsa_app.index_from_width = width;
 	break;
 
     case 5:
-	balsa_app.index_date_width = width;
+	balsa_app.index_subject_width = width;
 	break;
 
     case 6:
+	balsa_app.index_date_width = width;
+	break;
+
+    case 7:
 	balsa_app.index_size_width = width;
 	break;
 
@@ -2401,7 +2415,7 @@
 {
     GtkCList * clist;
     g_return_if_fail(bindex->mailbox_node);
-    g_return_if_fail(column>=0 && column <=6);
+    g_return_if_fail(column>=0 && column <=7);
     g_return_if_fail(order == GTK_SORT_DESCENDING || 
 		     order == GTK_SORT_ASCENDING);
 
@@ -2415,10 +2429,10 @@
     case 0:
 	gtk_clist_set_compare_func(clist, numeric_compare);
 	break;
-    case 5:
+    case 6:
 	gtk_clist_set_compare_func(clist, date_compare);
 	break;
-    case 6:
+    case 7:
         gtk_clist_set_compare_func(clist, size_compare);
         break;
     default:
@@ -2462,7 +2476,7 @@
 		gtk_ctree_node_get_row_data (ctree, node);
 	    txt_new = libbalsa_message_size_to_gchar(message,
 						     bindex->line_length);
-	    gtk_ctree_node_set_text (ctree, node, 6, txt_new);
+	    gtk_ctree_node_set_text (ctree, node, 7, txt_new);
 	    g_free (txt_new);
 	    j++;
 	}
@@ -2506,7 +2520,7 @@
 		gtk_ctree_node_get_row_data (ctree, node);
 	    txt_new = libbalsa_message_date_to_gchar(message,
 						     bindex->date_string);
-	    gtk_ctree_node_set_text (ctree, node, 5, txt_new);
+	    gtk_ctree_node_set_text (ctree, node, 6, txt_new);
 	    g_free (txt_new);
 	    j++;
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]