sync with 0.7.4cvs26
[claws.git] / src / summaryview.c
index a7a75f87e082b839e3ea4bf10800405c101751f4..75fc8e25d9769c396a306731531ad10eb3647984 100644 (file)
@@ -452,9 +452,11 @@ SummaryView *summary_create(void)
        GtkWidget *scrolledwin;
        GtkWidget *ctree;
        GtkWidget *hbox;
+       GtkWidget *hbox_l;
        GtkWidget *statlabel_folder;
        GtkWidget *statlabel_select;
        GtkWidget *statlabel_msgs;
+       GtkWidget *hbox_spc;
        GtkWidget *toggle_view_btn;
        GtkWidget *toggle_view_arrow;
        GtkWidget *popupmenu;
@@ -487,10 +489,13 @@ SummaryView *summary_create(void)
        hbox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
 
+       hbox_l = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), hbox_l, TRUE, TRUE, 0);
+
        statlabel_folder = gtk_label_new("");
-       gtk_box_pack_start(GTK_BOX(hbox), statlabel_folder, FALSE, FALSE, 2);
+       gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_folder, FALSE, FALSE, 2);
        statlabel_select = gtk_label_new("");
-       gtk_box_pack_start(GTK_BOX(hbox), statlabel_select, FALSE, FALSE, 16);
+       gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_select, FALSE, FALSE, 12);
 
        /* toggle view buttons */
        toggle_view_btn = gtk_button_new();
@@ -504,6 +509,9 @@ SummaryView *summary_create(void)
        statlabel_msgs = gtk_label_new("");
        gtk_box_pack_end(GTK_BOX(hbox), statlabel_msgs, FALSE, FALSE, 4);
 
+       hbox_spc = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_end(GTK_BOX(hbox), hbox_spc, FALSE, FALSE, 6);
+
        /* create popup menu */
        n_entries = sizeof(summary_popup_entries) /
                sizeof(summary_popup_entries[0]);
@@ -515,6 +523,7 @@ SummaryView *summary_create(void)
        summaryview->scrolledwin = scrolledwin;
        summaryview->ctree = ctree;
        summaryview->hbox = hbox;
+       summaryview->hbox_l = hbox_l;
        summaryview->statlabel_folder = statlabel_folder;
        summaryview->statlabel_select = statlabel_select;
        summaryview->statlabel_msgs = statlabel_msgs;
@@ -594,9 +603,9 @@ void summary_init(SummaryView *summaryview)
        gtk_widget_set_style(summaryview->statlabel_select, style);
        gtk_widget_set_style(summaryview->statlabel_msgs, style);
 
-       pixmap = stock_pixmap_widget(summaryview->hbox, STOCK_PIXMAP_DIR_OPEN);
-       gtk_box_pack_start(GTK_BOX(summaryview->hbox), pixmap, FALSE, FALSE, 4);
-       gtk_box_reorder_child(GTK_BOX(summaryview->hbox), pixmap, 0);
+       pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
+       gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
+       gtk_box_reorder_child(GTK_BOX(summaryview->hbox_l), pixmap, 0);
        gtk_widget_show(pixmap);
        summaryview->folder_pixmap = pixmap;
 
@@ -2191,6 +2200,28 @@ static void summary_write_cache_func(GtkCTree *ctree, GtkCTreeNode *node,
        procmsg_write_flags(msginfo, fps->mark_fp);
 }
 
+static gchar *summary_complete_address(const gchar *addr)
+{
+       gint count;
+       gchar *res, *tmp, *email_addr;
+
+       Xstrdup_a(email_addr, addr, return NULL);
+       extract_address(email_addr);
+       g_return_val_if_fail(*email_addr, NULL);
+
+       /*
+        * completion stuff must be already initialized
+        */
+       res = NULL;
+       if (1 < (count = complete_address(email_addr))) {
+               tmp = get_complete_address(1);
+               res = procheader_get_fromname(tmp);
+               g_free(tmp);    
+       }
+       
+       return res;
+}
+
 static void summary_set_header(SummaryView *summaryview, gchar *text[],
                               MsgInfo *msginfo)
 {
@@ -2230,34 +2261,37 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
                _("(No From)");
        if (prefs_common.swap_from && msginfo->from && msginfo->to &&
            !MSG_IS_NEWS(msginfo->flags)) {
-               gchar *from;
+               gchar *addr = NULL;
+
+               if (prefs_common.use_addr_book) {
+                       Xstrdup_a(addr, msginfo->from, return);
+                       extract_address(addr);
+               }
 
-               Xstrdup_a(from, msginfo->from, return);
-               extract_address(from);
-               if (account_find_from_address(from)) {
+               if (account_find_from_address(addr)) {
+                       addr = summary_complete_address(msginfo->to);
                        g_free(to);
-                       to = g_strconcat("-->", msginfo->to, NULL);
+                       to   = g_strconcat("-->", addr == NULL ? msginfo->to : addr, NULL);
                        text[col_pos[S_COL_FROM]] = to;
                }
        }
 
-       if ((text[col_pos[S_COL_FROM]] != to) && prefs_common.use_addr_book &&
-           msginfo->from) {
-               gint count;
+       /*
+        * CLAWS: note that the "text[col_pos[S_COL_FROM]] != to" is really a hack, 
+        * checking whether the above block (which handles the special case of
+        * the --> in sent boxes) was executed.
+        */
+       if (text[col_pos[S_COL_FROM]] != to && prefs_common.use_addr_book && msginfo->from) {
                gchar *from;
-  
-               Xstrdup_a(from, msginfo->from, return);
-               extract_address(from);
-               if (*from) {
-                       count = complete_address(from);
-                       if (count > 1) {
-                               g_free(from_name);
-                               from = get_complete_address(1);
-                               from_name = procheader_get_fromname(from);
-                               g_free(from);
-                               text[col_pos[S_COL_FROM]] = from_name;
-                       }
-               }
+               from = summary_complete_address(msginfo->from);
+               if (from) {
+                       /*
+                        * FIXME: this text[col_pos[S_COL_FROM]] should be freed
+                        * but may have been assigned _("No From"). Should be
+                        * freed??? 
+                        */
+                       text[col_pos[S_COL_FROM]] = from;
+               }       
        }
 
        if (prefs->enable_simplify_subject