2005-08-05 [paul] 1.9.13cvs14
[claws.git] / src / summaryview.c
index b5bf69c10fda26220aed8321eada6c72cf5243ab..994622c44e475fb37f10ff58fed5dc623d8e0587 100644 (file)
@@ -630,40 +630,11 @@ SummaryView *summary_create(void)
        return summaryview;
 }
 
-void summary_init(SummaryView *summaryview)
+static void summary_set_fonts(SummaryView *summaryview)
 {
-       GtkWidget *pixmap;
        PangoFontDescription *font_desc;
        gint size;
 
-       gtk_widget_realize(summaryview->ctree);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
-                        &markxpm, &markxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
-                        &deletedxpm, &deletedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
-                        &newxpm, &newxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
-                        &unreadxpm, &unreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
-                        &repliedxpm, &repliedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
-                        &forwardedxpm, &forwardedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
-                        &clipxpm, &clipxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
-                        &lockedxpm, &lockedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
-                        &ignorethreadxpm, &ignorethreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY,
-                        &clipkeyxpm, &clipkeyxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY,
-                        &keyxpm, &keyxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
-                        &gpgsignedxpm, &gpgsignedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_GPG_SIGNED,
-                        &clipgpgsignedxpm, &clipgpgsignedxpmmask);
-
        font_desc = pango_font_description_from_string(NORMAL_FONT);
        gtk_widget_modify_font(summaryview->ctree, font_desc);
        pango_font_description_free(font_desc);
@@ -689,12 +660,47 @@ void summary_init(SummaryView *summaryview)
 
        font_desc = pango_font_description_new();
        size = pango_font_description_get_size
-               (summaryview->statlabel_folder->style->font_desc);
+               (summaryview->ctree->style->font_desc);
        pango_font_description_set_size(font_desc, size * PANGO_SCALE_SMALL);
        gtk_widget_modify_font(summaryview->statlabel_folder, font_desc);
        gtk_widget_modify_font(summaryview->statlabel_select, font_desc);
        gtk_widget_modify_font(summaryview->statlabel_msgs, font_desc);
        pango_font_description_free(font_desc);
+}
+
+void summary_init(SummaryView *summaryview)
+{
+       GtkWidget *pixmap;
+
+       gtk_widget_realize(summaryview->ctree);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
+                        &markxpm, &markxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
+                        &deletedxpm, &deletedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
+                        &newxpm, &newxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
+                        &unreadxpm, &unreadxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
+                        &repliedxpm, &repliedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
+                        &forwardedxpm, &forwardedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
+                        &clipxpm, &clipxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
+                        &lockedxpm, &lockedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
+                        &ignorethreadxpm, &ignorethreadxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY,
+                        &clipkeyxpm, &clipkeyxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY,
+                        &keyxpm, &keyxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
+                        &gpgsignedxpm, &gpgsignedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_GPG_SIGNED,
+                        &clipgpgsignedxpm, &clipgpgsignedxpmmask);
+
+       summary_set_fonts(summaryview);
 
        pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
@@ -888,13 +894,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        main_window_cursor_wait(summaryview->mainwin);
 
-/*
-       mlist = item->folder->get_msg_list(item->folder, item, !update_cache);
-
-       !!! NEW !!!
-       USE LIST FROM CACHE, WILL NOT DISPLAY ANY MESSAGES DROPED
-       BY OTHER PROGRAMS TO THE FOLDER
-*/
        mlist = folder_item_get_msg_list(item);
 
        if (summaryview->folder_item->hide_read_msgs) {
@@ -1015,26 +1014,31 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                        summary_lock(summaryview);
                }
        } else {
-               /* select first unread message */
-               node = summary_find_next_flagged_msg(summaryview, NULL,
-                                                    MSG_UNREAD, FALSE);
+               switch (prefs_common.select_on_entry) {
+                       case SELECTONENTRY_UNREAD:
+                               node = summary_find_next_flagged_msg(summaryview, NULL,
+                                                                    MSG_UNREAD, FALSE);
+                               break;
+                       case SELECTONENTRY_NEW:
+                               node = summary_find_next_flagged_msg(summaryview, NULL,
+                                                                    MSG_NEW, FALSE);
+                               break;
+                       default:
+                               node = summary_find_next_flagged_msg(summaryview, NULL,
+                                                                    0, FALSE);
+               }
+
                if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
                        node = gtk_ctree_node_nth
                                (ctree,
                                 item->sort_type == SORT_DESCENDING
                                 ? 0 : GTK_CLIST(ctree)->rows - 1);
                }
-               if (prefs_common.open_unread_on_enter) {
-                       summary_unlock(summaryview);
-                       summary_select_node(summaryview, node, 
-                                           messageview_is_visible(summaryview->messageview), 
-                                           TRUE);
-                       summary_lock(summaryview);
-               } else {
-                       summary_unlock(summaryview);
-                       summary_select_node(summaryview, node, prefs_common.always_show_msg, TRUE);
-                       summary_lock(summaryview);
-               }
+               summary_unlock(summaryview);
+               summary_select_node(summaryview, node,
+                                   prefs_common.always_show_msg,
+                                   TRUE);
+               summary_lock(summaryview);
        }
 
        summary_set_column_titles(summaryview);
@@ -1409,7 +1413,7 @@ void summary_select_next_new(SummaryView *summaryview)
                val = alertpanel(_("No more new messages"),
                                 _("No new message found. "
                                   "Go to next folder?"),
-                                GTK_STOCK_YES, _("Search again"),
+                                GTK_STOCK_YES, _("_Search again"),
                                 GTK_STOCK_NO);
                if (val == G_ALERTDEFAULT) {
                        g_signal_stop_emission_by_name(G_OBJECT(ctree),"key_press_event");
@@ -2025,6 +2029,16 @@ static void summary_set_column_titles(SummaryView *summaryview)
        }
 }
 
+void summary_reflect_prefs(void)
+{
+       SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview;
+       bold_style = bold_marked_style = bold_deleted_style = 
+               small_style = small_marked_style = small_deleted_style = NULL;
+       summary_set_fonts(summaryview);
+       summary_set_column_titles(summaryview);
+       summary_show(summaryview, summaryview->folder_item);
+}
+
 void summary_sort(SummaryView *summaryview,
                  FolderSortKey sort_key, FolderSortType sort_type)
 {
@@ -3430,10 +3444,10 @@ void summary_save_as(SummaryView *summaryview)
 
        if ( aval==0 ) { /* append */
                if (append_file(src, dest, TRUE) < 0) 
-                       alertpanel_error(_("Can't save the file `%s'."), tmp);
+                       alertpanel_error(_("Can't save the file '%s'."), tmp);
        } else { /* overwrite */
                if (copy_file(src, dest, TRUE) < 0)
-                       alertpanel_error(_("Can't save the file `%s'."), tmp);
+                       alertpanel_error(_("Can't save the file '%s'."), tmp);
        }
        g_free(src);
        
@@ -3448,7 +3462,7 @@ void summary_save_as(SummaryView *summaryview)
                        if (!msginfo) break;
                        src = procmsg_get_message_file(msginfo);
                        if (append_file(src, dest, TRUE) < 0)
-                               alertpanel_error(_("Can't save the file `%s'."), tmp);
+                               alertpanel_error(_("Can't save the file '%s'."), tmp);
                }
                g_free(src);
        }
@@ -3474,12 +3488,12 @@ void summary_print(SummaryView *summaryview)
 #ifndef USE_GNOMEPRINT
        cmdline = input_dialog(_("Print"),
                               _("Enter the print command line:\n"
-                                "(`%s' will be replaced with file name)"),
+                                "('%s' will be replaced with file name)"),
                               prefs_common.print_cmd);
        if (!cmdline) return;
        if (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' ||
            strchr(p + 2, '%')) {
-               alertpanel_error(_("Print command line is invalid:\n`%s'"),
+               alertpanel_error(_("Print command line is invalid:\n'%s'"),
                                 cmdline);
                g_free(cmdline);
                return;
@@ -3535,12 +3549,9 @@ gboolean summary_execute(SummaryView *summaryview)
                summary_unthread_for_exec(summaryview);
 
        folder_item_update_freeze();
-       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        summary_execute_move(summaryview);
        summary_execute_copy(summaryview);
        summary_execute_delete(summaryview);
-       folder_item_update_thaw();
-       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        
        node = GTK_CTREE_NODE(clist->row_list);
        for (; node != NULL; node = next) {
@@ -3568,6 +3579,9 @@ gboolean summary_execute(SummaryView *summaryview)
                gtk_ctree_remove_node(ctree, node);
        }
 
+       folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+
        if (new_selected) {
                summary_unlock(summaryview);
                gtk_sctree_select
@@ -3578,8 +3592,10 @@ gboolean summary_execute(SummaryView *summaryview)
        }
 
        if (summaryview->threaded) {
+               gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
                summary_thread_build(summaryview);
                summary_thread_init(summaryview);
+               gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        }
 
        summaryview->selected = clist->selection ?
@@ -3597,8 +3613,6 @@ gboolean summary_execute(SummaryView *summaryview)
 
        gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
 
-       gtk_clist_thaw(clist);
-
        summary_unlock(summaryview);
        return TRUE;
 }
@@ -5221,10 +5235,6 @@ static gboolean processing_apply_func(GNode *node, gpointer data)
                STATUSBAR_PUSH(summaryview->mainwin, buf);
                g_free(buf);
 
-/*
-               mlist = item->folder->get_msg_list(item->folder, item,
-                                                  TRUE);
-*/             
                mlist = folder_item_get_msg_list(item);
                for(cur = mlist ; cur != NULL && cur->data != NULL ; cur = cur->next) {
                        MsgInfo * msginfo;