Fix g_timeout usage
[claws.git] / src / folderview.c
index 27f26ad118b500fe5bc651cbbeca7ab1b7dc6188..94d708d6261c0dc73832f787a81c29494e5c92fe 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -70,104 +70,56 @@ static GtkStyle *bold_style;
 static GtkStyle *bold_color_style;
 static GtkStyle *bold_tgtfold_style;
 
-static GdkPixmap *inboxxpm;
-static GdkBitmap *inboxxpmmask;
-static GdkPixmap *inboxhrmxpm;
-static GdkBitmap *inboxhrmxpmmask;
-static GdkPixmap *inboxopenxpm;
-static GdkBitmap *inboxopenxpmmask;
-static GdkPixmap *inboxopenhrmxpm;
-static GdkBitmap *inboxopenhrmxpmmask;
-static GdkPixmap *outboxxpm;
-static GdkBitmap *outboxxpmmask;
-static GdkPixmap *outboxhrmxpm;
-static GdkBitmap *outboxhrmxpmmask;
-static GdkPixmap *outboxopenxpm;
-static GdkBitmap *outboxopenxpmmask;
-static GdkPixmap *outboxopenhrmxpm;
-static GdkBitmap *outboxopenhrmxpmmask;
-static GdkPixmap *folderxpm;
-static GdkBitmap *folderxpmmask;
-static GdkPixmap *folderhrmxpm;
-static GdkBitmap *folderhrmxpmmask;
-static GdkPixmap *folderopenxpm;
-static GdkBitmap *folderopenxpmmask;
-static GdkPixmap *folderopenhrmxpm;
-static GdkBitmap *folderopenhrmxpmmask;
-static GdkPixmap *trashopenxpm;
-static GdkBitmap *trashopenxpmmask;
-static GdkPixmap *trashopenhrmxpm;
-static GdkBitmap *trashopenhrmxpmmask;
-static GdkPixmap *trashxpm;
-static GdkBitmap *trashxpmmask;
-static GdkPixmap *trashhrmxpm;
-static GdkBitmap *trashhrmxpmmask;
-static GdkPixmap *queuexpm;
-static GdkBitmap *queuexpmmask;
-static GdkPixmap *queuehrmxpm;
-static GdkBitmap *queuehrmxpmmask;
-static GdkPixmap *queueopenxpm;
-static GdkBitmap *queueopenxpmmask;
-static GdkPixmap *queueopenhrmxpm;
-static GdkBitmap *queueopenhrmxpmmask;
-static GdkPixmap *draftsxpm;
-static GdkBitmap *draftsxpmmask;
-static GdkPixmap *draftsopenxpm;
-static GdkBitmap *draftsopenxpmmask;
-static GdkPixmap *noselectxpm;
-static GdkBitmap *noselectxpmmask;
-
-static GdkPixmap *m_inboxxpm;
-static GdkBitmap *m_inboxxpmmask;
-static GdkPixmap *m_inboxhrmxpm;
-static GdkBitmap *m_inboxhrmxpmmask;
-static GdkPixmap *m_inboxopenxpm;
-static GdkBitmap *m_inboxopenxpmmask;
-static GdkPixmap *m_inboxopenhrmxpm;
-static GdkBitmap *m_inboxopenhrmxpmmask;
-static GdkPixmap *m_outboxxpm;
-static GdkBitmap *m_outboxxpmmask;
-static GdkPixmap *m_outboxhrmxpm;
-static GdkBitmap *m_outboxhrmxpmmask;
-static GdkPixmap *m_outboxopenxpm;
-static GdkBitmap *m_outboxopenxpmmask;
-static GdkPixmap *m_outboxopenhrmxpm;
-static GdkBitmap *m_outboxopenhrmxpmmask;
-static GdkPixmap *m_folderxpm;
-static GdkBitmap *m_folderxpmmask;
-static GdkPixmap *m_folderhrmxpm;
-static GdkBitmap *m_folderhrmxpmmask;
-static GdkPixmap *m_folderopenxpm;
-static GdkBitmap *m_folderopenxpmmask;
-static GdkPixmap *m_folderopenhrmxpm;
-static GdkBitmap *m_folderopenhrmxpmmask;
-static GdkPixmap *m_trashopenxpm;
-static GdkBitmap *m_trashopenxpmmask;
-static GdkPixmap *m_trashopenhrmxpm;
-static GdkBitmap *m_trashopenhrmxpmmask;
-static GdkPixmap *m_trashxpm;
-static GdkBitmap *m_trashxpmmask;
-static GdkPixmap *m_trashhrmxpm;
-static GdkBitmap *m_trashhrmxpmmask;
-static GdkPixmap *m_queuexpm;
-static GdkBitmap *m_queuexpmmask;
-static GdkPixmap *m_queuehrmxpm;
-static GdkBitmap *m_queuehrmxpmmask;
-static GdkPixmap *m_queueopenxpm;
-static GdkBitmap *m_queueopenxpmmask;
-static GdkPixmap *m_queueopenhrmxpm;
-static GdkBitmap *m_queueopenhrmxpmmask;
-static GdkPixmap *m_draftsxpm;
-static GdkBitmap *m_draftsxpmmask;
-static GdkPixmap *m_draftsopenxpm;
-static GdkBitmap *m_draftsopenxpmmask;
-
-static GdkPixmap *newxpm;
-static GdkBitmap *newxpmmask;
-static GdkPixmap *unreadxpm;
-static GdkBitmap *unreadxpmmask;
-static GdkPixmap *readxpm;
-static GdkBitmap *readxpmmask;
+static GdkPixbuf *inboxxpm;
+static GdkPixbuf *inboxhrmxpm;
+static GdkPixbuf *inboxopenxpm;
+static GdkPixbuf *inboxopenhrmxpm;
+static GdkPixbuf *outboxxpm;
+static GdkPixbuf *outboxhrmxpm;
+static GdkPixbuf *outboxopenxpm;
+static GdkPixbuf *outboxopenhrmxpm;
+static GdkPixbuf *folderxpm;
+static GdkPixbuf *folderhrmxpm;
+static GdkPixbuf *folderopenxpm;
+static GdkPixbuf *folderopenhrmxpm;
+static GdkPixbuf *trashopenxpm;
+static GdkPixbuf *trashopenhrmxpm;
+static GdkPixbuf *trashxpm;
+static GdkPixbuf *trashhrmxpm;
+static GdkPixbuf *queuexpm;
+static GdkPixbuf *queuehrmxpm;
+static GdkPixbuf *queueopenxpm;
+static GdkPixbuf *queueopenhrmxpm;
+static GdkPixbuf *draftsxpm;
+static GdkPixbuf *draftsopenxpm;
+static GdkPixbuf *noselectxpm;
+
+static GdkPixbuf *m_inboxxpm;
+static GdkPixbuf *m_inboxhrmxpm;
+static GdkPixbuf *m_inboxopenxpm;
+static GdkPixbuf *m_inboxopenhrmxpm;
+static GdkPixbuf *m_outboxxpm;
+static GdkPixbuf *m_outboxhrmxpm;
+static GdkPixbuf *m_outboxopenxpm;
+static GdkPixbuf *m_outboxopenhrmxpm;
+static GdkPixbuf *m_folderxpm;
+static GdkPixbuf *m_folderhrmxpm;
+static GdkPixbuf *m_folderopenxpm;
+static GdkPixbuf *m_folderopenhrmxpm;
+static GdkPixbuf *m_trashopenxpm;
+static GdkPixbuf *m_trashopenhrmxpm;
+static GdkPixbuf *m_trashxpm;
+static GdkPixbuf *m_trashhrmxpm;
+static GdkPixbuf *m_queuexpm;
+static GdkPixbuf *m_queuehrmxpm;
+static GdkPixbuf *m_queueopenxpm;
+static GdkPixbuf *m_queueopenhrmxpm;
+static GdkPixbuf *m_draftsxpm;
+static GdkPixbuf *m_draftsopenxpm;
+
+static GdkPixbuf *newxpm;
+static GdkPixbuf *unreadxpm;
+static GdkPixbuf *readxpm;
 
 static void folderview_select_node      (FolderView    *folderview,
                                          GtkCMCTreeNode        *node);
@@ -376,17 +328,17 @@ static void folderview_column_set_titles(FolderView *folderview)
        
        /* CLAWS: titles for "New" and "Unread" show new & unread pixmaps
         * instead text (text overflows making them unreadable and ugly) */
-        stock_pixmap_gdk(ctree, STOCK_PIXMAP_NEW,
-                        &newxpm, &newxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_UNREAD,
-                        &unreadxpm, &unreadxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_READ,
-                        &readxpm, &readxpmmask);
+        stock_pixbuf_gdk(ctree, STOCK_PIXMAP_NEW,
+                        &newxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_UNREAD,
+                        &unreadxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_READ,
+                        &readxpm);
        
        label_folder = gtk_label_new(_("Folder"));
-       label_new = gtk_image_new_from_pixmap(newxpm, newxpmmask);
-       label_unread = gtk_image_new_from_pixmap(unreadxpm, unreadxpmmask);
-       label_total = gtk_image_new_from_pixmap(readxpm, readxpmmask);
+       label_new = gtk_image_new_from_pixbuf(newxpm);
+       label_unread = gtk_image_new_from_pixbuf(unreadxpm);
+       label_total = gtk_image_new_from_pixbuf(readxpm);
        
        gtk_cmclist_column_titles_active(GTK_CMCLIST(ctree));
         
@@ -493,15 +445,9 @@ static GtkWidget *folderview_ctree_create(FolderView *folderview)
        gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree), 
                                           col_pos[F_COL_TOTAL],
                                           GTK_JUSTIFY_RIGHT);
-       if (prefs_common.enable_dotted_lines) {
-               gtk_cmctree_set_line_style(GTK_CMCTREE(ctree), GTK_CMCTREE_LINES_DOTTED);
-               gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree),
-                                    GTK_CMCTREE_EXPANDER_SQUARE);
-       } else {
-               gtk_cmctree_set_line_style(GTK_CMCTREE(ctree), GTK_CMCTREE_LINES_NONE);
-               gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree),
-                                    GTK_CMCTREE_EXPANDER_TRIANGLE);
-       }
+       gtk_cmctree_set_line_style(GTK_CMCTREE(ctree), GTK_CMCTREE_LINES_NONE);
+       gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree),
+                            GTK_CMCTREE_EXPANDER_TRIANGLE);
 
        gtk_sctree_set_stripes(GTK_SCTREE(ctree), prefs_common.use_stripes_in_summaries);
        gtk_sctree_set_recursive_expand(GTK_SCTREE(ctree), FALSE);
@@ -511,8 +457,7 @@ static GtkWidget *folderview_ctree_create(FolderView *folderview)
 
        /* don't let title buttons take key focus */
        for (i = 0; i < N_FOLDER_COLS; i++) {
-               GTK_WIDGET_UNSET_FLAGS(GTK_CMCLIST(ctree)->column[i].button,
-                                      GTK_CAN_FOCUS);
+               gtkut_widget_set_can_focus(GTK_CMCLIST(ctree)->column[i].button, FALSE);
                gtk_cmclist_set_column_width(GTK_CMCLIST(ctree), col_pos[i],
                                   prefs_common.folder_col_size[i]);
                gtk_cmclist_set_column_visibility
@@ -525,15 +470,8 @@ static GtkWidget *folderview_ctree_create(FolderView *folderview)
        g_signal_connect(G_OBJECT(ctree), "button_press_event",
                         G_CALLBACK(folderview_button_pressed),
                         folderview);
-#ifndef MAEMO
        g_signal_connect(G_OBJECT(ctree), "popup-menu",
                         G_CALLBACK(folderview_popup_menu), folderview);
-#else
-       gtk_widget_tap_and_hold_setup(GTK_WIDGET(ctree), NULL, NULL,
-                       GTK_TAP_AND_HOLD_NONE | GTK_TAP_AND_HOLD_NO_INTERNALS);
-       g_signal_connect(G_OBJECT(ctree), "tap-and-hold",
-                        G_CALLBACK(folderview_popup_menu), folderview);
-#endif
        g_signal_connect(G_OBJECT(ctree), "button_release_event",
                         G_CALLBACK(folderview_button_released),
                         folderview);
@@ -589,6 +527,23 @@ void folderview_set_column_order(FolderView *folderview)
        FolderItem *sel_item = NULL, *op_item = NULL;
        GtkWidget *scrolledwin = folderview->scrolledwin;
 
+       if (folderview->drag_timer_id != 0) {
+               g_source_remove(folderview->drag_timer_id);
+               folderview->drag_timer_id = 0;
+       }
+       if (folderview->deferred_refresh_id != 0) {
+               g_source_remove(folderview->deferred_refresh_id);
+               folderview->deferred_refresh_id = 0;
+       }
+       if (folderview->scroll_timeout_id != 0) {
+               g_source_remove(folderview->scroll_timeout_id);
+               folderview->scroll_timeout_id = 0;
+       }
+       if (folderview->postpone_select_id != 0) {
+               g_source_remove(folderview->postpone_select_id);
+               folderview->postpone_select_id = 0;
+       }
+
        if (folderview->selected)
                sel_item = gtk_cmctree_node_get_row_data(GTK_CMCTREE(ctree), folderview->selected);
        if (folderview->opened)
@@ -652,7 +607,11 @@ FolderView *folderview_create(void)
        
        folderview->target_list = gtk_target_list_new(folderview_drag_types, 2);
        folderview_list = g_list_append(folderview_list, folderview);
-       folderview->deferred_refresh_id = -1;
+
+       folderview->drag_timer_id       = 0;
+       folderview->deferred_refresh_id = 0;
+       folderview->scroll_timeout_id   = 0;
+       folderview->postpone_select_id  = 0;
 
        return folderview;
 }
@@ -662,52 +621,52 @@ void folderview_init(FolderView *folderview)
        GtkWidget *ctree = folderview->ctree;
        GdkColor gdk_color;
 
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE, &inboxxpm, &inboxxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_HRM, &inboxhrmxpm, &inboxhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN, &inboxopenxpm, &inboxopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_HRM, &inboxopenhrmxpm, &inboxopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE, &outboxxpm, &outboxxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_HRM, &outboxhrmxpm, &outboxhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN, &outboxopenxpm, &outboxopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_HRM, &outboxopenhrmxpm, &outboxopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE, &folderxpm, &folderxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_HRM, &folderhrmxpm, &folderhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN, &folderopenxpm, &folderopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM, &folderopenhrmxpm, &folderopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN, &trashopenxpm, &trashopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_HRM, &trashopenhrmxpm, &trashopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE, &trashxpm, &trashxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_HRM, &trashhrmxpm, &trashhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE, &queuexpm, &queuexpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_HRM, &queuehrmxpm, &queuehrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN, &queueopenxpm, &queueopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_HRM, &queueopenhrmxpm, &queueopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DRAFTS_CLOSE, &draftsxpm, &draftsxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DRAFTS_OPEN, &draftsopenxpm, &draftsopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_NOSELECT, &noselectxpm, &noselectxpmmask);
-
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_MARK, &m_inboxxpm, &m_inboxxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_HRM_MARK, &m_inboxhrmxpm, &m_inboxhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_MARK, &m_inboxopenxpm, &m_inboxopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_HRM_MARK, &m_inboxopenhrmxpm, &m_inboxopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_MARK, &m_outboxxpm, &m_outboxxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_HRM_MARK, &m_outboxhrmxpm, &m_outboxhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_MARK, &m_outboxopenxpm, &m_outboxopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_HRM_MARK, &m_outboxopenhrmxpm, &m_outboxopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_MARK, &m_folderxpm, &m_folderxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_HRM_MARK, &m_folderhrmxpm, &m_folderhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_MARK, &m_folderopenxpm, &m_folderopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM_MARK, &m_folderopenhrmxpm, &m_folderopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_MARK, &m_trashopenxpm, &m_trashopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_HRM_MARK, &m_trashopenhrmxpm, &m_trashopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_MARK, &m_trashxpm, &m_trashxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_HRM_MARK, &m_trashhrmxpm, &m_trashhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_MARK, &m_queuexpm, &m_queuexpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_HRM_MARK, &m_queuehrmxpm, &m_queuehrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_MARK, &m_queueopenxpm, &m_queueopenxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_HRM_MARK, &m_queueopenhrmxpm, &m_queueopenhrmxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DRAFTS_CLOSE_MARK, &m_draftsxpm, &m_draftsxpmmask);
-       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DRAFTS_OPEN_MARK, &m_draftsopenxpm, &m_draftsopenxpmmask);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE, &inboxxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_HRM, &inboxhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN, &inboxopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_HRM, &inboxopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE, &outboxxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_HRM, &outboxhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN, &outboxopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_HRM, &outboxopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE, &folderxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_HRM, &folderhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_OPEN, &folderopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM, &folderopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN, &trashopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_HRM, &trashopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE, &trashxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_HRM, &trashhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE, &queuexpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_HRM, &queuehrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN, &queueopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_HRM, &queueopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DRAFTS_CLOSE, &draftsxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DRAFTS_OPEN, &draftsopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_NOSELECT, &noselectxpm);
+
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_MARK, &m_inboxxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_HRM_MARK, &m_inboxhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_MARK, &m_inboxopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_HRM_MARK, &m_inboxopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_MARK, &m_outboxxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_HRM_MARK, &m_outboxhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_MARK, &m_outboxopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_HRM_MARK, &m_outboxopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_MARK, &m_folderxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_HRM_MARK, &m_folderhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_MARK, &m_folderopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM_MARK, &m_folderopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_MARK, &m_trashopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_HRM_MARK, &m_trashopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_MARK, &m_trashxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_HRM_MARK, &m_trashhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_MARK, &m_queuexpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_HRM_MARK, &m_queuehrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_MARK, &m_queueopenxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_HRM_MARK, &m_queueopenhrmxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DRAFTS_CLOSE_MARK, &m_draftsxpm);
+       stock_pixbuf_gdk(ctree, STOCK_PIXMAP_DRAFTS_OPEN_MARK, &m_draftsopenxpm);
                        
        if (!normal_style) {
                PangoFontDescription *font_desc;
@@ -763,7 +722,7 @@ static gboolean folderview_defer_set(gpointer data)
        debug_print("doing deferred folderview_set now\n");
        folderview_set(folderview);
 
-       folderview->deferred_refresh_id = -1;
+       folderview->deferred_refresh_id = 0;
        return FALSE;
 }
 
@@ -777,7 +736,7 @@ void folderview_set(FolderView *folderview)
                return;
 
        if (mainwin->lock_count) {
-               if (folderview->deferred_refresh_id == -1)
+               if (folderview->deferred_refresh_id == 0)
                        folderview->deferred_refresh_id = 
                                g_timeout_add(500, folderview_defer_set, folderview);
                debug_print("deferred folderview_set\n");
@@ -851,7 +810,7 @@ static void mark_all_read_cb(GtkAction *action, gpointer data)
        &&  prefs_common.ask_mark_all_read) {
                val = alertpanel_full(_("Mark all as read"),
                        _("Do you really want to mark all mails in this "
-                         "folder as read ?"), GTK_STOCK_NO, GTK_STOCK_YES, NULL,
+                         "folder as read?"), GTK_STOCK_NO, GTK_STOCK_YES, NULL,
                          TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
 
                if ((val & ~G_ALERTDISABLE) != G_ALERTALTERNATE)
@@ -880,7 +839,7 @@ static void folderview_select_node(FolderView *folderview, GtkCMCTreeNode *node)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
 
-       g_return_if_fail(node != NULL);
+       cm_return_if_fail(node != NULL);
 
        if (folderview->open_folder) {
                return;
@@ -889,8 +848,9 @@ static void folderview_select_node(FolderView *folderview, GtkCMCTreeNode *node)
        folderview->open_folder = TRUE;
        gtkut_ctree_set_focus_row(ctree, node);
        gtk_cmctree_select(ctree, node);
-       if (folderview->summaryview->folder_item &&
-           folderview->summaryview->folder_item->total_msgs > 0)
+       if ((folderview->summaryview->folder_item &&
+           folderview->summaryview->folder_item->total_msgs > 0) ||
+            prefs_common.layout_mode == SMALL_LAYOUT)
                summary_grab_focus(folderview->summaryview);
        else
                gtk_widget_grab_focus(folderview->ctree);
@@ -1072,11 +1032,11 @@ static void folderview_set_folders(FolderView *folderview)
 static gchar *get_scan_str(FolderItem *item)
 {
        if (item->path)
-               return g_strdup_printf(_("Scanning folder %s%c%s ..."),
+               return g_strdup_printf(_("Scanning folder %s%c%s..."),
                                      item->folder->name, G_DIR_SEPARATOR,
                                      item->path);
        else
-               return g_strdup_printf(_("Scanning folder %s ..."),
+               return g_strdup_printf(_("Scanning folder %s..."),
                                      item->folder->name);      
 }
 static void folderview_scan_tree_func(Folder *folder, FolderItem *item,
@@ -1102,7 +1062,7 @@ void folderview_rescan_tree(Folder *folder, gboolean rebuild)
        GtkAdjustment *pos = NULL;
        gint height = 0;
 
-       g_return_if_fail(folder != NULL);
+       cm_return_if_fail(folder != NULL);
 
        if (!folder->klass->scan_tree) return;
 
@@ -1128,7 +1088,7 @@ void folderview_rescan_tree(Folder *folder, gboolean rebuild)
        if (folderview) {
                pos = gtk_scrolled_window_get_vadjustment(
                                        GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-               height = pos->value;
+               height = gtk_adjustment_get_value(pos);
        }
 
        folder_set_ui_func(folder, folderview_scan_tree_func, NULL);
@@ -1147,47 +1107,6 @@ void folderview_rescan_tree(Folder *folder, gboolean rebuild)
        inc_unlock();
 }
 
-void folderview_fast_rescan_tree(Folder *folder)
-{
-       GtkWidget *window;
-       MainWindow *mainwin = mainwindow_get_mainwindow();
-       FolderView *folderview = NULL;
-       GtkAdjustment *pos = NULL;
-       gint height = 0;
-
-       g_return_if_fail(folder != NULL);
-
-       if (!folder->klass->scan_tree) return;
-
-       inc_lock();
-
-       window = label_window_create(_("Scanning folder tree..."));
-
-       if (mainwin)
-               folderview = mainwin->folderview;
-       
-       if (folderview) {
-               pos = gtk_scrolled_window_get_vadjustment(
-                                       GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-               height = pos->value;
-       }
-
-       folder_set_ui_func(folder, folderview_scan_tree_func, NULL);
-       folder_fast_scan_tree(folder);
-       folder_set_ui_func(folder, NULL, NULL);
-
-       folderview_set_all();
-
-       if (folderview) {
-               pos = gtk_scrolled_window_get_vadjustment(
-                                       GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-               gtk_adjustment_set_value(pos, height);
-               gtk_adjustment_changed(pos);
-       }
-       label_window_destroy(window);
-       inc_unlock();
-}
-
 /** folderview_check_new()
  *  Scan and update the folder and return the 
  *  count the number of new messages since last check. 
@@ -1483,10 +1402,8 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
        GtkStyle *style = NULL;
        GtkStyle *color_style = NULL;
        FolderItem *item;
-       GdkPixmap *xpm, *openxpm;
-       GdkBitmap *mask, *openmask;
-       static GdkPixmap *searchicon;
-       static GdkBitmap *searchmask;
+       GdkPixbuf *xpm, *openxpm;
+       static GdkPixbuf *searchicon;
        gboolean mark = FALSE;
        gchar *name;
        gchar *str;
@@ -1497,7 +1414,7 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
        SpecialFolderItemType stype;
        
        item = gtk_cmctree_node_get_row_data(ctree, node);
-       g_return_if_fail(item != NULL);
+       cm_return_if_fail(item != NULL);
 
        if (!GTK_CMCTREE_ROW(node)->expanded)
                mark = folderview_have_marked_children(folderview, item);
@@ -1517,80 +1434,57 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
        }
        switch (stype) {
        case F_INBOX:
-               if (item->hide_read_msgs) {
+               if (item->hide_read_msgs || item->hide_read_threads) {
                        xpm = mark?m_inboxhrmxpm:inboxhrmxpm;
-                       mask = mark?m_inboxhrmxpmmask:inboxhrmxpmmask;
                        openxpm = mark?m_inboxopenhrmxpm:inboxopenhrmxpm;
-                       openmask = mark?m_inboxopenhrmxpmmask:inboxopenhrmxpmmask;
                } else {
                        xpm = mark?m_inboxxpm:inboxxpm;
-                       mask = mark?m_inboxxpmmask:inboxxpmmask;
                        openxpm = mark?m_inboxopenxpm:inboxopenxpm;
-                       openmask = mark?m_inboxopenxpmmask:inboxopenxpmmask;
                }
                break;
        case F_OUTBOX:
-               if (item->hide_read_msgs) {
+               if (item->hide_read_msgs || item->hide_read_threads) {
                        xpm = mark?m_outboxhrmxpm:outboxhrmxpm;
-                       mask = mark?m_outboxhrmxpmmask:outboxhrmxpmmask;
                        openxpm = mark?m_outboxopenhrmxpm:outboxopenhrmxpm;
-                       openmask = mark?m_outboxopenhrmxpmmask:outboxopenhrmxpmmask;
                } else {
                        xpm = mark?m_outboxxpm:outboxxpm;
-                       mask = mark?m_outboxxpmmask:outboxxpmmask;
                        openxpm = mark?m_outboxopenxpm:outboxopenxpm;
-                       openmask = mark?m_outboxopenxpmmask:outboxopenxpmmask;
                }
                break;
        case F_QUEUE:
-               if (item->hide_read_msgs) {
+               if (item->hide_read_msgs || item->hide_read_threads) {
                        xpm = mark?m_queuehrmxpm:queuehrmxpm;
-                       mask = mark?m_queuehrmxpmmask:queuehrmxpmmask;
                        openxpm = mark?m_queueopenhrmxpm:queueopenhrmxpm;
-                       openmask = mark?m_queueopenhrmxpmmask:queueopenhrmxpmmask;
                } else {
                        xpm = mark?m_queuexpm:queuexpm;
-                       mask = mark?m_queuexpmmask:queuexpmmask;
                        openxpm = mark?m_queueopenxpm:queueopenxpm;
-                       openmask = mark?m_queueopenxpmmask:queueopenxpmmask;
                }
                break;
        case F_TRASH:
-               if (item->hide_read_msgs) {
+               if (item->hide_read_msgs || item->hide_read_threads) {
                        xpm = mark?m_trashhrmxpm:trashhrmxpm;
-                       mask = mark?m_trashhrmxpmmask:trashhrmxpmmask;
                        openxpm = mark?m_trashopenhrmxpm:trashopenhrmxpm;
-                       openmask = mark?m_trashopenhrmxpmmask:trashopenhrmxpmmask;
                } else {
                        xpm = mark?m_trashxpm:trashxpm;
-                       mask = mark?m_trashxpmmask:trashxpmmask;
                        openxpm = mark?m_trashopenxpm:trashopenxpm;
-                       openmask = mark?m_trashopenxpmmask:trashopenxpmmask;
                }
                break;
        case F_DRAFT:
                xpm = mark?m_draftsxpm:draftsxpm;
-               mask = mark?m_draftsxpmmask:draftsxpmmask;
                openxpm = mark?m_draftsopenxpm:draftsopenxpm;
-               openmask = mark?m_draftsopenxpmmask:draftsopenxpmmask;
                break;
        default:
-               if (item->hide_read_msgs) {
+               if (item->hide_read_msgs || item->hide_read_threads) {
                        xpm = mark?m_folderhrmxpm:folderhrmxpm;
-                       mask = mark?m_folderhrmxpmmask:folderhrmxpmmask;
                        openxpm = mark?m_folderopenhrmxpm:folderopenhrmxpm;
-                       openmask = mark?m_folderopenhrmxpmmask:folderopenhrmxpmmask;
                } else {
                        xpm = mark?m_folderxpm:folderxpm;
-                       mask = mark?m_folderxpmmask:folderxpmmask;
                        openxpm = mark?m_folderopenxpm:folderopenxpm;
-                       openmask = mark?m_folderopenxpmmask:folderopenxpmmask;
                }
        }
        
        if (item->no_select) {
                xpm = openxpm = noselectxpm;
-               mask = openmask = noselectxpmmask;
        }
 
        name = folder_item_get_name(item);
@@ -1607,11 +1501,10 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
 
        if (item->search_match) {
                if (!searchicon) {
-                       stock_pixmap_gdk(folderview->ctree, STOCK_PIXMAP_QUICKSEARCH,
-                        &searchicon, &searchmask);
+                       stock_pixbuf_gdk(folderview->ctree, STOCK_PIXMAP_QUICKSEARCH,
+                        &searchicon);
                }
                xpm = openxpm = searchicon;
-               mask = openmask = searchmask;
        }
 
        str = NULL;
@@ -1626,7 +1519,7 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
                                                        (add_unread_mark || add_sub_match_mark) ? "+" : "", 
                                                        (item->unreadmarked_msgs > 0) ? "!" : "");
                        }
-       } else {
+               } else {
                        if (prefs_common.display_folder_unread == 1) {
                                if (item->unread_msgs > 0) {
                                        /* show unread number and signs */
@@ -1655,14 +1548,24 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
                }
        }
        if (str == NULL) {
-               /* last fallback, folder name only or with ! sign */
-               str = g_strdup_printf("%s%s",
-                                       name, (item->unreadmarked_msgs > 0) ? " (!)" : "");
+               /* last fallback, folder name only or with +! sign */
+               if (item->unreadmarked_msgs > 0 && add_sub_match_mark) {
+                       str = g_strdup_printf("%s%s",
+                                               name, " (+!)");
+               } else if (item->unreadmarked_msgs > 0) {
+                       str = g_strdup_printf("%s%s",
+                                               name, " (!)");
+               } else if (add_sub_match_mark) {
+                       str = g_strdup_printf("%s%s",
+                                               name, " (+)");
+               } else {
+                       str = g_strdup_printf("%s", name);
+               }
        }
-               gtk_sctree_set_node_info(ctree, node, str, FOLDER_SPACING,
-                                       xpm, mask, openxpm, openmask,
-                                       FALSE, GTK_CMCTREE_ROW(node)->expanded);
-               g_free(str);
+       gtk_cmctree_set_node_info(ctree, node, str, FOLDER_SPACING,
+                               xpm, openxpm, 
+                               FALSE, GTK_CMCTREE_ROW(node)->expanded);
+       g_free(str);
        g_free(name);
 
        if (!folder_item_parent(item)) {
@@ -1676,12 +1579,21 @@ static void folderview_update_node(FolderView *folderview, GtkCMCTreeNode *node)
        }
 
        if (folder_has_parent_of_type(item, F_OUTBOX) ||
-           folder_has_parent_of_type(item, F_DRAFT) ||
            folder_has_parent_of_type(item, F_TRASH)) {
                use_bold = use_color = FALSE;
        } else if (folder_has_parent_of_type(item, F_QUEUE)) {
-               /* highlight queue folder if there are any messages */
-               use_bold = use_color = (item->total_msgs > 0);
+               GSList *list = folder_item_get_msg_list(item);
+               GSList *cur;
+               use_bold = use_color = FALSE;
+               for (cur = list; cur; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       if (!MSG_IS_DELETED(msginfo->flags)) {
+                               /* highlight queue folder if there are any messages */
+                               use_bold = use_color = TRUE;
+                               break;
+                       }
+               }
+               procmsg_msg_list_free(list);
        } else {
                /* if unread messages exist, print with bold font */
                use_bold = (item->unread_msgs > 0|| item->new_msgs > 0) 
@@ -1739,14 +1651,14 @@ void folderview_update_search_icon(FolderItem *item, gboolean matches)
        GtkCMCTree *ctree;
        GtkCMCTreeNode *node;
 
-       g_return_if_fail(item != NULL);
+       cm_return_if_fail(item != NULL);
 
        for (list = folderview_list; list != NULL; list = list->next) {
                folderview = (FolderView *)list->data;
                ctree = GTK_CMCTREE(folderview->ctree);
 
                node = gtk_cmctree_find_by_row_data(ctree, NULL, item);
-               if (node) {
+               if (node && item->search_match != matches) {
                        item->search_match = matches;
                        folderview_update_node(folderview, node);
                }
@@ -1759,9 +1671,9 @@ static gboolean folderview_update_item_claws(gpointer source, gpointer data)
        FolderView *folderview = (FolderView *)data;
        GtkCMCTree *ctree;
        GtkCMCTreeNode *node;
-       g_return_val_if_fail(update_info != NULL, TRUE);
-       g_return_val_if_fail(update_info->item != NULL, TRUE);
-       g_return_val_if_fail(folderview != NULL, FALSE);
+       cm_return_val_if_fail(update_info != NULL, TRUE);
+       cm_return_val_if_fail(update_info->item != NULL, TRUE);
+       cm_return_val_if_fail(folderview != NULL, FALSE);
 
        ctree = GTK_CMCTREE(folderview->ctree);
 
@@ -1774,7 +1686,7 @@ static gboolean folderview_update_item_claws(gpointer source, gpointer data)
                if ((update_info->update_flags & F_ITEM_UPDATE_CONTENT) && 
                     update_info->item == folderview->summaryview->folder_item &&
                     update_info->item != NULL)
-                       if (!quicksearch_is_active(folderview->summaryview->quicksearch))
+                       if (!quicksearch_has_sat_predicate(folderview->summaryview->quicksearch))
                                summary_show(folderview->summaryview, update_info->item);
        }
        
@@ -1788,7 +1700,7 @@ static gboolean folderview_gnode_func(GtkCMCTree *ctree, guint depth,
        FolderView *folderview = (FolderView *)data;
        FolderItem *item = FOLDER_ITEM(gnode->data);
 
-       g_return_val_if_fail(item != NULL, FALSE);
+       cm_return_val_if_fail(item != NULL, FALSE);
 
        gtk_cmctree_node_set_row_data(ctree, cnode, item);
        folderview_update_node(folderview, cnode);
@@ -1804,7 +1716,7 @@ static void folderview_expand_func(GtkCMCTree *ctree, GtkCMCTreeNode *node,
 
        if (GTK_CMCTREE_ROW(node)->children) {
                item = gtk_cmctree_node_get_row_data(ctree, node);
-               g_return_if_fail(item != NULL);
+               cm_return_if_fail(item != NULL);
 
                if (!item->collapsed)
                        gtk_cmctree_expand(ctree, node);
@@ -1871,7 +1783,7 @@ static void folderview_append_folder(FolderView *folderview, Folder *folder)
        GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
        GtkCMCTreeNode *root;
 
-       g_return_if_fail(folder != NULL);
+       cm_return_if_fail(folder != NULL);
 
        root = gtk_sctree_insert_gnode(ctree, NULL, NULL, folder->node,
                                      folderview_gnode_func, folderview);
@@ -1899,8 +1811,8 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row,
        folderview->ui_manager = ui_manager;
        item = folderview_get_selected_item(folderview);
 
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
        folder = item->folder;
 
        fpopup = g_hash_table_lookup(folderview_popups, folder->klass->idstr);
@@ -2074,10 +1986,10 @@ static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
                return FALSE;
 
        switch (event->keyval) {
-       case GDK_Right:
+       case GDK_KEY_Right:
 #ifndef GENERIC_UMPC
-       case GDK_Return:
-       case GDK_KP_Enter:
+       case GDK_KEY_Return:
+       case GDK_KEY_KP_Enter:
 #endif
                if (folderview->selected) {
                        folderview_select_node(folderview,
@@ -2085,7 +1997,7 @@ static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
                }
                break;
 #ifdef GENERIC_UMPC
-       case GDK_Return:
+       case GDK_KEY_Return:
                if (folderview->selected && GTK_CMCTREE_ROW(folderview->selected)->children) {
                        gtk_cmctree_toggle_expansion(
                                GTK_CMCTREE(folderview->ctree),
@@ -2093,7 +2005,7 @@ static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
                }
                break;  
 #endif
-       case GDK_space:
+       case GDK_KEY_space:
                BREAK_ON_MODIFIER_KEY();
                if (folderview->selected) {
                        if (folderview->opened == folderview->selected &&
@@ -2124,6 +2036,8 @@ static gboolean postpone_select(void *data)
 {
        PostponedSelectData *psdata = (PostponedSelectData *)data;
        debug_print("trying again\n");
+
+       psdata->folderview->postpone_select_id = 0;
        psdata->folderview->open_folder = TRUE;
        main_window_cursor_normal(psdata->folderview->mainwin);
        STATUSBAR_POP(psdata->folderview->mainwin);
@@ -2141,7 +2055,7 @@ void folderview_close_opened(FolderView *folderview)
                olditem = gtk_cmctree_node_get_row_data(GTK_CMCTREE(folderview->ctree), 
                                                      folderview->opened);
                if (olditem) {
-                       gchar *buf = g_strdup_printf(_("Closing Folder %s..."), 
+                       gchar *buf = g_strdup_printf(_("Closing folder %s..."), 
                                olditem->path ? olditem->path:olditem->name);
                        /* will be null if we just moved the previously opened folder */
                        STATUSBAR_PUSH(folderview->mainwin, buf);
@@ -2228,7 +2142,7 @@ static void folderview_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
                gtk_cmctree_expand(ctree, row);
 
        /* ungrab the mouse event */
-       if (GTK_WIDGET_HAS_GRAB(ctree)) {
+       if (gtk_widget_has_grab(GTK_WIDGET(ctree))) {
                gtk_grab_remove(GTK_WIDGET(ctree));
                if (gdk_pointer_is_grabbed())
                        gdk_pointer_ungrab(GDK_CURRENT_TIME);
@@ -2236,7 +2150,7 @@ static void folderview_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
 
        /* Open Folder */
        /* TODO: wwp: avoid displaying (null) in the status bar */
-       buf = g_strdup_printf(_("Opening Folder %s..."), item->path ? 
+       buf = g_strdup_printf(_("Opening folder %s..."), item->path ? 
                                        item->path : "(null)");
        debug_print("%s\n", buf);
        STATUSBAR_PUSH(folderview->mainwin, buf);
@@ -2270,7 +2184,9 @@ static void folderview_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
                        item->path ? item->path:item->name);
                folderview->open_folder = FALSE;
                can_select = TRUE;
-               g_timeout_add(500, postpone_select, data);
+               if (folderview->postpone_select_id != 0)
+                       g_source_remove(folderview->postpone_select_id);
+               folderview->postpone_select_id = g_timeout_add(500, postpone_select, data);
                END_TIMING();
                return;
        }
@@ -2307,7 +2223,7 @@ static void folderview_tree_expanded(GtkCMCTree *ctree, GtkCMCTreeNode *node,
        FolderItem *item;
 
        item = gtk_cmctree_node_get_row_data(ctree, node);
-       g_return_if_fail(item != NULL);
+       cm_return_if_fail(item != NULL);
        item->collapsed = FALSE;
        folderview_update_node(folderview, node);
 }
@@ -2318,7 +2234,7 @@ static void folderview_tree_collapsed(GtkCMCTree *ctree, GtkCMCTreeNode *node,
        FolderItem *item;
 
        item = gtk_cmctree_node_get_row_data(ctree, node);
-       g_return_if_fail(item != NULL);
+       cm_return_if_fail(item != NULL);
        item->collapsed = TRUE;
        folderview_update_node(folderview, node);
 }
@@ -2339,27 +2255,6 @@ static void folderview_col_resized(GtkCMCList *clist, gint column, gint width,
        prefs_common.folder_col_size[type] = width;
 }
 
-static void folderview_create_folder_node_recursive(FolderView *folderview, FolderItem *item)
-{
-       GNode *srcnode;
-
-       folderview_create_folder_node(folderview, item);
-
-       if (!item || !item->folder || !item->folder->node)
-               return;
-
-       srcnode = item->folder->node;   
-       srcnode = g_node_find(srcnode, G_PRE_ORDER, G_TRAVERSE_ALL, item);
-       srcnode = srcnode->children;
-       while (srcnode != NULL) {
-               if (srcnode && srcnode->data) {
-                       FolderItem *next_item = (FolderItem*) srcnode->data;
-                       folderview_create_folder_node_recursive(folderview, next_item);
-               }
-               srcnode = srcnode->next;
-       }
-}
-
 static void folderview_create_folder_node(FolderView *folderview, FolderItem *item)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
@@ -2377,8 +2272,8 @@ static void folderview_create_folder_node(FolderView *folderview, FolderItem *it
        text[col_pos[F_COL_FOLDER]] = item->name;
        node = gtk_sctree_insert_node(ctree, parent_node, NULL, text,
                                     FOLDER_SPACING,
-                                    folderxpm, folderxpmmask,
-                                    folderopenxpm, folderopenxpmmask,
+                                    folderxpm,
+                                    folderopenxpm,
                                     FALSE, FALSE);
        gtk_cmctree_expand(ctree, parent_node);
        gtk_cmctree_node_set_row_data(ctree, node, item);
@@ -2406,8 +2301,8 @@ static void folderview_empty_trash_cb(GtkAction *action, gpointer data)
 
        if (!folderview->selected) return;
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
 
        if (NULL != (ac = account_find_from_item(item)))
                special_trash = account_get_special_folder(ac, F_TRASH);
@@ -2449,8 +2344,8 @@ static void folderview_send_queue_cb(GtkAction *action, gpointer data)
 
        if (!folderview->selected) return;
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
 
        if (NULL != (ac = account_find_from_item(item)))
                special_queue = account_get_special_folder(ac, F_QUEUE);
@@ -2509,8 +2404,8 @@ static void folderview_run_processing_cb(GtkAction *action, gpointer data)
        if (!folderview->selected) return;
 
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
 
        item->processing_pending = TRUE;
        folder_item_apply_processing(item);
@@ -2526,8 +2421,8 @@ static void folderview_property_cb(GtkAction *action, gpointer data)
        if (!folderview->selected) return;
 
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
 
        prefs_folder_item_open(item);
 }
@@ -2555,22 +2450,17 @@ static void folderview_recollapse_nodes(FolderView *folderview, GtkCMCTreeNode *
 void folderview_move_folder(FolderView *folderview, FolderItem *from_folder,
                            FolderItem *to_folder, gboolean copy)
 {
-       FolderItem *from_parent = NULL;
        FolderItem *new_folder = NULL;
-       GtkCMCTreeNode *src_node = NULL;
        gchar *buf;
        gint status;
 
-       g_return_if_fail(folderview != NULL);
-       g_return_if_fail(from_folder != NULL);
-       g_return_if_fail(to_folder != NULL);
+       cm_return_if_fail(folderview != NULL);
+       cm_return_if_fail(from_folder != NULL);
+       cm_return_if_fail(to_folder != NULL);
 
-       src_node = gtk_cmctree_find_by_row_data(GTK_CMCTREE(folderview->ctree), NULL, from_folder);
-       from_parent = folder_item_parent(from_folder);
-       
        if (prefs_common.warn_dnd) {
-               buf = g_strdup_printf(copy ? _("Do you really want to copy folder '%s' in '%s' ?"):
-                                            _("Do you really want to make folder '%s' a subfolder of '%s' ?"), 
+               buf = g_strdup_printf(copy ? _("Do you really want to copy folder '%s' in '%s'?"):
+                                            _("Do you really want to make folder '%s' a subfolder of '%s'?"), 
                                        from_folder->name, to_folder->name);
                status = alertpanel_full(copy ? _("Copy folder"):_("Move folder"), buf,
                                         GTK_STOCK_NO, GTK_STOCK_YES, NULL, TRUE,
@@ -2671,8 +2561,8 @@ static void folderview_processing_cb(GtkAction *action, gpointer data)
        if (!folderview->selected) return;
 
        item = gtk_cmctree_node_get_row_data(ctree, folderview->selected);
-       g_return_if_fail(item != NULL);
-       g_return_if_fail(item->folder != NULL);
+       cm_return_if_fail(item != NULL);
+       cm_return_if_fail(item->folder != NULL);
 
        id = folder_item_get_identifier(item);
        title = g_strdup_printf (_("Processing configuration for folder %s"), id);
@@ -2703,7 +2593,9 @@ void folderview_set_target_folder_color(gint color_op)
 static gchar *last_smallfont = NULL;
 static gchar *last_normalfont = NULL;
 static gchar *last_boldfont = NULL;
-void folderview_reflect_prefs_pixmap_theme(FolderView *folderview)
+static gboolean last_derive = 0;
+
+void folderview_reinit_fonts(FolderView *folderview)
 {
        /* force reinit */
        g_free(last_smallfont);
@@ -2721,11 +2613,12 @@ void folderview_reflect_prefs(void)
        FolderItem *item = folderview_get_selected_item(folderview);
        GtkAdjustment *pos = gtk_scrolled_window_get_vadjustment(
                                GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-       gint height = pos->value;
+       gint height = gtk_adjustment_get_value(pos);
 
        if (!last_smallfont || strcmp(last_smallfont, SMALL_FONT) ||
                        !last_normalfont || strcmp(last_normalfont, NORMAL_FONT) ||
-                       !last_boldfont || strcmp(last_boldfont, BOLD_FONT))
+                       !last_boldfont || strcmp(last_boldfont, BOLD_FONT) ||
+                       last_derive != prefs_common.derive_from_normal_font)
                update_font = TRUE;
 
        g_free(last_smallfont);
@@ -2734,6 +2627,7 @@ void folderview_reflect_prefs(void)
        last_normalfont = g_strdup(NORMAL_FONT);
        g_free(last_boldfont);
        last_boldfont = g_strdup(BOLD_FONT);
+       last_derive = prefs_common.derive_from_normal_font;
 
        if (update_font) {              
                normal_style = normal_color_style = bold_style = 
@@ -2771,13 +2665,13 @@ void folderview_reflect_prefs(void)
 
 static void drag_state_stop(FolderView *folderview)
 {
-       if (folderview->drag_timer)
-               g_source_remove(folderview->drag_timer);
-       folderview->drag_timer = 0;
+       if (folderview->drag_timer_id)
+               g_source_remove(folderview->drag_timer_id);
+       folderview->drag_timer_id = 0;
        folderview->drag_node = NULL;
 }
 
-static gint folderview_defer_expand(FolderView *folderview)
+static gboolean folderview_defer_expand(FolderView *folderview)
 {
        if (folderview->drag_node) {
                folderview_recollapse_nodes(folderview, folderview->drag_node);
@@ -2788,7 +2682,7 @@ static gint folderview_defer_expand(FolderView *folderview)
                }
        }
        folderview->drag_item  = NULL;
-       folderview->drag_timer = 0;
+       folderview->drag_timer_id = 0;
        return FALSE;
 }
 
@@ -2799,9 +2693,9 @@ static void drag_state_start(FolderView *folderview, GtkCMCTreeNode *node, Folde
         * we need to call drag_state_stop() */
        drag_state_stop(folderview);
        /* request expansion */
-       if (0 != (folderview->drag_timer = g_timeout_add
+       if (0 != (folderview->drag_timer_id = g_timeout_add
                        (prefs_common.hover_timeout, 
-                        (GtkFunction)folderview_defer_expand,
+                        (GSourceFunc)folderview_defer_expand,
                         folderview))) {
                folderview->drag_node = node;
                folderview->drag_item = item;
@@ -2813,7 +2707,7 @@ static void folderview_start_drag(GtkWidget *widget, gint button, GdkEvent *even
 {
        GdkDragContext *context;
 
-       g_return_if_fail(folderview != NULL);
+       cm_return_if_fail(folderview != NULL);
        if (folderview->selected == NULL) return;
        if (folderview->nodes_to_recollapse) 
                g_slist_free(folderview->nodes_to_recollapse);
@@ -2842,7 +2736,7 @@ static void folderview_drag_data_get(GtkWidget        *widget,
                        if (item) {
                                source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
                                gtk_selection_data_set(selection_data,
-                                                      selection_data->target, 8,
+                                                      gtk_selection_data_get_target(selection_data), 8,
                                                       source, strlen(source));
                                break;
                        } else
@@ -2861,11 +2755,11 @@ static gboolean folderview_update_folder(gpointer source, gpointer userdata)
 
        hookdata = source;
        folderview = (FolderView *) userdata;   
-       g_return_val_if_fail(hookdata != NULL, FALSE);
-       g_return_val_if_fail(folderview != NULL, FALSE);
+       cm_return_val_if_fail(hookdata != NULL, FALSE);
+       cm_return_val_if_fail(folderview != NULL, FALSE);
 
        ctree = folderview->ctree;
-       g_return_val_if_fail(ctree != NULL, FALSE);
+       cm_return_val_if_fail(ctree != NULL, FALSE);
 
        if (hookdata->update_flags & FOLDER_ADD_FOLDERITEM)
                folderview_create_folder_node(folderview, hookdata->item);
@@ -2890,6 +2784,30 @@ static gboolean folderview_update_folder(gpointer source, gpointer userdata)
        return FALSE;
 }
 
+static gboolean folderview_dnd_scroll_cb(gpointer data)
+{
+       FolderView *folderview = (FolderView *)data;
+       GtkAdjustment *pos = gtk_scrolled_window_get_vadjustment(
+                               GTK_SCROLLED_WINDOW(folderview->scrolledwin));
+       gint new_val = (int)gtk_adjustment_get_value(pos) + folderview->scroll_value;
+       gint max = (int)gtk_adjustment_get_upper(pos) -
+               (int)gtk_adjustment_get_page_size(pos);
+
+       if (folderview->scroll_value == 0) {
+               folderview->scroll_timeout_id = 0;
+               return FALSE;
+       }
+
+       if (folderview->scroll_value > 0 && new_val > max) {
+               new_val = max;
+       } else if (folderview->scroll_value < 0 && new_val < 0) {
+               new_val = 0;
+       }
+       gtk_adjustment_set_value(pos, new_val);
+       
+       return TRUE;
+}
+
 static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                                          GdkDragContext *context,
                                          gint            x,
@@ -2903,22 +2821,29 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
        gboolean acceptable = FALSE;
        GtkAdjustment *pos = gtk_scrolled_window_get_vadjustment(
                                GTK_SCROLLED_WINDOW(folderview->scrolledwin));
-       int height = (int)pos->page_size;
-       int total_height = (int)pos->upper;
-       int vpos = (int) pos->value;
+       int height = (int)gtk_adjustment_get_page_size(pos);
+       int total_height = (int)gtk_adjustment_get_upper(pos);
+       int vpos = (int)gtk_adjustment_get_value(pos);
        int offset = prefs_common.show_col_headers ? 24:0;
-       
+       int dist;
+
        if (gtk_cmclist_get_selection_info
                (GTK_CMCLIST(widget), x - offset, y - offset, &row, &column)) {
                GtkWidget *srcwidget;
 
-               if (y > height - 24 && height + vpos < total_height) {
-                       gtk_adjustment_set_value(pos, (vpos+5 > total_height ? total_height : vpos+5));
-                       gtk_adjustment_changed(pos);
+               if (y > height - (48 - offset) && height + vpos < total_height) {
+                       dist = -(height - (48 - offset) - y);
+                       folderview->scroll_value = 1.41f * (1+(dist / 6));
+               } else if (y < 72 - (24 - offset) && y >= 0) {
+                       dist = 72 - (24 - offset) - y;
+                       folderview->scroll_value = -1.41f * (1+(dist / 6));
+               } else {
+                       folderview->scroll_value = 0;
                }
-               if (y < 48 && y > 0) {
-                       gtk_adjustment_set_value(pos, (vpos-5 < 0 ? 0 : vpos-5));
-                       gtk_adjustment_changed(pos);
+               if (folderview->scroll_value != 0 && folderview->scroll_timeout_id == 0) {
+                       folderview->scroll_timeout_id = 
+                               g_timeout_add(30, folderview_dnd_scroll_cb,
+                                             folderview);
                }
 
                node = gtk_cmctree_node_nth(GTK_CMCTREE(widget), row);
@@ -2967,7 +2892,7 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                        (G_OBJECT(widget),
                         G_CALLBACK(folderview_selected), folderview);
                gdk_drag_status(context, 
-                                       (context->actions == GDK_ACTION_COPY ?
+                                       (gdk_drag_context_get_actions(context) == GDK_ACTION_COPY ?
                                        GDK_ACTION_COPY : GDK_ACTION_MOVE) , time);
        } else {
                if (folderview->opened)
@@ -2984,6 +2909,7 @@ static void folderview_drag_leave_cb(GtkWidget      *widget,
                                     FolderView     *folderview)
 {
        drag_state_stop(folderview);
+       folderview->scroll_value = 0;
        gtk_cmctree_select(GTK_CMCTREE(widget), folderview->opened);
 }
 
@@ -3050,9 +2976,12 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
        GtkCMCTreeNode *node;
        int offset = prefs_common.show_col_headers ? 24:0;
 
+       folderview->scroll_value = 0;
+
        if (info == TARGET_DUMMY) {
                drag_state_stop(folderview);
-               if ((void *)strstr(data->data, "FROM_OTHER_FOLDER") != (void *)data->data) {
+               const gchar *ddata = (const gchar *)gtk_selection_data_get_data(data);
+               if ((gchar *)strstr(ddata, "FROM_OTHER_FOLDER") != ddata) {
                        /* comes from summaryview */
                        if (gtk_cmclist_get_selection_info
                                (GTK_CMCLIST(widget), x - offset, y - offset, &row, &column) == 0)
@@ -3073,7 +3002,7 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                                return;
                        }
                        if (item && src_item) {
-                               switch (drag_context->action) {
+                               switch (gdk_drag_context_get_selected_action(drag_context)) {
                                case GDK_ACTION_COPY:
                                        summary_copy_selected_to(folderview->summaryview, item);
                                        gtk_drag_finish(drag_context, TRUE, FALSE, time);
@@ -3093,9 +3022,10 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                        /* comes from folderview */
                        char *source;
                        gboolean folder_is_normal = TRUE;
-                       gboolean copy = (drag_context->action == GDK_ACTION_COPY);
+                       gboolean copy = (GDK_ACTION_COPY ==
+                               gdk_drag_context_get_selected_action(drag_context));
 
-                       source = data->data + 17;
+                       source = (char *)gtk_selection_data_get_data(data) + 17;
                        if (gtk_cmclist_get_selection_info
                            (GTK_CMCLIST(widget), x - offset, y - offset, &row, &column) == 0
                            || *source == 0) {
@@ -3139,7 +3069,8 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                        debug_print("no item\n");
                        return;
                }
-               folderview_finish_dnd(data->data, drag_context, time, item);
+               folderview_finish_dnd(gtk_selection_data_get_data(data),
+                       drag_context, time, item);
        }
 }
 
@@ -3148,6 +3079,7 @@ static void folderview_drag_end_cb(GtkWidget          *widget,
                                    FolderView      *folderview)
 {
        drag_state_stop(folderview);
+       folderview->scroll_value = 0;
        g_slist_free(folderview->nodes_to_recollapse);
        folderview->nodes_to_recollapse = NULL;
 }