+static void summary_switch_from_to(SummaryView *summaryview, FolderItem *item)
+{
+ gboolean show_from = FALSE, show_to = FALSE;
+ gboolean showing_from = FALSE, showing_to = FALSE;
+ gint from_pos = 0, to_pos = 0;
+ SummaryColumnState *col_state = summaryview->col_state;
+ GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+
+ if (!item)
+ return;
+ if (folder_has_parent_of_type(item, F_OUTBOX)
+ || folder_has_parent_of_type(item, F_DRAFT)
+ || folder_has_parent_of_type(item, F_QUEUE))
+ show_to = TRUE;
+ else
+ show_from = TRUE;
+
+ from_pos = summaryview->col_pos[S_COL_FROM];
+ to_pos = summaryview->col_pos[S_COL_TO];
+ showing_from = col_state[from_pos].visible;
+ showing_to = col_state[to_pos].visible;
+
+ if (showing_from && showing_to) {
+ debug_print("showing both\n");
+ return;
+ }
+
+ if (!showing_from && !showing_to) {
+ debug_print("showing none\n");
+ return;
+ }
+
+ debug_print("showing %s %s, must show %s %s\n",
+ showing_from?"From":"",
+ showing_to?"To":"",
+ show_from?"From":"",
+ show_to?"To":"");
+
+ if (showing_from == show_from && showing_to == show_to)
+ return;
+ /* else we'll switch both */
+
+ debug_print("switching columns\n");
+ col_state[from_pos].type = S_COL_TO;
+ col_state[from_pos].visible = show_to;
+
+ col_state[to_pos].type = S_COL_FROM;
+ col_state[to_pos].visible = show_from;
+
+ summaryview->col_pos[S_COL_TO] = from_pos;
+ summaryview->col_pos[S_COL_FROM] = to_pos;
+
+ gtk_clist_set_column_visibility
+ (GTK_CLIST(ctree), from_pos, col_state[from_pos].visible);
+ gtk_clist_set_column_visibility
+ (GTK_CLIST(ctree), to_pos, col_state[to_pos].visible);
+
+ summary_set_column_titles(summaryview);
+}
+