2005-02-03 [paul] 1.0.0cvs25.3
[claws.git] / src / summaryview.c
index aaf262129bef287593bbb7a68b456db6f3127150..258f0f08339e2f7215f7cf5fc3434cc16310f440 100644 (file)
@@ -611,8 +611,9 @@ SummaryView *summary_create(void)
 
 void summary_init(SummaryView *summaryview)
 {
-       GtkStyle *style;
        GtkWidget *pixmap;
+       PangoFontDescription *font_desc;
+       gint size;
 
        gtk_widget_realize(summaryview->ctree);
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
@@ -640,39 +641,11 @@ void summary_init(SummaryView *summaryview)
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
                         &gpgsignedxpm, &gpgsignedxpmmask);
 
-       if (!small_style) {
-               PangoFontDescription *font_desc = NULL;
-
-               small_style = gtk_style_copy
-                       (gtk_widget_get_style(summaryview->ctree));
-               if (SMALL_FONT)
-                       font_desc = pango_font_description_from_string
-                                               (SMALL_FONT);
-               if (font_desc) {
-                       if (small_style->font_desc)
-                               pango_font_description_free(small_style->font_desc);
-                       small_style->font_desc = font_desc;
-               }
-               small_marked_style = gtk_style_copy(small_style);
-               small_marked_style->fg[GTK_STATE_NORMAL] =
-                       summaryview->color_marked;
-               small_deleted_style = gtk_style_copy(small_style);
-               small_deleted_style->fg[GTK_STATE_NORMAL] =
-                       summaryview->color_dim;
-       }
        if (!bold_style) {
-               PangoFontDescription *font_desc = NULL;
                bold_style = gtk_style_copy
                        (gtk_widget_get_style(summaryview->ctree));
-               if (BOLD_FONT)
-                       font_desc = pango_font_description_from_string
-                                               (BOLD_FONT);
-               if (font_desc) {
-                       if (bold_style->font_desc)
-                               pango_font_description_free
-                                       (bold_style->font_desc);
-                       bold_style->font_desc = font_desc;
-               }
+               pango_font_description_set_weight
+                       (bold_style->font_desc, PANGO_WEIGHT_BOLD);
                bold_marked_style = gtk_style_copy(bold_style);
                bold_marked_style->fg[GTK_STATE_NORMAL] =
                        summaryview->color_marked;
@@ -681,11 +654,14 @@ void summary_init(SummaryView *summaryview)
                        summaryview->color_dim;
        }
 
-       style = gtk_style_copy(gtk_widget_get_style
-                               (summaryview->statlabel_folder));
-       gtk_widget_set_style(summaryview->statlabel_folder, style);
-       gtk_widget_set_style(summaryview->statlabel_select, style);
-       gtk_widget_set_style(summaryview->statlabel_msgs, style);
+       font_desc = pango_font_description_new();
+       size = pango_font_description_get_size
+               (summaryview->statlabel_folder->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);
 
        pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
@@ -791,7 +767,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        guint displayed_msgnum = 0;
        GSList *cur;
         GSList *not_killed;
-       gboolean quicksearch_changed = FALSE;
 
        if (summary_is_locked(summaryview)) return FALSE;
 
@@ -804,9 +779,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                quicksearch_set(summaryview->quicksearch, prefs_common.summary_quicksearch_type, "");
        }
 
-       if (quicksearch_is_running(summaryview->quicksearch))
-               quicksearch_changed = TRUE;
-
        /* STATUSBAR_POP(summaryview->mainwin); */
 
        is_refresh = (item == summaryview->folder_item) ? TRUE : FALSE;
@@ -825,7 +797,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
                val = alertpanel(_("Process mark"),
                                 _("Some marks are left. Process it?"),
-                                _("Yes"), _("No"), _("Cancel"));
+                                GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL);
                if (G_ALERTDEFAULT == val) {
                        summary_unlock(summaryview);
                        summary_execute(summaryview);
@@ -857,6 +829,15 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                gtk_clist_thaw(GTK_CLIST(ctree));
                summary_unlock(summaryview);
                inc_unlock();
+               if (item && quicksearch_is_running(summaryview->quicksearch)) {
+                       main_window_cursor_wait(summaryview->mainwin);
+                       quicksearch_reset_cur_folder_item(summaryview->quicksearch);
+                       if (quicksearch_is_active(summaryview->quicksearch))
+                               quicksearch_search_subfolders(summaryview->quicksearch, 
+                                             summaryview->folderview,
+                                             summaryview->folder_item);
+                       main_window_cursor_normal(summaryview->mainwin);
+               }                       
                return TRUE;
        }
        g_free(buf);
@@ -919,7 +900,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                                procmsg_msginfo_free(msginfo);
                }
                
-               if (quicksearch_changed) {
+               if (quicksearch_is_running(summaryview->quicksearch)) {
                        /* only scan subfolders when quicksearch changed,
                         * not when search is the same and folder changed */
                        main_window_cursor_wait(summaryview->mainwin);
@@ -1279,7 +1260,7 @@ void summary_select_prev_unread(SummaryView *summaryview)
                                val = alertpanel(_("No more unread messages"),
                                                 _("No unread message found. "
                                                   "Search from the end?"),
-                                                _("Yes"), _("No"), NULL);
+                                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                                break;
                        case NEXTUNREADMSGDIALOG_ASSUME_YES:
                                val = G_ALERTDEFAULT;
@@ -1331,7 +1312,7 @@ void summary_select_next_unread(SummaryView *summaryview)
                                        val = alertpanel(_("No more unread messages"),
                                                         _("No unread message found. "
                                                           "Go to next folder?"),
-                                                        _("Yes"), _("No"), NULL);
+                                                        GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                                        break;
                                case NEXTUNREADMSGDIALOG_ASSUME_YES:
                                        val = G_ALERTDEFAULT;
@@ -1371,7 +1352,7 @@ void summary_select_prev_new(SummaryView *summaryview)
                val = alertpanel(_("No more new messages"),
                                 _("No new message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_NEW, FALSE);
@@ -1395,7 +1376,8 @@ void summary_select_next_new(SummaryView *summaryview)
                val = alertpanel(_("No more new messages"),
                                 _("No new message found. "
                                   "Go to next folder?"),
-                                _("Yes"), _("Search again"), _("No"));
+                                GTK_STOCK_YES, _("Search again"),
+                                GTK_STOCK_NO);
                if (val == G_ALERTDEFAULT) {
                        g_signal_stop_emission_by_name(G_OBJECT(ctree),"key_press_event");
                        folderview_select_next_unread(summaryview->folderview);
@@ -1423,7 +1405,7 @@ void summary_select_prev_marked(SummaryView *summaryview)
                val = alertpanel(_("No more marked messages"),
                                 _("No marked message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_MARKED, TRUE);
@@ -1448,7 +1430,7 @@ void summary_select_next_marked(SummaryView *summaryview)
                val = alertpanel(_("No more marked messages"),
                                 _("No marked message found. "
                                   "Search from the beginning?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_MARKED, TRUE);
@@ -1473,7 +1455,7 @@ void summary_select_prev_labeled(SummaryView *summaryview)
                val = alertpanel(_("No more labeled messages"),
                                 _("No labeled message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_CLABEL_FLAG_MASK, TRUE);
@@ -1498,7 +1480,7 @@ void summary_select_next_labeled(SummaryView *summaryview)
                val = alertpanel(_("No more labeled messages"),
                                 _("No labeled message found. "
                                   "Search from the beginning?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_CLABEL_FLAG_MASK, TRUE);
@@ -2809,11 +2791,13 @@ void summary_mark_as_read(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_mark_row_as_read(summaryview,
                                         GTK_CTREE_NODE(cur->data));
        folder_item_update_thaw();
-       
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+
        summary_status_show(summaryview);
 }
 
@@ -2823,10 +2807,12 @@ void summary_msgs_lock(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_lock_row(summaryview,
                                         GTK_CTREE_NODE(cur->data));
        folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        
        summary_status_show(summaryview);
 }
@@ -2837,10 +2823,12 @@ void summary_msgs_unlock(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_unlock_row(summaryview,
                                   GTK_CTREE_NODE(cur->data));
        folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        
        summary_status_show(summaryview);
 }
@@ -2892,10 +2880,12 @@ void summary_mark_as_unread(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_mark_row_as_unread(summaryview,
                                           GTK_CTREE_NODE(cur->data));
        folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        
        summary_status_show(summaryview);
 }
@@ -3029,7 +3019,7 @@ void summary_delete(SummaryView *summaryview)
 
                aval = alertpanel(_("Delete message(s)"),
                                  _("Do you really want to delete message(s) from the trash?"),
-                                 _("Yes"), _("No"), NULL);
+                                 GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (aval != G_ALERTDEFAULT) return;
 
                for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
@@ -3044,12 +3034,14 @@ void summary_delete(SummaryView *summaryview)
 
        /* next code sets current row focus right. We need to find a row
         * that is not deleted. */
-       folder_item_update_freeze();     
+       folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree)); 
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
                sel_last = GTK_CTREE_NODE(cur->data);
                summary_delete_row(summaryview, sel_last);
        }
        folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
 
        node = summary_find_next_msg(summaryview, sel_last);
        if (!node)
@@ -3328,7 +3320,7 @@ void summary_save_as(SummaryView *summaryview)
                gchar *oldstr = filename;
                filename = conv_codeset_strdup(filename,
                                               CS_UTF_8,
-                                              conv_get_current_charset_str());
+                                              conv_get_locale_charset_str());
                if (!filename) {
                        g_warning("summary_save_as(): faild to convert character set.");
                        filename = g_strdup(oldstr);
@@ -3342,7 +3334,8 @@ void summary_save_as(SummaryView *summaryview)
        if (is_file_exist(dest)) {
                aval = alertpanel(_("Append or Overwrite"),
                                  _("Append or overwrite existing file?"),
-                                 _("Append"), _("Overwrite"), _("Cancel"));
+                                 _("Append"), _("Overwrite"),
+                                 GTK_STOCK_CANCEL);
                if (aval != 0 && aval != 1)
                        return;
        }
@@ -3429,11 +3422,13 @@ 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) {
                next = gtkut_ctree_node_next(ctree, node);
@@ -4055,10 +4050,12 @@ void summary_set_colorlabel(SummaryView *summaryview, guint labelcolor,
 
        main_window_cursor_wait(summaryview->mainwin);
        folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_set_row_colorlabel(summaryview,
                                           GTK_CTREE_NODE(cur->data), labelcolor);
        folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        main_window_cursor_normal(summaryview->mainwin);
 }
 
@@ -4664,17 +4661,12 @@ static void summary_reply_cb(SummaryView *summaryview, guint action,
 {
        MessageView *msgview = (MessageView*)summaryview->messageview;
        GSList *msginfo_list;
-       gchar *body;
 
        g_return_if_fail(msgview != NULL);
 
        msginfo_list = summary_get_selection(summaryview);
        g_return_if_fail(msginfo_list != NULL);
-
-       body = messageview_get_selection(msgview);
-
-       compose_reply_mode((ComposeMode)action, msginfo_list, body);
-       g_free(body);
+       compose_reply_from_messageview(msgview, msginfo_list, action);
        g_slist_free(msginfo_list);
 }
 
@@ -5022,14 +5014,15 @@ static void summary_ignore_thread(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
-
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), 
                                        GTK_CTREE_FUNC(summary_ignore_thread_func), 
                                        summaryview);
 
        folder_item_update_thaw();
-
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+       
        summary_status_show(summaryview);
 }
 
@@ -5056,14 +5049,14 @@ static void summary_unignore_thread(SummaryView *summaryview)
        GList *cur;
 
        folder_item_update_freeze();
-
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), 
                                        GTK_CTREE_FUNC(summary_unignore_thread_func), 
                                        summaryview);
 
        folder_item_update_thaw();
-
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        summary_status_show(summaryview);
 }