* src/filter.c
[claws.git] / src / mainwindow.c
index 64decf9ec8e431cc546fba884393e799d28bdfe1..62c427c3d5a817ba69f6ae3fc3e946d3194928ee 100644 (file)
 
 #define AC_LABEL_WIDTH 240
 
-#define STATUSBAR_PUSH(mainwin, str) \
-{ \
-       gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
-                          mainwin->mainwin_cid, str); \
-       gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
-}
-
-#define STATUSBAR_POP(mainwin) \
-{ \
-       gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
-                         mainwin->mainwin_cid); \
-}
-
 /* list of all instantiated MainWindow */
 static GList *mainwin_list = NULL;
 
@@ -121,8 +108,6 @@ static void toolbar_inc_all_cb              (GtkWidget      *widget,
 static void toolbar_send_cb            (GtkWidget      *widget,
                                         gpointer        data);
 
-static void toolbar_compose_cb         (GtkWidget      *widget,
-                                        gpointer        data);
 static void toolbar_compose_news_cb    (GtkWidget      *widget,
                                         gpointer        data);
 static void toolbar_compose_mail_cb    (GtkWidget      *widget,
@@ -164,10 +149,6 @@ static void toolbar_exec_cb                (GtkWidget      *widget,
 static void toolbar_next_unread_cb     (GtkWidget      *widget,
                                         gpointer        data);
 
-static void toolbar_prefs_cb           (GtkWidget      *widget,
-                                        gpointer        data);
-static void toolbar_account_cb         (GtkWidget      *widget,
-                                        gpointer        data);
 
 #if 0
 static void toolbar_account_button_pressed     (GtkWidget      *widget,
@@ -272,9 +253,6 @@ static void send_queue_cb           (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
 
-static void compose_cb                 (MainWindow     *mainwin,
-                                        guint           action,
-                                        GtkWidget      *widget);
 static void compose_mail_cb(MainWindow *mainwin, guint action,
                            GtkWidget *widget);
 static void compose_news_cb(MainWindow *mainwin, guint action,
@@ -422,27 +400,27 @@ static void create_filter_cb       (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
 
-static void prefs_common_open_cb (MainWindow   *mainwin,
-                                 guint          action,
-                                 GtkWidget     *widget);
-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);
+static void prefs_common_open_cb       (MainWindow     *mainwin,
+                                        guint           action,
+                                        GtkWidget      *widget);
+static void prefs_filter_open_cb       (MainWindow     *mainwin,
+                                        guint           action,
+                                        GtkWidget      *widget);
 static void prefs_template_open_cb     (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
 static void prefs_actions_open_cb      (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
+static void prefs_account_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 new_account_cb      (MainWindow    *mainwin,
                                  guint          action,
@@ -734,13 +712,13 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Tools/_Create filter rule/by _Subject"),
                                                NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
-       {N_("/_Tools/Actio_ns"),                        NULL, NULL, 0, "<Branch>"},
-       {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
-       {N_("/_Tools/E_xecute"),                        "X", execute_summary_cb, 0, NULL},
+       {N_("/_Tools/Actio_ns"),                NULL, NULL, 0, "<Branch>"},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Tools/Delete du_plicated messages"),
                                                NULL, delete_duplicated_cb,   0, NULL},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
+       {N_("/_Tools/E_xecute"),                "X", execute_summary_cb, 0, NULL},
+       {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Tools/_Log window"),             "<control>L", log_window_show_cb, 0, NULL},
 
        {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
@@ -830,7 +808,6 @@ MainWindow *main_window_create(SeparateType type)
        GtkItemFactory *ifactory;
        GtkWidget *ac_menu;
        GtkWidget *menuitem;
-       GtkWidget *compose_popup;
        GtkWidget *reply_popup;
        GtkWidget *replyall_popup;
        GtkWidget *replysender_popup;
@@ -1076,7 +1053,7 @@ MainWindow *main_window_create(SeparateType type)
 
        main_window_set_toolbar_sensitive(mainwin);
 
-       /* Create actions menu */
+       /* create actions menu */
        update_mainwin_actions_menu(ifactory, mainwin);
 
        /* show main window */
@@ -1192,6 +1169,7 @@ void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
                        activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
                        folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
+                       sd_reflect_prefs_pixmap_theme();
                }
                
                if (prefs_common.immediate_exec)
@@ -1446,7 +1424,7 @@ void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
 
        for (list = folder_get_list(); list != NULL; list = list->next) {
                folder = list->data;
-               if (folder && folder->trash && folder->trash->total != 0) {
+               if (folder && folder->trash) {
                        folderview_update_item(folder->trash, TRUE);
                }
        }
@@ -1487,7 +1465,7 @@ void main_window_add_mailbox(MainWindow *mainwin)
 
        folder_add(folder);
        folder_set_ui_func(folder, scan_tree_func, mainwin);
-       folder->scan_tree(folder);
+       folder_scan_tree(folder);
        folder_set_ui_func(folder, NULL, NULL);
 
        folderview_set(mainwin->folderview);
@@ -1528,7 +1506,7 @@ void main_window_add_mbox(MainWindow *mainwin)
 
        folder_add(folder);
 
-       item = folder_item_new(folder->name, NULL);
+       item = folder_item_new(folder, folder->name, NULL);
        item->folder = folder;
        folder->node = g_node_new(item);
 
@@ -1581,7 +1559,7 @@ static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                /*              if (item->folder->type != F_NEWS) */
                state |= M_ALLOW_DELETE;
 
-               if (selection == SUMMARY_NONE && item->hide_read_msgs
+               if ((selection == SUMMARY_NONE && item->hide_read_msgs)
                    || selection != SUMMARY_NONE)
                        state |= M_HIDE_READ_MSG;       
        }               
@@ -1734,8 +1712,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Tools/Harvest addresses"         , M_UNLOCKED},
                {"/Tools/Filter messages"           , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
                {"/Tools/Create filter rule"        , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
+               {"/Tools/Actions"                   , M_TARGET_EXIST|M_UNLOCKED},
                {"/Tools/Execute"                   , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
-               {"/Tools/Actions"                   , M_MSG_EXIST},
                {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
 
                {"/Configuration", M_UNLOCKED},
@@ -1950,6 +1928,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                                     prefs_common.mainwin_height);
                gtk_widget_show_all(vpaned);
 
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
+
                mainwin->win.sep_none.hpaned = hpaned;
                mainwin->win.sep_none.vpaned = vpaned;
                break;
@@ -2009,6 +1992,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                mainwin->win.sep_message.hpaned     = hpaned;
 
                gtk_widget_show_all(messagewin);
+               
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
                break;
        case SEPARATE_BOTH:
                gtk_box_pack_start(GTK_BOX(vbox_body),
@@ -2030,6 +2018,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
 
                gtk_widget_show_all(folderwin);
                gtk_widget_show_all(messagewin);
+               
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
                break;
        }
 
@@ -2079,8 +2072,6 @@ static void main_window_toolbar_create(MainWindow *mainwin,
        GtkWidget *delete_btn;
        GtkWidget *exec_btn;
        
-       GtkTooltips *tooltips;
-
        toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
                                  GTK_TOOLBAR_BOTH);
        gtk_container_add(GTK_CONTAINER(container), toolbar);
@@ -2318,7 +2309,6 @@ static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpoin
 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
 {
        MainWindow *mainwindow = (MainWindow *) data;
-       GtkWidget *replysender_menu, *replysender_item;
 
        if (!event) return;
 
@@ -2384,17 +2374,6 @@ static void toolbar_send_cb      (GtkWidget      *widget,
        send_queue_cb(mainwin, 0, NULL);
 }
 
-static void toolbar_compose_cb (GtkWidget      *widget,
-                                gpointer        data)
-{
-       MainWindow *mainwin = (MainWindow *)data;
-
-       if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
-               compose_cb(mainwin, 0, NULL);
-       else
-               compose_news_cb(mainwin, 0, NULL);
-}
-
 static void toolbar_compose_news_cb    (GtkWidget      *widget,
                                 gpointer        data)
 {
@@ -2477,20 +2456,6 @@ static void toolbar_next_unread_cb       (GtkWidget      *widget,
        next_unread_cb(mainwin, 0, NULL);
 }
 
-static void toolbar_prefs_cb   (GtkWidget      *widget,
-                                gpointer        data)
-{
-       prefs_common_open();
-}
-
-static void toolbar_account_cb (GtkWidget      *widget,
-                                gpointer        data)
-{
-       MainWindow *mainwin = (MainWindow *)data;
-
-       prefs_account_open_cb(mainwin, 0, NULL);
-}
-
 #if 0
 static void toolbar_account_button_pressed(GtkWidget *widget,
                                           GdkEventButton *event,
@@ -2591,7 +2556,7 @@ static void add_mbox_cb(MainWindow *mainwin, guint action,
 static void update_folderview_cb(MainWindow *mainwin, guint action,
                                 GtkWidget *widget)
 {
-       summary_show(mainwin->summaryview, NULL, FALSE);
+       summary_show(mainwin->summaryview, NULL);
        folderview_rescan_all();
 }
 
@@ -2860,19 +2825,6 @@ static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
        }
 }
 
-static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
-{
-       if (mainwin->summaryview->folder_item) {
-               if (mainwin->summaryview->folder_item->folder->account != NULL
-                   && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
-                       compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
-               else
-                       compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
-       }
-       else
-               compose_new(NULL);
-}
-
 static void compose_mail_cb(MainWindow *mainwin, guint action,
                            GtkWidget *widget)
 {
@@ -3128,7 +3080,7 @@ static void update_summary_cb(MainWindow *mainwin, guint action,
        if (!fitem) return;
 
        folder_item_scan(fitem);
-       summary_show(mainwin->summaryview, fitem, TRUE);
+       summary_show(mainwin->summaryview, fitem);
 }
 
 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
@@ -3327,8 +3279,6 @@ static void activate_compose_button (MainWindow *mainwin,
                                ToolbarStyle style,
                                ComposeButtonType type)
 {
-       SensitiveCond state = main_window_get_current_state(mainwin);
-
        if (style == TOOLBAR_NONE) 
                return;