2005-09-08 [colin] 1.9.14cvs9
authorColin Leroy <colin@colino.net>
Thu, 8 Sep 2005 18:28:36 +0000 (18:28 +0000)
committerColin Leroy <colin@colino.net>
Thu, 8 Sep 2005 18:28:36 +0000 (18:28 +0000)
* src/compose.c
         Alert when we can't save draft
         Fix various wrap/color issues
         Add mid-click pasting respecting wrap_paste option
* src/folder.c
* src/folder.h
* src/folder_item_prefs.c
* src/folder_item_prefs.h
* src/imap.c
* src/imap_gtk.c
* src/imap_gtk.h
* src/main.c
* src/mainwindow.c
* src/mainwindow.h
* src/news.c
* src/news_gtk.c
* src/news_gtk.h
* src/prefs_folder_item.c
         Fix the impossibility to synchronise folders for
         offline use (IMAP and NNTP are concerned)

18 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/compose.c
src/folder.c
src/folder.h
src/folder_item_prefs.c
src/folder_item_prefs.h
src/imap.c
src/imap_gtk.c
src/imap_gtk.h
src/main.c
src/mainwindow.c
src/mainwindow.h
src/news.c
src/news_gtk.c
src/news_gtk.h
src/prefs_folder_item.c

index bf8ba53..60275f1 100644 (file)
@@ -1,3 +1,26 @@
+2005-09-08 [colin]     1.9.14cvs9
+
+       * src/compose.c
+               Alert when we can't save draft
+               Fix various wrap/color issues
+               Add mid-click pasting respecting wrap_paste option
+       * src/folder.c
+       * src/folder.h
+       * src/folder_item_prefs.c
+       * src/folder_item_prefs.h
+       * src/imap.c
+       * src/imap_gtk.c
+       * src/imap_gtk.h
+       * src/main.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/news.c
+       * src/news_gtk.c
+       * src/news_gtk.h
+       * src/prefs_folder_item.c
+               Fix the impossibility to synchronise folders for
+               offline use (IMAP and NNTP are concerned)
+
 2005-09-08 [colin]     1.9.14cvs8
 
        * configure.ac
index 66b5fb8..bc74f59 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-1.html;  cvs diff -u -r 1.4 -r 1.5 doc/manual/en/sylpheed-10.html;  cvs diff -u -r 1.5 -r 1.6 doc/manual/en/sylpheed-11.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-12.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-13.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-14.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-15.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-16.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-17.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-18.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-19.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-2.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-20.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-21.html;  cvs diff -u -r 1.1.4.1 -r 1.1.4.2 doc/manual/en/sylpheed-22.html;  cvs diff -u -r 1.4 -r 1.5 doc/manual/en/sylpheed-3.html;  cvs diff -u -r 1.6.2.1 -r 1.6.2.2 doc/manual/en/sylpheed-4.html;  cvs diff -u -r 1.4.2.1 -r 1.4.2.2 doc/manual/en/sylpheed-5.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-6.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-7.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-8.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed-9.html;  cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/manual/en/sylpheed.html;  ) > 1.9.14cvs6.patchset
 ( cvs diff -u -r 1.5.2.2 -r 1.5.2.3 doc/manual/en/sylpheed-1.html;  cvs diff -u -r 1.4.2.2 -r 1.4.2.3 doc/manual/en/sylpheed-18.html;  cvs diff -u -r 1.4.2.2 -r 1.4.2.3 doc/manual/en/sylpheed-19.html;  cvs diff -u -r 1.6.2.2 -r 1.6.2.3 doc/manual/en/sylpheed-4.html;  cvs diff -u -r 1.5.2.2 -r 1.5.2.3 doc/manual/en/sylpheed-6.html;  cvs diff -u -r 1.5.2.2 -r 1.5.2.3 doc/manual/en/sylpheed.html;  cvs diff -u -r 1.274.2.60 -r 1.274.2.61 src/mainwindow.c;  ) > 1.9.14cvs7.patchset
 ( cvs diff -u -r 1.654.2.818 -r 1.654.2.819 configure.ac;  cvs diff -u -r 1.96.2.73 -r 1.96.2.74 src/textview.c;  ) > 1.9.14cvs8.patchset
+( cvs diff -u -r 1.382.2.162 -r 1.382.2.163 src/compose.c;  cvs diff -u -r 1.213.2.54 -r 1.213.2.55 src/folder.c;  cvs diff -u -r 1.87.2.16 -r 1.87.2.17 src/folder.h;  cvs diff -u -r 1.2.2.7 -r 1.2.2.8 src/folder_item_prefs.c;  cvs diff -u -r 1.2.2.1 -r 1.2.2.2 src/folder_item_prefs.h;  cvs diff -u -r 1.179.2.66 -r 1.179.2.67 src/imap.c;  cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/imap_gtk.c;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/imap_gtk.h;  cvs diff -u -r 1.115.2.52 -r 1.115.2.53 src/main.c;  cvs diff -u -r 1.274.2.61 -r 1.274.2.62 src/mainwindow.c;  cvs diff -u -r 1.39.2.4 -r 1.39.2.5 src/mainwindow.h;  cvs diff -u -r 1.101.2.13 -r 1.101.2.14 src/news.c;  cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/news_gtk.c;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/news_gtk.h;  cvs diff -u -r 1.52.2.12 -r 1.52.2.13 src/prefs_folder_item.c;  ) > 1.9.14cvs9.patchset
index 72b6580..bc06cbe 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=14
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=8
+EXTRA_VERSION=9
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 4a9368f..c6c78b0 100644 (file)
@@ -1525,6 +1525,7 @@ void compose_reedit(MsgInfo *msginfo)
                        strcrchomp(buf);
                        gtk_text_buffer_insert(textbuf, &iter, buf, -1);
                }
+               compose_wrap_all_full(compose, FALSE);
                compose->autowrap = prev_autowrap;
                fclose(fp);
        }
@@ -3101,22 +3102,27 @@ static void compose_beautify_paragraph(Compose *compose, GtkTextIter *par_iter,
                                goto colorize;
                        }
                        debug_print("compose_beautify_paragraph(): quote_str = '%s'\n", quote_str);
-                       startq_offset = gtk_text_iter_get_offset(&iter);
+                       if (startq_offset == -1) 
+                               startq_offset = gtk_text_iter_get_offset(&iter);
                } else {
                        if (startq_offset == -1)
                                noq_offset = gtk_text_iter_get_offset(&iter);
                }
 
-               if (prev_autowrap == FALSE && !force) {
+               if (prev_autowrap == FALSE && !force && !wrap_quote) {
                        goto colorize;
                }
                if (compose_get_line_break_pos(buffer, &iter, &break_pos,
                                               prefs_common.linewrap_len,
                                               quote_len)) {
                        GtkTextIter prev, next, cur;
-
-                       gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
                        
+                       if (prev_autowrap != FALSE || force)
+                               gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+                       else if (quote_str && wrap_quote)
+                               gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+                       else 
+                               goto colorize;
                        /* remove trailing spaces */
                        cur = break_pos;
                        gtk_text_iter_backward_char(&cur);
@@ -4831,6 +4837,20 @@ static void compose_savemsg_select_cb(GtkWidget *widget, Compose *compose)
        g_free(path);
 }
 
+static void entry_paste_clipboard(Compose *compose, GtkWidget *entry, gboolean wrap,
+                                 GdkAtom clip);
+static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
+                                       Compose *compose)
+{
+       if (event->button == 2) {
+               entry_paste_clipboard(compose, compose->focused_editable, 
+                               prefs_common.linewrap_pastes,
+                               GDK_SELECTION_PRIMARY);
+               return TRUE;
+       }
+       return FALSE;
+}
+
 static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
 {
        Compose   *compose;
@@ -5016,6 +5036,8 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                         G_CALLBACK(compose_grab_focus_cb), compose);
        g_signal_connect(G_OBJECT(buffer), "insert_text",
                         G_CALLBACK(text_inserted), compose);
+       g_signal_connect(G_OBJECT(text), "button_press_event",
+                        G_CALLBACK(text_clicked), compose);
 
        /* drag and drop */
        gtk_drag_dest_set(text, GTK_DEST_DEFAULT_ALL, compose_mime_types, 
@@ -6527,6 +6549,8 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
                g_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
+               if (action != COMPOSE_AUTO_SAVE)
+                       alertpanel_error(_("Could not save draft."));
                return;
        }
        g_free(tmp);
@@ -6782,17 +6806,16 @@ static void entry_copy_clipboard(GtkWidget *entry)
                        gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
 }
 
-static void entry_paste_clipboard(GtkWidget *entry, gboolean wrap)
+static void entry_paste_clipboard(Compose *compose, GtkWidget *entry, 
+                                 gboolean wrap, GdkAtom clip)
 {
-       if (GTK_IS_EDITABLE(entry))
-               gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
-       else if (GTK_IS_TEXT_VIEW(entry)) {
+       if (GTK_IS_TEXT_VIEW(entry)) {
                GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry));
                GtkTextMark *mark_start = gtk_text_buffer_get_insert(buffer);
                GtkTextIter start_iter, end_iter;
                gint start, end;
                
-               gchar *contents = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+               gchar *contents = gtk_clipboard_wait_for_text(gtk_clipboard_get(clip));
 
                if (contents == NULL)
                        return;
@@ -6809,9 +6832,16 @@ static void entry_paste_clipboard(GtkWidget *entry, gboolean wrap)
                        gtk_text_buffer_get_iter_at_offset(buffer, &start_iter, start);
                        gtk_text_buffer_get_iter_at_offset(buffer, &end_iter, end);
                        gtk_text_buffer_apply_tag_by_name(buffer, "no_wrap", &start_iter, &end_iter);
+               } else if (wrap && clip == GDK_SELECTION_PRIMARY) {
+                       mark_start = gtk_text_buffer_get_insert(buffer);
+                       gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, mark_start);
+                       gtk_text_iter_backward_char(&start_iter);
+                       compose_beautify_paragraph(compose, &start_iter, TRUE);
                }
                
-       }
+       } else if (GTK_IS_EDITABLE(entry))
+               gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
+       
 }
 
 static void entry_allsel(GtkWidget *entry)
@@ -6880,7 +6910,9 @@ static void compose_paste_cb(Compose *compose)
        BLOCK_WRAP();
        if (compose->focused_editable &&
            GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
-               entry_paste_clipboard(compose->focused_editable, prefs_common.linewrap_pastes);
+               entry_paste_clipboard(compose, compose->focused_editable, 
+                               prefs_common.linewrap_pastes,
+                               GDK_SELECTION_CLIPBOARD);
        UNBLOCK_WRAP();
 }
 
@@ -6900,7 +6932,9 @@ static void compose_paste_as_quote_cb(Compose *compose)
                                    "paste_as_quotation",
                                    GINT_TO_POINTER(paste_as_quotation + 1));
                prefs_common.linewrap_quote = prefs_common.linewrap_pastes;
-               entry_paste_clipboard(compose->focused_editable, prefs_common.linewrap_pastes);
+               entry_paste_clipboard(compose, compose->focused_editable, 
+                               prefs_common.linewrap_pastes,
+                               GDK_SELECTION_CLIPBOARD);
                prefs_common.linewrap_quote = wrap_quote;
        }
 }
@@ -6912,7 +6946,8 @@ static void compose_paste_no_wrap_cb(Compose *compose)
        BLOCK_WRAP();
        if (compose->focused_editable &&
            GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
-               entry_paste_clipboard(compose->focused_editable, FALSE);
+               entry_paste_clipboard(compose, compose->focused_editable, FALSE,
+                       GDK_SELECTION_CLIPBOARD);
        UNBLOCK_WRAP();
 }
 
@@ -6923,7 +6958,8 @@ static void compose_paste_wrap_cb(Compose *compose)
        BLOCK_WRAP();
        if (compose->focused_editable &&
            GTK_WIDGET_HAS_FOCUS(compose->focused_editable))
-               entry_paste_clipboard(compose->focused_editable, TRUE);
+               entry_paste_clipboard(compose, compose->focused_editable, TRUE,
+                       GDK_SELECTION_CLIPBOARD);
        UNBLOCK_WRAP();
 }
 
index 58c3abb..b298d54 100644 (file)
@@ -3559,6 +3559,50 @@ void folder_item_update_thaw(void)
        }
 }
 
+static void folder_item_synchronise_func(FolderItem *item, gpointer data)
+{
+       Folder *folder = (Folder *)data;
+       if (folder == NULL || item->folder == folder) {
+               if(item->prefs->offlinesync && item->folder->klass->synchronise)
+                       item->folder->klass->synchronise(item);
+       }
+}
+
+void folder_synchronise(Folder *folder)
+{
+       folder_func_to_all_folders(folder_item_synchronise_func, folder);
+}
+
+typedef struct _WantSyncData {
+       Folder *folder;
+       gboolean want_sync;
+} WantSyncData;
+
+static void folder_item_want_synchronise_func(FolderItem *item, gpointer data)
+{
+       WantSyncData *want_sync_data = (WantSyncData *)data;
+       
+       if (want_sync_data->folder == NULL || item->folder == want_sync_data->folder) {
+               if(item->prefs->offlinesync && item->folder->klass->synchronise)
+                       want_sync_data->want_sync = TRUE;
+               else
+                       want_sync_data->want_sync = FALSE;
+       }
+}
+
+gboolean folder_want_synchronise(Folder *folder)
+{
+       WantSyncData *want_sync_data = g_new0(WantSyncData, 1);
+       gboolean result;
+       want_sync_data->folder = folder;
+       
+       folder_func_to_all_folders(folder_item_want_synchronise_func, want_sync_data);
+       result = want_sync_data->want_sync;
+       g_free(want_sync_data);
+       debug_print("Folder %s wants sync: %d\n", folder->name, result);
+       return result;
+}
+
 void folder_item_set_batch (FolderItem *item, gboolean batch)
 {
        if (item->folder->klass->set_batch) {
index f3afb9a..297423c 100644 (file)
@@ -572,6 +572,7 @@ struct _FolderClass
        void            (*set_batch)            (Folder         *folder,
                                                 FolderItem     *item,
                                                 gboolean        batch);
+       void            (*synchronise)          (FolderItem     *item);
 };
 
 struct _FolderItem
@@ -808,4 +809,7 @@ void folder_item_update_freeze              (void);
 void folder_item_update_thaw           (void);
 void folder_item_set_batch             (FolderItem *item, gboolean batch);
 gboolean folder_has_parent_of_type     (FolderItem *item, SpecialFolderItemType type);
+void folder_synchronise                        (Folder *folder);
+gboolean folder_want_synchronise       (Folder *folder);
+
 #endif /* __FOLDER_H__ */
index d028636..8ea9952 100644 (file)
@@ -97,6 +97,8 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"newmailcheck", "TRUE", &tmp_prefs.newmailcheck, P_BOOL,
         NULL, NULL, NULL},
+       {"offlinesync", "FALSE", &tmp_prefs.offlinesync, P_BOOL,
+        NULL, NULL, NULL},
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -195,6 +197,7 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
        prefs->processing = NULL;
 
        prefs->newmailcheck = TRUE;
+       prefs->offlinesync = FALSE;
 
        return prefs;
 }
@@ -250,6 +253,7 @@ void folder_item_prefs_copy_prefs(FolderItem * src, FolderItem * dest)
        tmp_prefs.enable_thread                 = src->prefs->enable_thread;
         tmp_prefs.enable_processing             = src->prefs->enable_processing;
        tmp_prefs.newmailcheck                  = src->prefs->newmailcheck;
+       tmp_prefs.offlinesync                  = src->prefs->offlinesync;
 
        prefs_matcher_read_config();
 
index 9fda358..0dc15fe 100644 (file)
@@ -45,6 +45,7 @@ struct _FolderItemPrefs {
        GSList * processing;
 
        int newmailcheck;
+       int offlinesync;
 
        gboolean request_return_receipt;
        gboolean enable_default_to;
index e0fab6f..c907cef 100644 (file)
@@ -283,6 +283,7 @@ static gchar imap_get_path_separator                (IMAPFolder     *folder,
                                                 const gchar    *path);
 static gchar *imap_get_real_path               (IMAPFolder     *folder,
                                                 const gchar    *path);
+static void imap_synchronise           (FolderItem     *item);
 
 static void imap_free_capabilities     (IMAPSession    *session);
 
@@ -443,6 +444,7 @@ FolderClass *imap_get_class(void)
                imap_class.change_flags = imap_change_flags;
                imap_class.get_flags = imap_get_flags;
                imap_class.set_batch = imap_set_batch;
+               imap_class.synchronise = imap_synchronise;
 #ifdef USE_PTREAD
                pthread_mutex_init(&imap_mutex, NULL);
 #endif
@@ -3935,3 +3937,8 @@ FolderClass *imap_get_class(void)
        return &imap_class;
 }
 #endif
+
+void imap_synchronise(FolderItem *item) 
+{
+       imap_gtk_synchronise(item);
+}
index 27e8c44..361e16b 100644 (file)
@@ -50,6 +50,7 @@ static void remove_server_cb(FolderView *folderview, guint action, GtkWidget *wi
 static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void sync_cb(FolderView *folderview, guint action, GtkWidget *widget);
 
 static GtkItemFactoryEntry imap_popup_entries[] =
 {
@@ -58,6 +59,7 @@ static GtkItemFactoryEntry imap_popup_entries[] =
        {N_("/M_ove folder..."),         NULL, move_folder_cb,   0, NULL},
        {N_("/_Delete folder"),          NULL, delete_folder_cb, 0, NULL},
        {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
+       {N_("/Synchronise"),             NULL, sync_cb,         0, NULL},
        {N_("/Down_load messages"),      NULL, download_cb,      0, NULL},
        {N_("/---"),                     NULL, NULL,             0, "<Separator>"},
        {N_("/_Check for new messages"), NULL, update_tree_cb,   0, NULL},
@@ -372,16 +374,21 @@ static void update_tree_cb(FolderView *folderview, guint action,
                folderview_rescan_tree(item->folder);
 }
 
-static void download_cb(FolderView *folderview, guint action,
-                       GtkWidget *widget)
+static void sync_cb(FolderView *folderview, guint action,
+                          GtkWidget *widget)
 {
-       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
-       MainWindow *mainwin = folderview->mainwin;
        FolderItem *item;
 
-       if (!folderview->selected) return;
+       item = folderview_get_selected_item(folderview);
+       g_return_if_fail(item != NULL);
+       folder_synchronise(item->folder);
+}
 
-       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+void imap_gtk_synchronise(FolderItem *item)
+{
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+       FolderView *folderview = mainwin->folderview;
+       
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
@@ -404,6 +411,18 @@ static void download_cb(FolderView *folderview, guint action,
        main_window_unlock(mainwin);
        inc_unlock();
        main_window_cursor_normal(mainwin);
+
+}
+static void download_cb(FolderView *folderview, guint action,
+                       GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+
+       if (!folderview->selected) return;
+
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       imap_gtk_synchronise(item);
 }
 
 gboolean imap_gtk_should_override(void)
@@ -415,7 +434,7 @@ gboolean imap_gtk_should_override(void)
        if (prefs_common.work_offline) {
                if (time(NULL) - overridden_yes < 600)
                         return TRUE;
-               else if (time(NULL) - overridden_no < 3)
+               else if (time(NULL) - overridden_no < 600)
                         return FALSE;
                
                answer = (alertpanel(_("Offline warning"), 
index 81b0030..943c785 100644 (file)
 #ifndef IMAP_GTK_H
 #define IMAP_GTK_H
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+
 #include <glib.h>
+#include "folder.h"
 
 void imap_gtk_init(void);
+void imap_gtk_synchronise(FolderItem *item);
 gboolean imap_gtk_should_override(void);
 
 #endif /* IMAP_GTK_H */
index 9d0b93e..bb1438d 100644 (file)
@@ -437,9 +437,9 @@ int main(int argc, char *argv[])
        signal(SIGPIPE, SIG_IGN);
 #endif
        if (cmd.online_mode == ONLINE_MODE_OFFLINE)
-               main_window_toggle_work_offline(mainwin, TRUE);
+               main_window_toggle_work_offline(mainwin, TRUE, FALSE);
        if (cmd.online_mode == ONLINE_MODE_ONLINE)
-               main_window_toggle_work_offline(mainwin, FALSE);
+               main_window_toggle_work_offline(mainwin, FALSE, FALSE);
 
        if (cmd.status_folders) {
                g_ptr_array_free(cmd.status_folders, TRUE);
@@ -993,9 +993,9 @@ static void lock_socket_input_cb(gpointer data,
        } else if (!strncmp(buf, "send", 4)) {
                send_queue();
        } else if (!strncmp(buf, "online", 6)) {
-               main_window_toggle_work_offline(mainwin, FALSE);
+               main_window_toggle_work_offline(mainwin, FALSE, FALSE);
        } else if (!strncmp(buf, "offline", 7)) {
-               main_window_toggle_work_offline(mainwin, TRUE);
+               main_window_toggle_work_offline(mainwin, TRUE, FALSE);
        } else if (!strncmp(buf, "status-full", 11) ||
                   !strncmp(buf, "status", 6)) {
                gchar *status;
index 0c3a537..218877b 100644 (file)
@@ -428,6 +428,9 @@ static void addr_harvest_cb  ( MainWindow  *mainwin,
 static void addr_harvest_msg_cb         ( MainWindow  *mainwin,
                                   guint       action,
                                   GtkWidget   *widget );
+static void sync_cb             ( MainWindow *mainwin, 
+                                  guint action, 
+                                  GtkWidget *widget );
 
 static gboolean mainwindow_focus_in_event      (GtkWidget      *widget, 
                                                 GdkEventFocus  *focus,
@@ -676,6 +679,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, inc_cancel_cb, 0, NULL},
        {N_("/_Message/Recei_ve/---"),          NULL, NULL, 0, "<Separator>"},
        {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
+       {N_("/_Message/Synchronise folders"),   "<control><shift>S", sync_cb, 0, NULL},
        {N_("/_Message/---"),                   NULL, NULL, 0, "<Separator>"},
        {N_("/_Message/Compose a_n email message"),     "<control>M", compose_mail_cb, 0, NULL},
        {N_("/_Message/Compose a news message"),        NULL,   compose_news_cb, 0, NULL},
@@ -791,6 +795,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Help/_About"),                   NULL, about_show, 0, NULL}
 };
 
+static gboolean offline_ask_sync = TRUE;
+
 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
                                             GObject *arg1,
                                             guint value,
@@ -887,8 +893,8 @@ MainWindow *main_window_create(SeparateType type)
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
        ifactory = gtk_item_factory_from_widget(menubar);
 
-       menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
-       menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
+       menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
+       menu_set_sensitive(ifactory, "/Help/FAQ", manual_available(MANUAL_FAQ_LOCAL));
 
        if (prefs_common.toolbar_detachable) {
                handlebox = gtk_handle_box_new();
@@ -2590,17 +2596,45 @@ static void separate_widget_cb(MainWindow *mainwin, guint action,
        prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
 }
 
-void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
+void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
+                                       gboolean ask_sync)
 {
+       offline_ask_sync = ask_sync;
        if (offline)
                online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
        else
                online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
+       offline_ask_sync = TRUE;
 }
 
 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
 {
-       main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
+       main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
+}
+
+static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
+{
+       GList *folderlist = folder_get_list();
+       gboolean found = FALSE;
+
+       /* see if there are synchronised folders */
+       for (; folderlist; folderlist = folderlist->next) {
+               Folder *folder = (Folder *)folderlist->data;
+               if (folder_want_synchronise(folder)) {
+                       found = TRUE;
+                       break;
+               }
+       }
+       
+       if (!found)
+               return;
+               
+       if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
+                       _("Do you want to synchronise your folders now?"),
+                       GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+               return;
+
+       folder_synchronise(NULL);
 }
 
 static void online_switch_clicked (GtkButton *btn, gpointer data) 
@@ -2619,6 +2653,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        
        if (btn == GTK_BUTTON(mainwin->online_switch)) {
                /* go offline */
+               mainwindow_check_synchronise(mainwin, TRUE);
                gtk_widget_hide (mainwin->online_switch);
                gtk_widget_show (mainwin->offline_switch);
                menuitem->active = TRUE;
@@ -3260,6 +3295,11 @@ gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
        return FALSE;
 }
 
+static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
+{
+       mainwindow_check_synchronise(mainwin, FALSE);
+}
+
 /*
 * End of Source.
 */
index 374116c..60a4f16 100644 (file)
@@ -191,7 +191,8 @@ void toolbar_set_compose_button               (Toolbar               *toolbar,
 void main_window_destroy_all                  (void);
 
 void main_window_toggle_work_offline          (MainWindow        *mainwin, 
-                                               gboolean           offline);
+                                               gboolean           offline,
+                                              gboolean           ask_sync);
 
 /* public so it can be disabled from summaryview */
 gboolean mainwindow_key_pressed                      (GtkWidget         *widget, 
index 21e53d4..417755f 100644 (file)
@@ -131,6 +131,7 @@ gint news_post_stream                        (Folder        *folder,
 static gchar *news_folder_get_path      (Folder        *folder);
 gchar *news_item_get_path               (Folder        *folder,
                                          FolderItem    *item);
+static void news_synchronise            (FolderItem    *item);
 
 static FolderClass news_class;
 
@@ -154,6 +155,7 @@ FolderClass *news_get_class(void)
                news_class.get_msginfo = news_get_msginfo;
                news_class.get_msginfos = news_get_msginfos;
                news_class.fetch_msg = news_fetch_msg;
+               news_class.synchronise = news_synchronise;
        };
 
        return &news_class;
@@ -1124,3 +1126,8 @@ gboolean news_scan_required(Folder *folder, FolderItem *item)
 {
        return TRUE;
 }
+
+void news_synchronise(FolderItem *item) 
+{
+       news_gtk_synchronise(item);
+}
index 7b90cd4..2c9424a 100644 (file)
@@ -46,13 +46,15 @@ static void news_settings_cb(FolderView *folderview, guint action, GtkWidget *wi
 static void remove_news_server_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
 static void download_cb(FolderView *folderview, guint action, GtkWidget *widget);
+static void sync_cb(FolderView *folderview, guint action, GtkWidget *widget);
 
 static GtkItemFactoryEntry news_popup_entries[] =
 {
        {N_("/_Subscribe to newsgroup..."),     NULL, subscribe_newsgroup_cb,    0, NULL},
        {N_("/_Unsubscribe newsgroup"),         NULL, unsubscribe_newsgroup_cb,  0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
-       {N_("/Down_load"),                      NULL, download_cb,               0, NULL},
+       {N_("/Synchronise"),                    NULL, sync_cb,          0, NULL},
+       {N_("/Down_load messages"),             NULL, download_cb,               0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
        {N_("/_Check for new messages"),        NULL, update_tree_cb,            0, NULL},
        {N_("/---"),                            NULL, NULL,                      0, "<Separator>"},
@@ -319,22 +321,24 @@ static void update_tree_cb(FolderView *folderview, guint action,
        folderview_check_new(item->folder);
 }
 
-static void download_cb(FolderView *folderview, guint action,
-                       GtkWidget *widget)
+static void sync_cb(FolderView *folderview, guint action,
+                          GtkWidget *widget)
 {
-       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
-       MainWindow *mainwin = folderview->mainwin;
        FolderItem *item;
 
-       if (!folderview->selected) return;
+       item = folderview_get_selected_item(folderview);
+       g_return_if_fail(item != NULL);
+       folder_synchronise(item->folder);
+}
 
-       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+void news_gtk_synchronise(FolderItem *item)
+{
+       MainWindow *mainwin = mainwindow_get_mainwindow();
+       FolderView *folderview = mainwin->folderview;
+       
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
-       if (prefs_common.work_offline && !news_gtk_should_override())
-               return;
-
        main_window_cursor_wait(mainwin);
        inc_lock();
        main_window_lock(mainwin);
@@ -355,3 +359,15 @@ static void download_cb(FolderView *folderview, guint action,
        inc_unlock();
        main_window_cursor_normal(mainwin);
 }
+
+static void download_cb(FolderView *folderview, guint action,
+                       GtkWidget *widget)
+{
+       GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+       FolderItem *item;
+
+       if (!folderview->selected) return;
+
+       item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+       news_gtk_synchronise(item);
+}
index d5a6581..9495841 100644 (file)
 #ifndef NEWS_GTK_H
 #define NEWS_GTK_H
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "folder.h"
+
 void news_gtk_init(void);
 gboolean news_gtk_should_override(void);
-
+void news_gtk_synchronise(FolderItem *item);
 #endif /* NEWS_GTK_H */
index d802b6d..0b00b81 100644 (file)
@@ -72,6 +72,7 @@ struct _FolderItemGeneralPage
        GtkWidget *folder_color_btn;
        GtkWidget *checkbtn_enable_processing;
        GtkWidget *checkbtn_newmailcheck;
+       GtkWidget *checkbtn_offlinesync;
 
        /* appy to sub folders */
        GtkWidget *simplify_subject_rec_checkbtn;
@@ -79,6 +80,7 @@ struct _FolderItemGeneralPage
        GtkWidget *folder_color_rec_checkbtn;
        GtkWidget *enable_processing_rec_checkbtn;
        GtkWidget *newmailcheck_rec_checkbtn;
+       GtkWidget *offlinesync_rec_checkbtn;
 
        gint       folder_color;
 };
@@ -150,17 +152,19 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        GtkWidget *folder_color_btn;
        GtkWidget *checkbtn_enable_processing;
        GtkWidget *checkbtn_newmailcheck;
+       GtkWidget *checkbtn_offlinesync;
 
        GtkWidget *simplify_subject_rec_checkbtn;
        GtkWidget *folder_chmod_rec_checkbtn;
        GtkWidget *folder_color_rec_checkbtn;
        GtkWidget *enable_processing_rec_checkbtn;
        GtkWidget *newmailcheck_rec_checkbtn;
-       
+       GtkWidget *offlinesync_rec_checkbtn;
+
        page->item         = item;
 
        /* Table */
-       table = gtk_table_new(5, 2, FALSE);
+       table = gtk_table_new(6, 2, FALSE);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 4);
        rowcount = 0;
@@ -273,6 +277,28 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
 
        rowcount++;
 
+       /* Synchronise folder for offline use */
+       checkbtn_offlinesync = gtk_check_button_new_with_label(_("Synchronise for offline use"));
+       gtk_table_attach(GTK_TABLE(table), checkbtn_offlinesync, 0, 2,
+                        rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+       
+       offlinesync_rec_checkbtn = gtk_check_button_new();
+       gtk_table_attach(GTK_TABLE(table), offlinesync_rec_checkbtn, 2, 3, 
+                        rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+
+       if (item->folder && (item->folder->klass->type != F_IMAP && 
+           item->folder->klass->type != F_NEWS)) {
+                item->prefs->offlinesync = TRUE;
+               gtk_widget_set_sensitive(GTK_WIDGET(checkbtn_offlinesync),
+                                                                FALSE);
+               gtk_widget_set_sensitive(GTK_WIDGET(offlinesync_rec_checkbtn),
+                                                                FALSE);
+       
+       }
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync),
+                                                                item->prefs->offlinesync);
+       rowcount++;
+
        gtk_widget_show_all(table);
 
        page->table = table;
@@ -283,12 +309,14 @@ void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->folder_color_btn = folder_color_btn;
        page->checkbtn_enable_processing = checkbtn_enable_processing;
        page->checkbtn_newmailcheck = checkbtn_newmailcheck;
+       page->checkbtn_offlinesync = checkbtn_offlinesync;
 
        page->simplify_subject_rec_checkbtn  = simplify_subject_rec_checkbtn;
        page->folder_chmod_rec_checkbtn      = folder_chmod_rec_checkbtn;
        page->folder_color_rec_checkbtn      = folder_color_rec_checkbtn;
        page->enable_processing_rec_checkbtn = enable_processing_rec_checkbtn;
        page->newmailcheck_rec_checkbtn      = newmailcheck_rec_checkbtn;
+       page->offlinesync_rec_checkbtn       = offlinesync_rec_checkbtn;
 
        page->page.widget = table;
 }
@@ -348,6 +376,11 @@ static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_newmailcheck));
        }
 
+       if (all ||  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn))) {
+               prefs->offlinesync = 
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_offlinesync));
+       }
+
        folder_item_prefs_save_config(folder);
 }      
 
@@ -369,7 +402,8 @@ static gboolean general_save_recurse_func(GNode *node, gpointer data)
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn)) ||
-             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn))))
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn)) ||
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn))))
                return TRUE;
        else 
                return FALSE;