new filtering action : forward - some fixes
[claws.git] / src / mainwindow.c
index f9eb9e7cf8609a268a8af58d13bfb862593bf062..99d38c998cb46ce24bc98198443237589ec1d228 100644 (file)
@@ -57,7 +57,9 @@
 #include "export.h"
 #include "prefs_common.h"
 #include "prefs_filter.h"
+#include "prefs_scoring.h"
 #include "prefs_account.h"
+#include "prefs_folder_item.h"
 #include "account.h"
 #include "addressbook.h"
 #include "headerwindow.h"
@@ -318,6 +320,12 @@ static void prefs_common_open_cb (MainWindow       *mainwin,
 static void prefs_filter_open_cb (MainWindow   *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void prefs_scoring_open_cb (MainWindow  *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
+static void prefs_filtering_open_cb (MainWindow        *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 static void prefs_account_open_cb(MainWindow   *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -501,6 +509,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Summary/_Sort/Sort by _date"),   NULL, sort_summary_cb, SORT_BY_DATE, NULL},
        {N_("/_Summary/_Sort/Sort by _from"),   NULL, sort_summary_cb, SORT_BY_FROM, NULL},
        {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
+       {N_("/_Summary/_Sort/Sort by sco_re"),  NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
        {N_("/_Summary/_Sort/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Summary/_Sort/_Attract by subject"),
                                                NULL, attract_by_subject_cb, 0, NULL},
@@ -517,6 +526,10 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, prefs_common_open_cb, 0, NULL},
        {N_("/_Configuration/_Filter setting..."),
                                                NULL, prefs_filter_open_cb, 0, NULL},
+       {N_("/_Configuration/_Scoring ..."),
+                                               NULL, prefs_scoring_open_cb, 0, NULL},
+       {N_("/_Configuration/_Filtering ..."),
+                                               NULL, prefs_filtering_open_cb, 0, NULL},
        {N_("/_Configuration/_Preferences per account..."),
                                                NULL, prefs_account_open_cb, 0, NULL},
        {N_("/_Configuration/---"),             NULL, NULL, 0, "<Separator>"},
@@ -791,6 +804,10 @@ void main_window_reflect_prefs_all(void)
                        gtk_widget_set_sensitive(mainwin->get_btn,    FALSE);
                        gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
                }
+               if (prefs_common.immediate_exec)
+                       gtk_widget_hide(mainwin->exec_btn);
+               else
+                       gtk_widget_show(mainwin->exec_btn);
 
                summary_change_display_item(mainwin->summaryview);
                summary_redisplay_msg(mainwin->summaryview);
@@ -1326,8 +1343,10 @@ static void main_window_toolbar_create(MainWindow *mainwin,
        GtkWidget *replyall_btn;
        GtkWidget *fwd_btn;
        GtkWidget *send_btn;
+       /*
        GtkWidget *prefs_btn;
        GtkWidget *account_btn;
+       */
        GtkWidget *next_btn;
        GtkWidget *delete_btn;
        GtkWidget *exec_btn;
@@ -1432,6 +1451,7 @@ static void main_window_toolbar_create(MainWindow *mainwin,
                                           toolbar_next_unread_cb,
                                           mainwin);
 
+       /*
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
 
        CREATE_TOOLBAR_ICON(stock_preferences_xpm);
@@ -1453,6 +1473,7 @@ static void main_window_toolbar_create(MainWindow *mainwin,
        gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
                           GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
                           mainwin);
+       */
 
        mainwin->toolbar      = toolbar;
        mainwin->get_btn      = get_btn;
@@ -1462,8 +1483,10 @@ static void main_window_toolbar_create(MainWindow *mainwin,
        mainwin->replyall_btn = replyall_btn;
        mainwin->fwd_btn      = fwd_btn;
        mainwin->send_btn     = send_btn;
+       /*
        mainwin->prefs_btn    = prefs_btn;
        mainwin->account_btn  = account_btn;
+       */
        mainwin->next_btn     = next_btn;
        mainwin->delete_btn   = delete_btn;
        mainwin->exec_btn     = exec_btn;
@@ -1836,10 +1859,10 @@ static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                compose_reply(msginfo, prefs_common.reply_with_quote, TRUE);
                break;
        case COMPOSE_FORWARD:
-               compose_forward(msginfo, FALSE);
+               compose_forward(NULL, msginfo, FALSE);
                break;
        case COMPOSE_FORWARD_AS_ATTACH:
-               compose_forward(msginfo, TRUE);
+               compose_forward(NULL, msginfo, TRUE);
                break;
        default:
                compose_reply(msginfo, prefs_common.reply_with_quote, FALSE);
@@ -1915,23 +1938,49 @@ static void set_charset_cb(MainWindow *mainwin, guint action,
        debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
 }
 
-static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+void main_window_set_thread_option(MainWindow *mainwin)
 {
        GtkItemFactory *ifactory;
 
+       ifactory = gtk_item_factory_from_widget(mainwin->menubar);
+
+       if (mainwin->summaryview->folder_item->prefs->enable_thread) {
+               menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
+               menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
+               summary_thread_build(mainwin->summaryview);
+       }
+       else {
+               menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
+               menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
+               summary_unthread(mainwin->summaryview);
+       }
+       prefs_folder_item_save_config(mainwin->summaryview->folder_item);
+}
+
+static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       /*
        ifactory = gtk_item_factory_from_widget(widget);
+       */
+       mainwin->summaryview->folder_item->prefs->enable_thread =
+               !mainwin->summaryview->folder_item->prefs->enable_thread;
+       main_window_set_thread_option(mainwin);
 
+       /*
        if (0 == action) {
                summary_thread_build(mainwin->summaryview);
-               prefs_common.enable_thread = TRUE;
+               mainwin->summaryview->folder_item->prefs->enable_thread =
+                       TRUE;
                menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
                menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
        } else {
                summary_unthread(mainwin->summaryview);
-               prefs_common.enable_thread = FALSE;
+               mainwin->summaryview->folder_item->prefs->enable_thread =
+                       FALSE;
                menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
                menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
        }
+       */
 }
 
 static void set_display_item_cb(MainWindow *mainwin, guint action,
@@ -2050,6 +2099,18 @@ static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
        prefs_filter_open();
 }
 
+static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
+                                 GtkWidget *widget)
+{
+       prefs_scoring_open();
+}
+
+static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
+                                   GtkWidget *widget)
+{
+       prefs_filtering_open();
+}
+
 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
                                  GtkWidget *widget)
 {