2012-01-10 [wwp] 3.8.0cvs13
[claws.git] / src / mainwindow.c
index 0deab19e05c3a4027344188f6ac3e63c672f9355..1ece79540c7881c796d05e6bbb960c98a417b5a0 100644 (file)
@@ -6,12 +6,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -247,6 +247,8 @@ static void set_decode_cb           (GtkAction *action, GtkRadioAction *current, gpointer
 
 static void hide_read_messages   (GtkAction    *action,
                                  gpointer       data);
+static void hide_read_threads   (GtkAction     *action,
+                                 gpointer       data);
 static void hide_del_messages   (GtkAction     *action,
                                  gpointer       data);
 
@@ -562,7 +564,7 @@ static GtkActionEntry mainwin_entries[] =
        {"View/Goto/OtherFolder",               NULL, N_("_Other folder..."), "G", NULL, G_CALLBACK(goto_folder_cb) },
 
         /* {"View/Scroll/---",                  NULL, "---", NULL, NULL, NULL }, */
-        {"View/Scroll",                         NULL, N_("Message Scroll") },
+        {"View/Scroll",                         NULL, N_("Message scroll") },
         {"View/Scroll/PrevLine",                NULL, N_("Previous line"), NULL, NULL, G_CALLBACK(scroll_prev_line_cb) },
         {"View/Scroll/NextLine",                NULL, N_("Next line"), NULL, NULL, G_CALLBACK(scroll_next_line_cb) },
         {"View/Scroll/PrevPage",                NULL, N_("Previous page"), NULL, NULL, G_CALLBACK(scroll_prev_page_cb) },
@@ -763,6 +765,7 @@ static GtkToggleActionEntry mainwin_toggle_entries[] = {
 #endif
        {"View/ShowHide/ColumnHeaders",         NULL, N_("Column headers"), NULL, NULL, G_CALLBACK(toggle_col_headers_cb) }, /* toggle */
        {"View/ThreadView",                     NULL, N_("Th_read view"), "<control>T", NULL, G_CALLBACK(thread_cb) }, /* toggle */
+       {"View/HideReadThreads",                NULL, N_("Hide read threads"), NULL, NULL, G_CALLBACK(hide_read_threads) }, /* toggle */
        {"View/HideReadMessages",               NULL, N_("_Hide read messages"), NULL, NULL, G_CALLBACK(hide_read_messages) }, /* toggle */
        {"View/HideDelMessages",                NULL, N_("Hide deleted messages"), NULL, NULL, G_CALLBACK(hide_del_messages) }, /* toggle */
 #ifndef MAEMO
@@ -1718,6 +1721,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ThreadView", "View/ThreadView", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "ExpandThreads", "View/ExpandThreads", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "CollapseThreads", "View/CollapseThreads", GTK_UI_MANAGER_MENUITEM)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideReadThreads", "View/HideReadThreads", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideReadMessages", "View/HideReadMessages", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "HideDelMessages", "View/HideDelMessages", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator3", "View/---", GTK_UI_MANAGER_SEPARATOR)
@@ -3080,6 +3084,10 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                if ((selection == SUMMARY_NONE && item->hide_read_msgs)
                    || selection != SUMMARY_NONE)
                        state |= M_HIDE_READ_MSG;
+
+               if ((selection == SUMMARY_NONE && item->hide_read_threads)
+                   || selection != SUMMARY_NONE)
+                       state |= M_HIDE_READ_THREADS;
        }               
        if (mainwin->summaryview->threaded)
                state |= M_THREADED;
@@ -3120,6 +3128,9 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (cur_account)
                state |= M_HAVE_ACCOUNT;
        
+       if (cur_account && cur_account->protocol != A_NONE)
+               state |= M_HAVE_RETRIEVABLE_ACCOUNT;
+
        if (any_folder_want_synchronise())
                state |= M_WANT_SYNC;
 
@@ -3129,6 +3140,13 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (g_list_length(account_list) > 1)
                state |= M_HAVE_MULTI_ACCOUNT;
 
+       for ( ; account_list != NULL; account_list = account_list->next) {
+               if (((PrefsAccount*)account_list->data)->protocol != A_NONE) {
+                       state |= M_HAVE_ANY_RETRIEVABLE_ACCOUNT;
+                       break;
+               }
+       }
+
        for ( ; account_list != NULL; account_list = account_list->next) {
                if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
                        state |= M_HAVE_NEWS_ACCOUNT;
@@ -3208,6 +3226,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/ThreadView"               , M_EXEC|M_SUMMARY_ISLIST},
                {"Menu/View/ExpandThreads"        , M_MSG_EXIST|M_SUMMARY_ISLIST},
                {"Menu/View/CollapseThreads"      , M_MSG_EXIST|M_SUMMARY_ISLIST},
+               {"Menu/View/HideReadThreads"       , M_HIDE_READ_THREADS|M_SUMMARY_ISLIST},
                {"Menu/View/HideReadMessages"      , M_HIDE_READ_MSG|M_SUMMARY_ISLIST},
                {"Menu/View/HideDelMessages"       , M_SUMMARY_ISLIST},
                {"Menu/View/Goto/Prev"        , M_MSG_EXIST},
@@ -3225,9 +3244,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"Menu/View/Quotes"                    , M_SINGLE_TARGET_EXIST},
 
                {"Menu/Message/Receive/CurrentAccount"
-                                                , M_HAVE_ACCOUNT|M_UNLOCKED},
+                                                , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_RETRIEVABLE_ACCOUNT},
                {"Menu/Message/Receive/AllAccounts"
-                                                , M_HAVE_ACCOUNT|M_UNLOCKED},
+                                                , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_ANY_RETRIEVABLE_ACCOUNT},
                {"Menu/Message/Receive/CancelReceiving"
                                                 , M_INC_ACTIVE},
                {"Menu/Message/SendQueue"  , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
@@ -3368,12 +3387,20 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        &&  mainwin->messageview->mimeview
        &&  mainwin->messageview->mimeview->textview)
                cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/AllHeaders",
-                             mainwin->messageview->mimeview->textview->show_all_headers);
+                                               prefs_common.show_all_headers);
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/ThreadView", (state & M_THREADED) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/ExpandThreads", (state & M_THREADED) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/CollapseThreads", (state & M_THREADED) != 0);
+       cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", (state & M_THREADED) != 0);
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/CollapseAll", (prefs_common.hide_quotes == 1));
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse2", (prefs_common.hide_quotes == 2));
        cm_toggle_menu_set_active_full(mainwin->ui_manager, "Menu/View/Quotes/Collapse3", (prefs_common.hide_quotes == 3));
 
+       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_msgs)
+               cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadThreads", FALSE);
+       if (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->hide_read_threads)
+               cm_menu_set_sensitive_full(mainwin->ui_manager, "Menu/View/HideReadMessages", FALSE);
+               
        main_window_menu_callback_unblock(mainwin);
 }
 
@@ -4347,7 +4374,7 @@ static void show_all_header_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
        if (mainwin->menu_lock_count) return;
-       mainwin->summaryview->messageview->all_headers = 
+       prefs_common.show_all_headers = 
                        gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
        summary_display_msg_selected(mainwin->summaryview,
                                     gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
@@ -4480,7 +4507,7 @@ static void open_urls_cb(GtkAction *action, gpointer data)
        MainWindow *mainwin = (MainWindow *)data;
        if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
                summary_display_msg_selected(mainwin->summaryview, 
-                       mainwin->messageview->mimeview->textview->show_all_headers);
+                                            prefs_common.show_all_headers);
        }
        messageview_list_urls(mainwin->messageview);
 }
@@ -4543,6 +4570,16 @@ static void hide_del_messages (GtkAction *action, gpointer data)
        summary_toggle_show_del_messages(mainwin->summaryview);
 }
 
+static void hide_read_threads (GtkAction *action, gpointer data)
+{
+       MainWindow *mainwin = (MainWindow *)data;
+       GtkWidget *menuitem = gtk_ui_manager_get_widget(mainwin->ui_manager, "/Menu/View/HideReadThreads");
+       if (!mainwin->summaryview->folder_item
+           || g_object_get_data(G_OBJECT(menuitem), "dont_toggle"))
+               return;
+       summary_toggle_show_read_threads(mainwin->summaryview);
+}
+
 static void thread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;