2007-06-08 [wwp] 2.9.2cvs50
[claws.git] / src / mainwindow.c
index c6ae75284b8764659ea0b6662a2fd36cf72727ec..7ac43eaaae2ee6f11aa3d59da1267100a876cc0e 100644 (file)
@@ -106,6 +106,8 @@ static GList *mainwin_list = NULL;
 static GdkCursor *watch_cursor = NULL;
 static GdkCursor *hand_cursor = NULL;
 
+static gint iconified_count = 0;
+
 static void main_window_menu_callback_block    (MainWindow     *mainwin);
 static void main_window_menu_callback_unblock  (MainWindow     *mainwin);
 
@@ -197,6 +199,9 @@ static void addressbook_open_cb     (MainWindow     *mainwin,
 static void log_window_show_cb (MainWindow     *mainwin,
                                 guint           action,
                                 GtkWidget      *widget);
+static void filtering_debug_window_show_cb     (MainWindow     *mainwin,
+                                guint           action,
+                                GtkWidget      *widget);
 
 static void inc_cancel_cb              (MainWindow     *mainwin,
                                         guint           action,
@@ -394,6 +399,9 @@ static void create_filter_cb         (MainWindow    *mainwin,
 static void create_processing_cb (MainWindow   *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void open_urls_cb        (MainWindow    *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 
 static void prefs_template_open_cb     (MainWindow     *mainwin,
                                         guint           action,
@@ -467,6 +475,12 @@ static void sync_cb                 ( MainWindow *mainwin,
 static gboolean mainwindow_focus_in_event      (GtkWidget      *widget, 
                                                 GdkEventFocus  *focus,
                                                 gpointer        data);
+static gboolean mainwindow_visibility_event_cb (GtkWidget      *widget, 
+                                                GdkEventVisibility     *state,
+                                                gpointer        data);
+static gboolean mainwindow_state_event_cb      (GtkWidget      *widget, 
+                                                GdkEventWindowState    *state,
+                                                gpointer        data);
 static void main_window_reply_cb                       (MainWindow     *mainwin, 
                                                 guint           action,
                                                 GtkWidget      *widget);
@@ -551,6 +565,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Layout/_Three columns"),    NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/Layout/_Wide message"),     NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
+       {N_("/_View/Layout/S_mall screen"),     NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_View/_Sort"),                    NULL, NULL, 0, "<Branch>"},
        {N_("/_View/_Sort/by _number"),         NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
@@ -829,6 +844,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Tools/C_reate processing rule/by _Subject"),
                                                NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
+       {N_("/_Tools/List _URLs..."),           "<shift><control>U", open_urls_cb, 0, NULL},
+       {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Tools/Actio_ns"),                NULL, NULL, 0, "<Branch>"},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Tools/Ch_eck for new messages in all folders"),
@@ -847,7 +864,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, ssl_manager_open_cb, 0, NULL},
 #endif
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
-       {N_("/_Tools/_Log window"),             "<shift><control>L", log_window_show_cb, 0, NULL},
+       {N_("/_Tools/Filtering Log"),           NULL, filtering_debug_window_show_cb, 0, NULL},
+       {N_("/_Tools/Protocol _Log"),           "<shift><control>L", log_window_show_cb, 0, NULL},
 
        {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
        {N_("/_Configuration/C_hange current account"),
@@ -882,6 +900,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
 
 static gboolean offline_ask_sync = TRUE;
 static guint lastkey;
+static gboolean is_obscured = FALSE;
 
 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
                                             GObject *arg1,
@@ -1028,12 +1047,12 @@ static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refr
                g_object_set_data(G_OBJECT(item), "mainwin",
                                  mainwin);
                gtk_widget_show(item);
-               gtk_widget_add_accelerator(item, "activate", 
+               if (i < 9)
+                       gtk_widget_add_accelerator(item, "activate", 
                                   mainwin->menu_factory->accel_group, 
                                   GDK_1+i, GDK_CONTROL_MASK,
                                   GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
        }
-
        gtk_widget_show(menu);
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
        mainwin->colorlabel_menu = menu;
@@ -1124,7 +1143,7 @@ MainWindow *main_window_create()
        mainwin = g_new0(MainWindow, 1);
 
        /* main window */
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
 
@@ -1271,16 +1290,40 @@ MainWindow *main_window_create()
 
        gtk_widget_hide(offline_switch);
        gtk_widget_hide(warning_btn);
+
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
        mainwin->summaryview = summaryview = summary_create();
        mainwin->messageview = messageview = messageview_create(mainwin);
-       mainwin->logwin      = log_window_create();
 
+       /* init log instances data before creating log views */
+       set_log_title(LOG_PROTOCOL, _("Protocol log"));
+       set_log_prefs(LOG_PROTOCOL,
+                       &prefs_common.logwin_width,
+                       &prefs_common.logwin_height);
+       set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
+       set_log_prefs(LOG_DEBUG_FILTERING,
+                       &prefs_common.filtering_debugwin_width,
+                       &prefs_common.filtering_debugwin_height);
+
+       /* setup log windows */
+       mainwin->logwin = log_window_create(LOG_PROTOCOL);
        log_window_init(mainwin->logwin);
-       log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
+
+       mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
+       log_window_set_clipping(mainwin->logwin,
+                               prefs_common.cliplog,
                                prefs_common.loglength);
 
+       log_window_init(mainwin->filtering_debugwin);
+       log_window_set_clipping(mainwin->filtering_debugwin,
+                               prefs_common.filtering_debug_cliplog,
+                               prefs_common.filtering_debug_loglength);
+       if (prefs_common.enable_filtering_debug)
+               log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
+       else
+               log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
+
        folderview->mainwin      = mainwin;
        folderview->summaryview  = summaryview;
 
@@ -1420,12 +1463,20 @@ MainWindow *main_window_create()
           menu items in different menus             */
        menu_connect_identical_items();
 
-
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
 
-       if (prefs_common.layout_mode == VERTICAL_LAYOUT)
-               summary_relayout(mainwin->summaryview); 
+       g_signal_connect(G_OBJECT(window), "window_state_event",
+                        G_CALLBACK(mainwindow_state_event_cb), mainwin);
+       g_signal_connect(G_OBJECT(window), "visibility_notify_event",
+                        G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
+       gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
 
+       if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
+           prefs_common.layout_mode == SMALL_LAYOUT) {
+               summary_relayout(mainwin->summaryview); 
+       }
+       summary_update_unread(mainwin->summaryview, NULL);
+       
        gtk_widget_show(mainwin->window);
 
        /* initialize views */
@@ -1865,9 +1916,16 @@ static void main_window_separation_change(MainWindow *mainwin, LayoutType layout
        gtk_widget_unref(message_wid);
 }
 
-static void mainwin_reset_paned(GtkPaned *paned)
+void mainwindow_reset_paned(GtkPaned *paned)
 {
                gint min, max, mid;
+
+               if (gtk_paned_get_child1(GTK_PANED(paned)))
+                       gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
+               if (gtk_paned_get_child2(GTK_PANED(paned)))
+                       gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
+
+GTK_EVENTS_FLUSH();
                g_object_get (G_OBJECT(paned),
                                "min-position",
                                &min, NULL);
@@ -1875,10 +1933,37 @@ static void mainwin_reset_paned(GtkPaned *paned)
                                "max-position",
                                &max, NULL);
                mid = (min+max)/2;
-
                gtk_paned_set_position(GTK_PANED(paned), mid);
 }
 
+static void mainwin_paned_show_first(GtkPaned *paned)
+{
+               gint max;
+               g_object_get (G_OBJECT(paned),
+                               "max-position",
+                               &max, NULL);
+
+               if (gtk_paned_get_child1(GTK_PANED(paned)))
+                       gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
+               if (gtk_paned_get_child2(GTK_PANED(paned)))
+                       gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
+               gtk_paned_set_position(GTK_PANED(paned), max);
+}
+
+static void mainwin_paned_show_last(GtkPaned *paned)
+{
+               gint min;
+               g_object_get (G_OBJECT(paned),
+                               "min-position",
+                               &min, NULL);
+
+               if (gtk_paned_get_child1(GTK_PANED(paned)))
+                       gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
+               if (gtk_paned_get_child2(GTK_PANED(paned)))
+                       gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
+               gtk_paned_set_position(GTK_PANED(paned), min);
+}
+
 void main_window_toggle_message_view(MainWindow *mainwin)
 {
        SummaryView *summaryview = mainwin->summaryview;
@@ -1888,6 +1973,7 @@ void main_window_toggle_message_view(MainWindow *mainwin)
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
        case VERTICAL_LAYOUT:
+       case SMALL_LAYOUT:
                ppaned = mainwin->vpaned;
                container = mainwin->hpaned;
                if (ppaned->parent != NULL) {
@@ -2031,10 +2117,10 @@ void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
 
 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
 {
-       if (confirm) {
+       if (confirm && procmsg_have_trashed_mails_fast()) {
                if (alertpanel(_("Empty trash"),
                               _("Delete all messages in trash folders?"),
-                              GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
+                              GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
                    != G_ALERTALTERNATE)
                        return;
                manage_window_focus_in(mainwin->window, NULL, NULL);
@@ -2054,7 +2140,7 @@ void main_window_add_mailbox(MainWindow *mainwin)
 
        path = input_dialog(_("Add mailbox"),
                            _("Input the location of mailbox.\n"
-                             "If the existing mailbox is specified, it will be\n"
+                             "If an existing mailbox is specified, it will be\n"
                              "scanned automatically."),
                            "Mail");
        if (!path) return;
@@ -2155,6 +2241,8 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
 
        if (inc_is_active())
                state |= M_INC_ACTIVE;
+       if (imap_cancel_all_enabled())
+               state |= M_INC_ACTIVE;
 
        if (mainwin->summaryview->deleted > 0 ||
            mainwin->summaryview->moved > 0 ||
@@ -2187,8 +2275,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/File/Synchronise folders", M_WANT_SYNC},
                {"/File/Exit"      , M_UNLOCKED},
 
-               {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
-               {"/Edit/Delete thread"             , M_SINGLE_TARGET_EXIST},
+               {"/Edit/Select thread"             , M_TARGET_EXIST},
+               {"/Edit/Delete thread"             , M_TARGET_EXIST},
                {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
 
                {"/View/Set displayed columns/in Folder list..."
@@ -2249,11 +2337,15 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Tools/Filter selected messages"     , M_TARGET_EXIST|M_EXEC},
                {"/Tools/Create filter rule"           , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
                {"/Tools/Create processing rule"       , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
+               {"/Tools/List URLs..."                 , M_TARGET_EXIST},
                {"/Tools/Actions"                      , M_TARGET_EXIST|M_ACTIONS_EXIST},
                {"/Tools/Execute"                      , M_DELAY_EXEC},
                {"/Tools/Delete duplicated messages/In selected folder"   , M_MSG_EXIST|M_ALLOW_DELETE},
 
                {"/Configuration", M_UNLOCKED},
+               {"/Configuration/Preferences for current account...", M_UNLOCKED},
+               {"/Configuration/Create new account...", M_UNLOCKED},
+               {"/Configuration/Edit accounts...", M_UNLOCKED},
 
                {NULL, 0}
        };
@@ -2487,7 +2579,8 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
        const gchar *buf;
        gint i = 0;
        buf = *buffer;
-       
+       gboolean with_plus = TRUE;
+
        if (buf == 0x00) {
                *url_decoded = '\0';
                *buffer = NULL;
@@ -2501,6 +2594,8 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
        /* First non space and non comment must be a < */
        if (*buf =='<' ) {
                buf++;
+               if (!strncmp(buf, "mailto:", strlen("mailto:")))
+                       with_plus = FALSE;
                for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
                buf++;
        }
@@ -2517,7 +2612,7 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
        if (i == maxlen) {
                return;
        }
-       decode_uri (url_decoded, (const gchar *)tmp);
+       decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
 
        /* Prepare the work for the next url in the list */
        /* after the closing bracket >, ignore space, comments and tabs */
@@ -2561,6 +2656,13 @@ void main_window_popup(MainWindow *mainwin)
                main_window_show(mainwin);
 
        gtkut_window_popup(mainwin->window);
+       if (prefs_common.layout_mode == SMALL_LAYOUT) {
+               if (mainwin->in_folder) {
+                       mainwindow_enter_folder(mainwin);
+               } else {
+                       mainwindow_exit_folder(mainwin);
+               }
+       }
 }
 
 void main_window_show(MainWindow *mainwin)
@@ -2601,18 +2703,28 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        GtkWidget *vbox_body = mainwin->vbox_body;
        GtkItemFactory *ifactory = mainwin->menu_factory;
        GtkWidget *menuitem;
-
+       gboolean first_set = (mainwin->hpaned == NULL);
        debug_print("Setting widgets... ");
 
-       gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+       if (layout_mode == SMALL_LAYOUT && first_set) {
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
                                    prefs_common.folderview_width,
                                    prefs_common.folderview_height);
-       gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+                                   0,0);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+                                   0,0);
+       } else {
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+                                   prefs_common.folderview_width,
+                                   prefs_common.folderview_height);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
                                    prefs_common.summaryview_width,
                                    prefs_common.summaryview_height);
-       gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
                                    prefs_common.msgview_width,
                                    prefs_common.msgview_height);
+       }
 
        mainwin->messageview->statusbar = mainwin->statusbar;
        mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
@@ -2625,10 +2737,12 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                        gtk_widget_destroy(mainwin->hpaned);
        }
 
-       menu_set_sensitive(ifactory, "/View/Show or hide/Message view", (layout_mode != WIDE_MSGLIST_LAYOUT));
+       menu_set_sensitive(ifactory, "/View/Show or hide/Message view", 
+               (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
        switch (layout_mode) {
        case VERTICAL_LAYOUT:
        case NORMAL_LAYOUT:
+       case SMALL_LAYOUT:
                hpaned = gtk_hpaned_new();
                if (layout_mode == VERTICAL_LAYOUT)
                        vpaned = gtk_hpaned_new();
@@ -2652,6 +2766,9 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
                gtk_paned_add2(GTK_PANED(vpaned),
                               GTK_WIDGET_PTR(mainwin->messageview));
                gtk_widget_show(vpaned);
+               if (layout_mode == SMALL_LAYOUT && first_set) {
+                       mainwin_paned_show_first(GTK_PANED(hpaned));
+               }
                gtk_widget_queue_resize(vpaned);
                break;
        case WIDE_LAYOUT:
@@ -2709,6 +2826,28 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        mainwin->hpaned = hpaned;
        mainwin->vpaned = vpaned;
 
+       if (layout_mode == SMALL_LAYOUT) {
+               if (mainwin->messageview->visible)
+                       main_window_toggle_message_view(mainwin);
+       } 
+
+       if (layout_mode == SMALL_LAYOUT && first_set) {
+               gtk_widget_realize(mainwin->window);
+               gtk_widget_realize(mainwin->folderview->ctree);
+               gtk_widget_realize(mainwin->summaryview->hbox);
+               gtk_widget_realize(mainwin->summaryview->hbox_l);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
+                                   prefs_common.folderview_width,
+                                   prefs_common.folderview_height);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
+                                   0,0);
+               gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
+                                   0,0);
+               gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
+                               prefs_common.mainwin_width,
+                               prefs_common.mainwin_height);
+               gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
+       } 
        /* remove headerview if not in prefs */
        headerview_set_visibility(mainwin->messageview->headerview,
                                  prefs_common.display_header_pane);
@@ -2765,6 +2904,9 @@ static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
        case WIDE_MSGLIST_LAYOUT:
                SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
                break;
+       case SMALL_LAYOUT:
+               SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
+               break;
        }
 #undef SET_CHECK_MENU_ACTIVE
 
@@ -2841,8 +2983,11 @@ static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
                                 gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
+       gboolean close_allowed = TRUE;
 
-       if (mainwin->lock_count == 0)
+       hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
+
+       if (close_allowed && mainwin->lock_count == 0)
                app_exit_cb(data, 0, widget);
 
        return TRUE;
@@ -2853,7 +2998,6 @@ static void main_window_size_allocate_cb(GtkWidget *widget,
                                         gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-
        main_window_get_size(mainwin);
 }
 
@@ -3011,7 +3155,7 @@ static void set_layout_cb(MainWindow *mainwin, guint action,
                               GtkWidget *widget)
 {
        LayoutType layout_mode = action;
-
+       LayoutType old_layout_mode = prefs_common.layout_mode;
        if (mainwin->menu_lock_count) {
                return;
        }
@@ -3023,13 +3167,22 @@ static void set_layout_cb(MainWindow *mainwin, guint action,
                return;
        }
        
-       if (!mainwin->messageview->visible)
+       if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
+               main_window_toggle_message_view(mainwin);
+       else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
                main_window_toggle_message_view(mainwin);
 
        main_window_separation_change(mainwin, layout_mode);
-
-       mainwin_reset_paned(GTK_PANED(mainwin->vpaned));
+       mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
+       if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
+               mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
+       }
+       if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
+               mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
+               mainwindow_exit_folder(mainwin);
+       }
        summary_relayout(mainwin->summaryview); 
+       summary_update_unread(mainwin->summaryview, NULL);
 }
 
 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
@@ -3073,8 +3226,9 @@ static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
                        _("Do you want to synchronise your folders now?"),
                        GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
                return;
-
-       folder_synchronise(NULL);
+       
+       if (offline_ask_sync)
+               folder_synchronise(NULL);
 }
 
 static void online_switch_clicked (GtkButton *btn, gpointer data) 
@@ -3130,9 +3284,16 @@ static void log_window_show_cb(MainWindow *mainwin, guint action,
        log_window_show(mainwin->logwin);
 }
 
+static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
+                              GtkWidget *widget)
+{
+       log_window_show(mainwin->filtering_debugwin);
+}
+
 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        inc_cancel_all();
+       imap_cancel_all();
 }
 
 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
@@ -3273,6 +3434,15 @@ static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
        summary_reedit(mainwin->summaryview);
 }
 
+static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
+               summary_display_msg_selected(mainwin->summaryview, 
+                       mainwin->messageview->mimeview->textview->show_all_headers);
+       }
+       messageview_list_urls(mainwin->messageview);
+}
+
 static void add_address_cb(MainWindow *mainwin, guint action,
                           GtkWidget *widget)
 {
@@ -3758,6 +3928,34 @@ static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focu
        return FALSE;
 }
 
+static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
+                                         gpointer data)
+{
+       is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
+       return FALSE;
+}
+
+static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
+                                         gpointer data)
+{
+       if (!claws_is_starting()
+               && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
+               && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
+
+               if (iconified_count > 0)
+                       hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
+               iconified_count++;
+       }
+       if (state->new_window_state == 0)
+               gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
+       return FALSE;
+}
+
+gboolean mainwindow_is_obscured(void)
+{
+       return is_obscured;
+}
+
 #define BREAK_ON_MODIFIER_KEY() \
        if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
 
@@ -3792,6 +3990,15 @@ gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
                        folderview_select_next_unread(mainwin->folderview, TRUE);
                }
                break;
+#ifdef MAEMO
+       case GDK_F6:
+               if (maemo_mainwindow_is_fullscreen(widget)) {
+                       gtk_window_unfullscreen(GTK_WINDOW(widget));
+                } else {
+                       gtk_window_fullscreen(GTK_WINDOW(widget));
+                }
+               break;
+#endif
        default:
                break;
        }
@@ -3864,7 +4071,7 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
        summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
 }
 
-void mainwindow_jump_to(const gchar *target)
+void mainwindow_jump_to(const gchar *target, gboolean popup)
 {
        gchar *tmp = NULL;
        gchar *p = NULL;
@@ -3890,7 +4097,8 @@ void mainwindow_jump_to(const gchar *target)
        if ((item = folder_find_item_from_identifier(tmp))) {
                printf("selecting folder '%s'\n", tmp);
                folderview_select(mainwin->folderview, item);
-               main_window_popup(mainwin);
+               if (popup)
+                       main_window_popup(mainwin);
                g_free(tmp);
                return;
        }
@@ -3908,7 +4116,8 @@ void mainwindow_jump_to(const gchar *target)
                        printf("selecting message %d\n", atoi(msg));
                        summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
                        summary_display_msg_selected(mainwin->summaryview, FALSE);
-                       main_window_popup(mainwin);
+                       if (popup)
+                               main_window_popup(mainwin);
                        g_free(tmp);
                        return;
                } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
@@ -3920,7 +4129,8 @@ void mainwindow_jump_to(const gchar *target)
                                printf("selecting message %s\n", msg);
                                summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
                                summary_display_msg_selected(mainwin->summaryview, FALSE);
-                               main_window_popup(mainwin);
+                               if (popup)
+                                       main_window_popup(mainwin);
                                g_free(tmp);
                                procmsg_msginfo_free(msginfo);
                                return;
@@ -3936,3 +4146,40 @@ void mainwindow_jump_to(const gchar *target)
        
        g_free(tmp);
 }
+
+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));
+       }
+       mainwin->in_folder = FALSE;
+}
+
+void mainwindow_enter_folder(MainWindow *mainwin) {
+       if (prefs_common.layout_mode == SMALL_LAYOUT) {
+               mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
+       }
+       mainwin->in_folder = TRUE;
+}
+
+#ifdef MAEMO
+gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
+{
+       gint w, h;
+       gtk_window_get_size(GTK_WINDOW(widget), &w, &h); 
+       return (w == 800);
+}
+
+void maemo_window_full_screen_if_needed (GtkWindow *window)
+{
+       if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
+               gtk_window_fullscreen(GTK_WINDOW(window));
+       }
+}
+
+void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
+{
+       g_signal_connect(G_OBJECT(window), "key_press_event",
+                        G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());
+}
+#endif