2008-07-05 [colin] 3.5.0cvs12
[claws.git] / src / mainwindow.c
index d9fd8a5a6900de0d324e15266863dcbfbac03f48..953fe3525e4c047c99c747a8cb99d4ed75fd5cd4 100644 (file)
@@ -1,6 +1,6 @@
 /*
    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
-   Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+   Copyright (C) 1999-2008 Hiroyuki Yamamoto and the Claws Mail team
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -114,7 +114,7 @@ static void main_window_menu_callback_block (MainWindow     *mainwin);
 static void main_window_menu_callback_unblock  (MainWindow     *mainwin);
 
 static void main_window_show_cur_account       (MainWindow     *mainwin);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void main_window_separation_change      (MainWindow     *mainwin,
                                                 LayoutType      layout_mode);
 #endif
@@ -127,7 +127,7 @@ static void toolbar_child_attached          (GtkWidget      *widget,
 static void toolbar_child_detached             (GtkWidget      *widget,
                                                 GtkWidget      *child,
                                                 gpointer        data);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static gboolean ac_label_button_pressed                (GtkWidget      *widget,
                                                 GdkEventButton *event,
                                                 gpointer        data);
@@ -197,7 +197,7 @@ static void toggle_toolbar_cb        (MainWindow    *mainwin,
 static void toggle_col_headers_cb(MainWindow   *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void toggle_statusbar_cb         (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -461,7 +461,7 @@ static void account_selector_menu_cb         (GtkMenuItem   *menuitem,
                                          gpointer       data);
 static void account_receive_menu_cb     (GtkMenuItem   *menuitem,
                                          gpointer       data);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void account_compose_menu_cb     (GtkMenuItem   *menuitem,
                                          gpointer       data);
 #endif
@@ -577,13 +577,13 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
        {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
                                                NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
                                                NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
 #endif
        {N_("/_View/Show or hi_de/_Message view"),
                                                "V", toggle_message_cb, 0, "<ToggleItem>"},
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        {N_("/_View/Show or hi_de/Status _bar"),
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
 #endif
@@ -594,7 +594,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
 
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        {N_("/_View/La_yout"),                  NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Layout/_Standard"),         NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
        {N_("/_View/Layout/_Three columns"),    NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
@@ -1309,7 +1309,7 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
        mainwin->tags_menu = menu;
 }
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
                                    MainWindow *mainwindow)
 {
@@ -1379,14 +1379,16 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                app_exit_cb(mainwin, 0, NULL);
                return FALSE;
        case GDK_space:
-               if (mainwin->folderview && mainwin->summaryview
-                   && ((!mainwin->summaryview->displayed
-                       && !mainwin->summaryview->selected) 
-                       || (mainwin->summaryview->folder_item
-                           && mainwin->summaryview->folder_item->total_msgs == 0))) {
-                       g_signal_stop_emission_by_name(G_OBJECT(widget), 
-                                       "key_press_event");
-                       folderview_select_next_unread(mainwin->folderview, TRUE);
+               if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
+                       if (mainwin->folderview && mainwin->summaryview
+                           && ((!mainwin->summaryview->displayed
+                               && !mainwin->summaryview->selected) 
+                               || (mainwin->summaryview->folder_item
+                                   && mainwin->summaryview->folder_item->total_msgs == 0))) {
+                               g_signal_stop_emission_by_name(G_OBJECT(widget), 
+                                              "key_press_event");
+                               folderview_select_next_unread(mainwin->folderview, TRUE);
+                       }
                }
                break;
 #ifdef MAEMO
@@ -1397,6 +1399,54 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        gtk_window_fullscreen(GTK_WINDOW(widget));
                 }
                break;
+       case GDK_F7:
+               {
+                       PangoFontDescription *font_desc;
+                       int size;
+                       font_desc = pango_font_description_from_string(prefs_common.normalfont);
+                       size = pango_font_description_get_size(font_desc)/PANGO_SCALE;
+                       if (size < 30) {
+                               size++; pango_font_description_set_size(font_desc, size*PANGO_SCALE);
+                               g_free(prefs_common.normalfont); 
+                               prefs_common.normalfont = pango_font_description_to_string(font_desc);
+                               main_window_reflect_prefs_all();
+                       }
+                       pango_font_description_free(font_desc);
+                       font_desc = pango_font_description_from_string(prefs_common.textfont);
+                       size = pango_font_description_get_size(font_desc)/PANGO_SCALE;
+                       if (size < 30) {
+                               size++; pango_font_description_set_size(font_desc, size*PANGO_SCALE);
+                               g_free(prefs_common.textfont); 
+                               prefs_common.textfont = pango_font_description_to_string(font_desc);
+                               main_window_reflect_prefs_all();
+                       }
+                       pango_font_description_free(font_desc);
+               }
+               break;
+       case GDK_F8:
+               {
+                       PangoFontDescription *font_desc;
+                       int size;
+                       font_desc = pango_font_description_from_string(prefs_common.normalfont);
+                       size = pango_font_description_get_size(font_desc)/PANGO_SCALE;
+                       if (size > 5) {
+                               size--; pango_font_description_set_size(font_desc, size*PANGO_SCALE);
+                               g_free(prefs_common.normalfont); 
+                               prefs_common.normalfont = pango_font_description_to_string(font_desc);
+                               main_window_reflect_prefs_all();
+                       }
+                       pango_font_description_free(font_desc);
+                       font_desc = pango_font_description_from_string(prefs_common.textfont);
+                       size = pango_font_description_get_size(font_desc)/PANGO_SCALE;
+                       if (size > 5) {
+                               size--; pango_font_description_set_size(font_desc, size*PANGO_SCALE);
+                               g_free(prefs_common.textfont); 
+                               prefs_common.textfont = pango_font_description_to_string(font_desc);
+                               main_window_reflect_prefs_all();
+                       }
+                       pango_font_description_free(font_desc);
+               }
+               break;
        case GDK_Escape:
                if (mainwin->summaryview && 
                    mainwin->summaryview->ext_messageview && 
@@ -1426,20 +1476,31 @@ void mainwindow_maemo_led_set(gboolean state) {
                        "--dest=com.nokia.mce "
                        "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_activate "
                        "string:PatternCommunicationEvent", TRUE);
+                 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
+                       "--dest=com.nokia.mce "
+                       "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_activate "
+                       "string:PatternCommunicationEmail", TRUE);
                } else {
                  execute_command_line("/usr/bin/dbus-send --system --type=method_call "
                        "--dest=com.nokia.mce "
                        "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_deactivate "
                        "string:PatternCommunicationEvent", TRUE);
+                 execute_command_line("/usr/bin/dbus-send --system --type=method_call "
+                       "--dest=com.nokia.mce "
+                       "/com/nokia/mce/request com.nokia.mce.request.req_led_pattern_deactivate "
+                       "string:PatternCommunicationEmail", TRUE);
                }
        } 
 }
 
 static void led_update(FolderItem *removed_item)
 {
-       guint new, unread, unreadmarked, marked, total;
+       guint new, unread, unreadmarked, marked, total, replied;
+       guint forwarded, locked, ignored, watched;
 
-       folder_count_total_msgs(&new, &unread, &unreadmarked, &marked, &total);
+       folder_count_total_msgs(&new, &unread, &unreadmarked, &marked, &total,
+                               &replied, &forwarded, &locked, &ignored,
+                               &watched);
        if (removed_item) {
                total -= removed_item->total_msgs;
                new -= removed_item->new_msgs;
@@ -1502,7 +1563,7 @@ MainWindow *main_window_create()
        GtkWidget *menubar;
        GtkWidget *handlebox;
        GtkWidget *vbox_body;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        GtkWidget *hbox_stat;
        GtkWidget *statusbar;
        GtkWidget *progressbar;
@@ -1538,7 +1599,7 @@ MainWindow *main_window_create()
        window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-#ifdef MAEMO
+#ifdef GENERIC_UMPC
        prefs_common.layout_mode = SMALL_LAYOUT;
 #endif
        if (!geometry.min_height) {
@@ -1618,7 +1679,7 @@ MainWindow *main_window_create()
        gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
        gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        hbox_stat = gtk_hbox_new(FALSE, 2);
        gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
 
@@ -1747,7 +1808,7 @@ MainWindow *main_window_create()
        mainwin->vbox_body      = vbox_body;
        mainwin->online_switch  = online_switch;
        mainwin->offline_switch    = offline_switch;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        messageview->statusbar  = statusbar;
        mainwin->statusbar      = statusbar;
        mainwin->hbox_stat      = hbox_stat;
@@ -1848,7 +1909,7 @@ MainWindow *main_window_create()
        }
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        gtk_widget_hide(mainwin->hbox_stat);
        menuitem = gtk_item_factory_get_item
                (ifactory, "/View/Show or hide/Status bar");
@@ -1887,7 +1948,7 @@ MainWindow *main_window_create()
           menu items in different menus             */
        menu_connect_identical_items();
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
 #endif
 
@@ -2017,7 +2078,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
        gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
        GList *cur;
        MainWindow *mainwin;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        GtkWidget *pixmap;
 #endif
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
@@ -2034,7 +2095,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        compose_reflect_prefs_pixmap_theme();
                        folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
                        pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
                                             mainwin->online_pixmap);
@@ -2048,6 +2109,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        gtk_widget_show(pixmap);
                        mainwin->offline_pixmap = pixmap;
 #endif
+                       hooks_invoke(THEME_CHANGED_HOOKLIST, NULL);
                }
                
                headerview_set_font(mainwin->messageview->headerview);
@@ -2056,7 +2118,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                textview_reflect_prefs(mainwin->messageview->mimeview->textview);
                folderview_reflect_prefs();
                summary_reflect_prefs();
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
                summary_redisplay_msg(mainwin->summaryview);
 #endif
                if (prefs_common.layout_mode == SMALL_LAYOUT) {
@@ -2101,9 +2163,10 @@ static gboolean main_window_reflect_tags_changes_real(gpointer data)
        GList *cur;
        MainWindow *mainwin = (MainWindow *)data;
 
-       if (summary_is_locked(mainwin->summaryview))
+       if (summary_is_locked(mainwin->summaryview)) {
+               tags_tag = 0;
                return TRUE;
-
+       }
        /* re-create tags submenu */
        menu = GTK_MENU_SHELL(mainwin->tags_menu);
        g_return_val_if_fail(menu != NULL, FALSE);
@@ -2115,6 +2178,7 @@ static gboolean main_window_reflect_tags_changes_real(gpointer data)
        mainwindow_tags_menu_create(mainwin, TRUE);
        summary_reflect_tags_changes(mainwin->summaryview);
        
+       tags_tag = 0;
        return FALSE;
 }
 
@@ -2128,8 +2192,8 @@ void main_window_reflect_tags_changes(MainWindow *mainwin)
 
 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
 {
-       if (prefs_tag == 0 || pixmap_theme_changed) {
-               prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb, 
+       if (prefs_tag == 0) {
+               prefs_tag = g_timeout_add(100, reflect_prefs_timeout_cb, 
                                                GINT_TO_POINTER(pixmap_theme_changed));
        }
 }
@@ -2215,6 +2279,9 @@ static void main_window_set_account_receive_menu(MainWindow *mainwin,
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
 
+               if (ac_prefs->protocol == A_NONE)
+                       continue;
+
                menuitem = gtk_menu_item_new_with_label
                        (ac_prefs->account_name ? ac_prefs->account_name
                         : _("Untitled"));
@@ -2245,6 +2312,9 @@ static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
                ac_prefs = (PrefsAccount *)cur_ac->data;
 
+               if (ac_prefs->protocol == A_NONE)
+                       continue;
+
                menuitem = gtk_menu_item_new_with_label
                        (ac_prefs->account_name
                         ? ac_prefs->account_name : _("Untitled"));
@@ -2260,7 +2330,7 @@ static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
                                                       GList *account_list)
 {
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        GList *cur_ac;
        GtkWidget *menuitem;
        PrefsAccount *ac_prefs;
@@ -2334,13 +2404,14 @@ static void main_window_show_cur_account(MainWindow *mainwin)
        gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
        g_free(buf);
 
-       gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
+       if (mainwin->ac_label)
+               gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
        if (mainwin->ac_button)
                gtk_widget_queue_resize(mainwin->ac_button);
 
        g_free(ac_name);
 }
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
 {
        GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
@@ -2484,6 +2555,9 @@ void main_window_toggle_message_view(MainWindow *mainwin)
                gtk_widget_queue_resize(mainwin->vpaned);
        }
        summary_grab_focus(summaryview);
+       if (!summary_is_list(summaryview)) {
+               summary_show(summaryview, summaryview->folder_item);
+       }
 }
 
 void main_window_get_size(MainWindow *mainwin)
@@ -2508,7 +2582,8 @@ void main_window_get_size(MainWindow *mainwin)
        }
 
        allocation = &mainwin->window->allocation;
-       if (allocation->width > 1 && allocation->height > 1) {
+       if (allocation->width > 1 && allocation->height > 1 &&
+           !prefs_common.mainwin_maximised) {
                prefs_common.mainview_height = allocation->height;
                prefs_common.mainwin_width   = allocation->width;
                prefs_common.mainwin_height  = allocation->height;
@@ -2541,6 +2616,9 @@ void main_window_get_position(MainWindow *mainwin)
 {
        gint x, y;
 
+       if (prefs_common.mainwin_maximised)
+               return;
+
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
 
        prefs_common.mainview_x = x;
@@ -2562,14 +2640,27 @@ void main_window_progress_off(MainWindow *mainwin)
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
 }
 
-void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
+static gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
 {
        if (confirm && procmsg_have_trashed_mails_fast()) {
-               if (alertpanel(_("Empty trash"),
+               AlertValue val;
+               
+               if (for_quit)
+                       val = alertpanel(_("Empty trash"),
                               _("Delete all messages in trash folders?"),
-                              GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
-                   != G_ALERTALTERNATE)
-                       return;
+                              GTK_STOCK_NO, "+" GTK_STOCK_YES, _("Don't quit"));
+               else
+                       val = alertpanel(_("Empty trash"),
+                              _("Delete all messages in trash folders?"),
+                              GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
+               if (val == G_ALERTALTERNATE) {
+                       debug_print("will empty trash\n");
+               } else if (val == G_ALERTDEFAULT) {
+                       debug_print("will not empty trash\n");
+                       return TRUE;
+               } else {
+                       return FALSE; /* cancel exit */
+               }
                manage_window_focus_in(mainwin->window, NULL, NULL);
        }
 
@@ -2578,6 +2669,7 @@ void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
        if (mainwin->summaryview->folder_item &&
            mainwin->summaryview->folder_item->stype == F_TRASH)
                gtk_widget_grab_focus(mainwin->folderview->ctree);
+       return TRUE;
 }
 
 static void main_window_add_mailbox(MainWindow *mainwin)
@@ -2705,6 +2797,12 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
            mainwin->summaryview->copied > 0)
                state |= M_DELAY_EXEC;
 
+       if (summary_is_list(mainwin->summaryview))
+               state |= M_SUMMARY_ISLIST;
+
+       if (prefs_common.layout_mode != SMALL_LAYOUT || mainwin->in_folder)
+               state |= M_IN_MSGLIST;
+
        return state;
 }
 
@@ -2731,17 +2829,18 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/File/Synchronise folders", M_WANT_SYNC},
                {"/File/Exit"      , M_UNLOCKED},
 
-               {"/Edit/Select thread"             , M_TARGET_EXIST},
-               {"/Edit/Delete thread"             , M_TARGET_EXIST},
+               {"/Edit/Select thread"             , M_TARGET_EXIST|M_SUMMARY_ISLIST},
+               {"/Edit/Delete thread"             , M_TARGET_EXIST|M_SUMMARY_ISLIST},
                {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
+               {"/Edit/Quick search",               M_IN_MSGLIST},
 
                {"/View/Set displayed columns/in Folder list..."
-                                                  , M_UNLOCKED}, 
-               {"/View/Sort"                      , M_EXEC},
-               {"/View/Thread view"               , M_EXEC},
-               {"/View/Expand all threads"        , M_MSG_EXIST},
-               {"/View/Collapse all threads"      , M_MSG_EXIST},
-               {"/View/Hide read messages"        , M_HIDE_READ_MSG},
+                                                  , M_UNLOCKED|M_SUMMARY_ISLIST}, 
+               {"/View/Sort"                      , M_EXEC|M_SUMMARY_ISLIST},
+               {"/View/Thread view"               , M_EXEC|M_SUMMARY_ISLIST},
+               {"/View/Expand all threads"        , M_MSG_EXIST|M_SUMMARY_ISLIST},
+               {"/View/Collapse all threads"      , M_MSG_EXIST|M_SUMMARY_ISLIST},
+               {"/View/Hide read messages"        , M_HIDE_READ_MSG|M_SUMMARY_ISLIST},
                {"/View/Go to/Previous message"        , M_MSG_EXIST},
                {"/View/Go to/Next message"        , M_MSG_EXIST},
                {"/View/Go to/Previous unread message" , M_MSG_EXIST},
@@ -2765,18 +2864,18 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Message/Send queued messages"  , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
                {"/Message/Compose an email message", M_HAVE_ACCOUNT},
                {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
-               {"/Message/Reply"                 , M_HAVE_ACCOUNT|M_TARGET_EXIST},
-               {"/Message/Reply to"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
-               {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
-               {"/Message/Forward"               , M_HAVE_ACCOUNT|M_TARGET_EXIST},
-               {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
-               {"/Message/Redirect"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+               {"/Message/Reply"                 , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
+               {"/Message/Reply to"              , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
+               {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS|M_SUMMARY_ISLIST},
+               {"/Message/Forward"               , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
+               {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
+               {"/Message/Redirect"              , M_HAVE_ACCOUNT|M_TARGET_EXIST|M_SUMMARY_ISLIST},
                {"/Message/Move..."               , M_TARGET_EXIST|M_ALLOW_DELETE},
                {"/Message/Copy..."               , M_TARGET_EXIST|M_EXEC},
                {"/Message/Move to trash"         , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
                {"/Message/Delete..."             , M_TARGET_EXIST|M_ALLOW_DELETE},
                {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
-               {"/Message/Mark"                  , M_TARGET_EXIST},
+               {"/Message/Mark"                  , M_TARGET_EXIST|M_SUMMARY_ISLIST},
                {"/Message/Mark/Mark as spam"     , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
                {"/Message/Mark/Mark as ham"      , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
                {"/Message/Mark/Ignore thread"    , M_TARGET_EXIST},
@@ -2788,7 +2887,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Message/Re-edit"               , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
 
                {"/Tools/Add sender to address book"   , M_SINGLE_TARGET_EXIST},
-               {"/Tools/Harvest addresses"            , M_MSG_EXIST},
+               {"/Tools/Harvest addresses"            , M_MSG_EXIST|M_SUMMARY_ISLIST},
                {"/Tools/Harvest addresses/from Messages..."
                                                       , M_TARGET_EXIST},
                {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
@@ -3115,10 +3214,20 @@ static void mailing_list_compose (GtkWidget *w, gpointer *data)
        
 void main_window_popup(MainWindow *mainwin)
 {
+       static gboolean first_start = TRUE;
+
        if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
                main_window_show(mainwin);
 
-       gtkut_window_popup(mainwin->window);
+       if (prefs_common.mainwin_maximised)
+               gtk_window_maximize(GTK_WINDOW(mainwin->window));
+
+       if (first_start) {
+               gtk_window_deiconify(GTK_WINDOW(mainwin->window));
+               first_start = FALSE;
+       } else {
+               gtkut_window_popup(mainwin->window);
+       }
        if (prefs_common.layout_mode == SMALL_LAYOUT) {
                if (mainwin->in_folder) {
                        mainwindow_enter_folder(mainwin);
@@ -3132,7 +3241,7 @@ void main_window_show(MainWindow *mainwin)
 {
        gtk_widget_show(mainwin->window);
        gtk_widget_show(mainwin->vbox_body);
-
+#ifndef GENERIC_UMPC
         gtk_widget_set_uposition(mainwin->window,
                                  prefs_common.mainwin_x,
                                  prefs_common.mainwin_y);
@@ -3146,6 +3255,7 @@ void main_window_show(MainWindow *mainwin)
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
                             prefs_common.msgview_width,
                             prefs_common.msgview_height);
+#endif
 }
 
 void main_window_hide(MainWindow *mainwin)
@@ -3189,7 +3299,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                                    prefs_common.msgview_height);
        }
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        mainwin->messageview->statusbar = mainwin->statusbar;
        mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
 #endif
@@ -3355,7 +3465,7 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
 }
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
                SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
@@ -3427,7 +3537,7 @@ static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
 {
        gtk_widget_set_size_request(child, -1, -1);
 }
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
                                    gpointer data)
 {
@@ -3535,7 +3645,7 @@ static void export_list_mbox_cb(MainWindow *mainwin, guint action,
 static void empty_trash_cb(MainWindow *mainwin, guint action,
                           GtkWidget *widget)
 {
-       main_window_empty_trash(mainwin, TRUE);
+       main_window_empty_trash(mainwin, TRUE, FALSE);
 }
 
 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
@@ -3563,6 +3673,11 @@ static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 
 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
+       if (prefs_common.clean_on_exit) {
+               if (!main_window_empty_trash(mainwin, prefs_common.ask_on_clean, TRUE))
+                       return;
+       }
+
        if (prefs_common.confirm_on_exit) {
                if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
                               GTK_STOCK_CANCEL, GTK_STOCK_QUIT,  NULL)
@@ -3635,7 +3750,7 @@ static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
        }
 }
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
                                GtkWidget *widget)
 {
@@ -3734,6 +3849,13 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        MainWindow *mainwin;
        GtkItemFactory *ifactory;
        GtkCheckMenuItem *menuitem;
+       gboolean have_connectivity;
+
+#ifdef HAVE_NETWORKMANAGER
+       have_connectivity = networkmanager_is_online(NULL); 
+#else
+       have_connectivity = TRUE;
+#endif
 
        mainwin = (MainWindow *) data;
        
@@ -3744,7 +3866,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        g_return_if_fail(menuitem != NULL);
        
        if (btn == GTK_BUTTON(mainwin->online_switch)) {
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
                gtk_widget_hide (mainwin->online_switch);
                gtk_widget_show (mainwin->offline_switch);
 #endif
@@ -3754,7 +3876,9 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                /* go offline */
                if (prefs_common.work_offline)
                        return;
-               mainwindow_check_synchronise(mainwin, TRUE);
+
+               if(have_connectivity)
+                       mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
                imap_disconnect_all();
                hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
@@ -3762,7 +3886,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                /*go online */
                if (!prefs_common.work_offline)
                        return;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
                gtk_widget_hide (mainwin->offline_switch);
                gtk_widget_show (mainwin->online_switch);
 #endif
@@ -4242,7 +4366,7 @@ static void goto_folder_cb(MainWindow *mainwin, guint action,
 {
        FolderItem *to_folder;
 
-       to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
+       to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL, FALSE);
 
        if (to_folder)
                folderview_select(mainwin->folderview, to_folder);
@@ -4391,7 +4515,7 @@ static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
 
        inc_account_mail(mainwin, account);
 }
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
 {
        PrefsAccount *account = (PrefsAccount *)data;
@@ -4474,6 +4598,9 @@ static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState
                if (iconified_count > 0)
                        hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
                iconified_count++;
+       } else if (!claws_is_starting()) {
+               prefs_common.mainwin_maximised = 
+                       ((state->new_window_state&GDK_WINDOW_STATE_MAXIMIZED) != 0);
        }
        if (state->new_window_state == 0)
                gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
@@ -4556,7 +4683,7 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
        FolderItem *item = NULL;
        gchar *msg = NULL;
        MainWindow *mainwin = mainwindow_get_mainwindow();
-       
+       gchar *from_uri = NULL;
        if (!target)
                return;
                
@@ -4565,7 +4692,10 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
                return;
        }
 
-       tmp = g_strdup(target);
+       if ((from_uri = g_filename_from_uri(target, NULL, NULL)) != NULL)
+               tmp = from_uri;
+       else
+               tmp = g_strdup(target);
        
        if ((p = strstr(tmp, "\r")) != NULL)
                *p = '\0';
@@ -4587,6 +4717,9 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
                if ((item = folder_find_item_from_identifier(tmp))) {
                        g_print("selecting folder '%s'\n", tmp);
                        folderview_select(mainwin->folderview, item);
+               } else if ((item = folder_find_item_from_real_path(tmp))) {
+                       g_print("selecting folder '%s'\n", tmp);
+                       folderview_select(mainwin->folderview, item);
                } else {
                        g_print("'%s' not found\n", tmp);
                }
@@ -4629,8 +4762,10 @@ void mainwindow_exit_folder(MainWindow *mainwin) {
        if (prefs_common.layout_mode == SMALL_LAYOUT) {
                folderview_close_opened(mainwin->folderview);
                mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
+               gtk_widget_grab_focus(mainwin->folderview->ctree);
        }
        mainwin->in_folder = FALSE;
+       main_window_set_menu_sensitive(mainwin);
 }
 
 void mainwindow_enter_folder(MainWindow *mainwin) {
@@ -4638,6 +4773,7 @@ void mainwindow_enter_folder(MainWindow *mainwin) {
                mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
        }
        mainwin->in_folder = TRUE;
+       main_window_set_menu_sensitive(mainwin);
 }
 
 #ifdef MAEMO