2007-07-20 [colin] 2.10.0cvs51
authorColin Leroy <colin@colino.net>
Fri, 20 Jul 2007 16:20:59 +0000 (16:20 +0000)
committerColin Leroy <colin@colino.net>
Fri, 20 Jul 2007 16:20:59 +0000 (16:20 +0000)
* src/folder.c
* src/folder.h
* src/folder_item_prefs.c
* src/folder_item_prefs.h
* src/folderview.c
* src/imap.c
* src/imap_gtk.c
* src/imap_gtk.h
* src/news.c
* src/news_gtk.c
* src/news_gtk.h
* src/prefs_folder_item.c
Implement age-based caching: allow to
specify a threshold for the offline synchronisation
feature, and whether old cached bodies should
be removed
* src/toolbar.c
* src/toolbar.h
Fix label/tooltips
* src/plugins/dillo_viewer/dillo_viewer.c
Check that Dillo's installed

18 files changed:
ChangeLog
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/folder_item_prefs.c
src/folder_item_prefs.h
src/folderview.c
src/imap.c
src/imap_gtk.c
src/imap_gtk.h
src/news.c
src/news_gtk.c
src/news_gtk.h
src/plugins/dillo_viewer/dillo_viewer.c
src/prefs_folder_item.c
src/toolbar.c
src/toolbar.h

index 2f10e22..533d8f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2007-07-20 [colin]     2.10.0cvs51
+
+       * src/folder.c
+       * src/folder.h
+       * src/folder_item_prefs.c
+       * src/folder_item_prefs.h
+       * src/folderview.c
+       * src/imap.c
+       * src/imap_gtk.c
+       * src/imap_gtk.h
+       * src/news.c
+       * src/news_gtk.c
+       * src/news_gtk.h
+       * src/prefs_folder_item.c
+               Implement age-based caching: allow to
+               specify a threshold for the offline synchronisation
+               feature, and whether old cached bodies should 
+               be removed
+       * src/toolbar.c
+       * src/toolbar.h
+               Fix label/tooltips
+       * src/plugins/dillo_viewer/dillo_viewer.c
+               Check that Dillo's installed
+
 2007-07-20 [wwp]       2.10.0cvs50
 
        * src/mimeview.c
index cafe3bc..59c644e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.274.2.199 -r 1.274.2.200 src/mainwindow.c;  cvs diff -u -r 1.94.2.141 -r 1.94.2.142 src/messageview.c;  cvs diff -u -r 1.43.2.76 -r 1.43.2.77 src/toolbar.c;  cvs diff -u -r 1.19.2.19 -r 1.19.2.20 src/toolbar.h;  ) > 2.10.0cvs48.patchset
 ( cvs diff -u -r 1.115.2.159 -r 1.115.2.160 src/main.c;  cvs diff -u -r 1.1.2.58 -r 1.1.2.59 src/wizard.c;  ) > 2.10.0cvs49.patchset
 ( cvs diff -u -r 1.83.2.111 -r 1.83.2.112 src/mimeview.c;  cvs diff -u -r 1.25.2.43 -r 1.25.2.44 src/stock_pixmap.c;  ) > 2.10.0cvs50.patchset
+( cvs diff -u -r 1.213.2.150 -r 1.213.2.151 src/folder.c;  cvs diff -u -r 1.87.2.44 -r 1.87.2.45 src/folder.h;  cvs diff -u -r 1.2.2.21 -r 1.2.2.22 src/folder_item_prefs.c;  cvs diff -u -r 1.2.2.10 -r 1.2.2.11 src/folder_item_prefs.h;  cvs diff -u -r 1.207.2.168 -r 1.207.2.169 src/folderview.c;  cvs diff -u -r 1.179.2.176 -r 1.179.2.177 src/imap.c;  cvs diff -u -r 1.1.2.47 -r 1.1.2.48 src/imap_gtk.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/imap_gtk.h;  cvs diff -u -r 1.101.2.39 -r 1.101.2.40 src/news.c;  cvs diff -u -r 1.2.2.23 -r 1.2.2.24 src/news_gtk.c;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/news_gtk.h;  cvs diff -u -r 1.52.2.41 -r 1.52.2.42 src/prefs_folder_item.c;  cvs diff -u -r 1.43.2.77 -r 1.43.2.78 src/toolbar.c;  cvs diff -u -r 1.19.2.20 -r 1.19.2.21 src/toolbar.h;  cvs diff -u -r 1.12.2.22 -r 1.12.2.23 src/plugins/dillo_viewer/dillo_viewer.c;  ) > 2.10.0cvs51.patchset
index bd02336..7b8b5e7 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=10
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=50
+EXTRA_VERSION=51
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8105720..5ed9790 100644 (file)
@@ -2298,6 +2298,38 @@ void folder_clean_cache_memory(FolderItem *protected_item)
        }
 }
 
+static void folder_item_remove_cached_msg(FolderItem *item, MsgInfo *msginfo)
+{
+       Folder *folder = item->folder;
+
+       g_return_if_fail(folder != NULL);
+
+       if (folder->klass->remove_cached_msg == NULL)
+               return;
+       
+       folder->klass->remove_cached_msg(folder, item, msginfo);
+}
+
+static void folder_item_clean_local_files(FolderItem *item, gint days)
+{
+       g_return_if_fail(item != NULL);
+       g_return_if_fail(item->folder != NULL);
+
+       if (FOLDER_TYPE(item->folder) == F_IMAP ||
+           FOLDER_TYPE(item->folder) == F_NEWS) {
+               GSList *msglist = folder_item_get_msg_list(item);
+               GSList *cur;
+               time_t t = time(NULL);
+               for (cur = msglist; cur; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       gint age = (t - msginfo->date_t) / (60*60*24);
+                       if (age > days)
+                               folder_item_remove_cached_msg(item, msginfo);
+               }
+               procmsg_msg_list_free(msglist);
+       }
+}
+
 static void folder_item_read_cache(FolderItem *item)
 {
        gchar *cache_file, *mark_file, *tags_file;
@@ -4071,7 +4103,11 @@ void folder_item_synchronise(FolderItem *item)
                return;
        if (item->prefs->offlinesync && item->folder->klass->synchronise) {
                statusbar_print_all(_("Synchronising %s for offline use...\n"), item->path ? item->path : "(null)");
-               item->folder->klass->synchronise(item);
+               item->folder->klass->synchronise(item, 
+                       item->prefs->offlinesync_days);
+               if (item->prefs->offlinesync_days > 0 &&
+                   item->prefs->remove_old_bodies)
+                       folder_item_clean_local_files(item, item->prefs->offlinesync_days);
                statusbar_pop_all();
        }
 }
index f9d58e8..828dbf4 100644 (file)
@@ -583,8 +583,10 @@ struct _FolderClass
        /* Called when switching offline or asking for synchronisation. the imple
         * mentation should do what's necessary to be able to read mails present
         * in the FolderItem at this time with no network connectivity. 
+        * Days: max number of days of mail to fetch.
         */
-       void            (*synchronise)          (FolderItem     *item);
+       void            (*synchronise)          (FolderItem     *item,
+                                                gint            days);
        
        /* Passed from claws-mail --subscribe scheme://uri. Implementations
         * should check if they handle this type of URI, and return TRUE in this
@@ -605,6 +607,10 @@ struct _FolderClass
        void            (*copy_private_data)    (Folder         *folder,
                                                 FolderItem     *src,
                                                 FolderItem     *dest);
+
+       void            (*remove_cached_msg)    (Folder         *folder,
+                                                FolderItem     *item,
+                                                MsgInfo        *msginfo);
 };
 
 struct _FolderItem
index 6a40ab5..2f93623 100644 (file)
@@ -95,6 +95,10 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"offlinesync", "FALSE", &tmp_prefs.offlinesync, P_BOOL,
         NULL, NULL, NULL},
+       {"offlinesync_days", "0", &tmp_prefs.offlinesync_days, P_INT,
+        NULL, NULL, NULL},
+       {"remove_old_bodies", "FALSE", &tmp_prefs.remove_old_bodies, P_BOOL,
+        NULL, NULL, NULL},
 
        {"compose_with_format", "FALSE", &tmp_prefs.compose_with_format, P_BOOL,
         NULL, NULL, NULL},
@@ -206,6 +210,8 @@ static FolderItemPrefs *folder_item_prefs_clear(FolderItemPrefs *prefs)
 
        prefs->newmailcheck = TRUE;
        prefs->offlinesync = FALSE;
+       prefs->offlinesync_days = 0;
+       prefs->remove_old_bodies = FALSE;
 
        prefs->compose_with_format = FALSE;
        prefs->compose_subject_format = NULL;
@@ -261,7 +267,9 @@ 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;
+       tmp_prefs.offlinesync                   = src->prefs->offlinesync;
+       tmp_prefs.offlinesync_days              = src->prefs->offlinesync_days;
+       tmp_prefs.remove_old_bodies             = src->prefs->remove_old_bodies;
 
        prefs_matcher_read_config();
 
index c7d3f76..ce622c7 100644 (file)
@@ -46,6 +46,8 @@ struct _FolderItemPrefs {
 
        int newmailcheck;
        int offlinesync;
+       int offlinesync_days;
+       int remove_old_bodies;
 
        gboolean request_return_receipt;
        gboolean enable_default_to;
index 6eeed53..cfade1b 100644 (file)
@@ -534,8 +534,12 @@ static GtkWidget *folderview_ctree_create(FolderView *folderview)
                         folderview);
        g_signal_connect(G_OBJECT(ctree), "tree_select_row",
                         G_CALLBACK(folderview_selected), folderview);
+#ifndef MAEMO
+       /* drag-n-dropping folders on maemo is impractical as this 
+        * opens the folder almost everytime */
        g_signal_connect(G_OBJECT(ctree), "start_drag",
                         G_CALLBACK(folderview_start_drag), folderview);
+#endif
        g_signal_connect(G_OBJECT(ctree), "drag_data_get",
                         G_CALLBACK(folderview_drag_data_get),
                         folderview);
index ebcc9f9..8ac2600 100644 (file)
@@ -198,6 +198,9 @@ static gchar   *imap_fetch_msg_full (Folder         *folder,
                                         gint            uid,
                                         gboolean        headers,
                                         gboolean        body);
+static void    imap_remove_cached_msg  (Folder         *folder, 
+                                        FolderItem     *item, 
+                                        MsgInfo        *msginfo);
 static gint    imap_add_msg            (Folder         *folder,
                                         FolderItem     *dest,
                                         const gchar    *file, 
@@ -303,7 +306,7 @@ static gchar imap_get_path_separator                (IMAPSession    *session,
 static gchar *imap_get_real_path               (IMAPSession    *session,
                                                 IMAPFolder     *folder,
                                                 const gchar    *path);
-static void imap_synchronise           (FolderItem     *item);
+static void imap_synchronise           (FolderItem     *item, gint days);
 static gboolean imap_is_busy           (Folder *folder);
 
 static void imap_free_capabilities     (IMAPSession    *session);
@@ -471,6 +474,7 @@ FolderClass *imap_get_class(void)
                imap_class.get_flags = imap_get_flags;
                imap_class.set_batch = imap_set_batch;
                imap_class.synchronise = imap_synchronise;
+               imap_class.remove_cached_msg = imap_remove_cached_msg;
 #ifdef USE_PTREAD
                pthread_mutex_init(&imap_mutex, NULL);
 #endif
@@ -1006,6 +1010,26 @@ static guint get_file_size_with_crs(const gchar *filename)
        return cnt;
 }
 
+static void imap_remove_cached_msg(Folder *folder, FolderItem *item, MsgInfo *msginfo)
+{
+       gchar *path, *filename;
+
+       path = folder_item_get_path(item);
+
+       if (!is_dir_exist(path)) {
+               g_free(path);
+               return;
+       }
+
+       filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL);
+       g_free(path);
+
+       if (is_file_exist(filename)) {
+               g_unlink(filename);
+       }
+       g_free(filename);
+}
+
 static gchar *imap_fetch_msg_full(Folder *folder, FolderItem *item, gint uid,
                                  gboolean headers, gboolean body)
 {
@@ -4824,7 +4848,7 @@ gboolean imap_cancel_all_enabled(void)
 
 #endif
 
-void imap_synchronise(FolderItem *item) 
+void imap_synchronise(FolderItem *item, gint days
 {
 #ifdef HAVE_LIBETPAN
        if (IMAP_FOLDER_ITEM(item)->last_sync == IMAP_FOLDER_ITEM(item)->last_change) {
@@ -4832,7 +4856,7 @@ void imap_synchronise(FolderItem *item)
                return;
        }
        debug_print("syncing %s\n", item->path?item->path:item->name);
-       imap_gtk_synchronise(item);
+       imap_gtk_synchronise(item, days);
        IMAP_FOLDER_ITEM(item)->last_sync = IMAP_FOLDER_ITEM(item)->last_change;
 #endif
 }
index 6202c8a..c9453d6 100644 (file)
@@ -360,7 +360,7 @@ static void sync_cb(FolderView *folderview, guint action,
        folder_synchronise(item->folder);
 }
 
-void imap_gtk_synchronise(FolderItem *item)
+void imap_gtk_synchronise(FolderItem *item, gint days)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
        FolderView *folderview = mainwin->folderview;
@@ -379,11 +379,14 @@ void imap_gtk_synchronise(FolderItem *item)
                GSList *cur;
                gint num = 0;
                gint total = item->total_msgs;
+               time_t t = time(NULL);
 
                mlist = folder_item_get_msg_list(item);
                for (cur = mlist; cur != NULL; cur = cur->next) {
                        MsgInfo *msginfo = (MsgInfo *)cur->data;
-                       imap_cache_msg(msginfo->folder, msginfo->msgnum);
+                       gint age = (t - msginfo->date_t) / (60*60*24);
+                       if (days == 0 || age <= days)
+                               imap_cache_msg(msginfo->folder, msginfo->msgnum);
                        statusbar_progress_all(num++,total, 100);
                        if (num % 100 == 0)
                                GTK_EVENTS_FLUSH();
@@ -399,7 +402,6 @@ void imap_gtk_synchronise(FolderItem *item)
        main_window_unlock(mainwin);
        inc_unlock();
        main_window_cursor_normal(mainwin);
-
 }
 
 static void chk_update_val(GtkWidget *widget, gpointer data)
@@ -547,5 +549,5 @@ static void download_cb(FolderView *folderview, guint action,
        if (!folderview->selected) return;
 
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
-       imap_gtk_synchronise(item);
+       imap_gtk_synchronise(item, 0);
 }
index 2b46c5a..260277b 100644 (file)
@@ -29,7 +29,7 @@
 #include "folder.h"
 
 void imap_gtk_init(void);
-void imap_gtk_synchronise(FolderItem *item);
+void imap_gtk_synchronise(FolderItem *item, gint days);
 gboolean imap_gtk_should_override(void);
 
 #endif /* IMAP_GTK_H */
index 6ae7bd0..dd81ba8 100644 (file)
@@ -85,8 +85,9 @@ static void    news_folder_destroy    (Folder         *folder);
 static gchar *news_fetch_msg           (Folder         *folder,
                                         FolderItem     *item,
                                         gint            num);
-
-
+static void news_remove_cached_msg     (Folder         *folder, 
+                                        FolderItem     *item, 
+                                        MsgInfo        *msginfo);
 #if USE_OPENSSL
 static Session *news_session_new        (const gchar   *server,
                                          gushort        port,
@@ -134,7 +135,7 @@ static gint news_post_stream                         (Folder        *folder,
 static gchar *news_folder_get_path      (Folder        *folder);
 static gchar *news_item_get_path                (Folder        *folder,
                                          FolderItem    *item);
-static void news_synchronise            (FolderItem    *item);
+static void news_synchronise            (FolderItem    *item, gint days);
 static int news_remove_msg              (Folder        *folder, 
                                          FolderItem    *item, 
                                          gint           msgnum);
@@ -165,6 +166,7 @@ FolderClass *news_get_class(void)
                news_class.fetch_msg = news_fetch_msg;
                news_class.synchronise = news_synchronise;
                news_class.remove_msg = news_remove_msg;
+               news_class.remove_cached_msg = news_remove_cached_msg;
        };
 
        return &news_class;
@@ -357,6 +359,26 @@ static NNTPSession *news_session_get(Folder *folder)
        return NNTP_SESSION(rfolder->session);
 }
 
+static void news_remove_cached_msg(Folder *folder, FolderItem *item, MsgInfo *msginfo)
+{
+       gchar *path, *filename;
+
+       path = folder_item_get_path(item);
+
+       if (!is_dir_exist(path)) {
+               g_free(path);
+               return;
+       }
+
+       filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(msginfo->msgnum), NULL);
+       g_free(path);
+
+       if (is_file_exist(filename)) {
+               g_unlink(filename);
+       }
+       g_free(filename);
+}
+
 static gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num)
 {
        gchar *path, *filename;
@@ -1225,9 +1247,9 @@ static gboolean news_scan_required(Folder *folder, FolderItem *item)
        return TRUE;
 }
 
-void news_synchronise(FolderItem *item) 
+void news_synchronise(FolderItem *item, gint days
 {
-       news_gtk_synchronise(item);
+       news_gtk_synchronise(item, days);
 }
 
 static gint news_remove_folder(Folder *folder, FolderItem *item)
index d7863f9..77c54f2 100644 (file)
@@ -278,33 +278,44 @@ static void sync_cb(FolderView *folderview, guint action,
        folder_synchronise(item->folder);
 }
 
-void news_gtk_synchronise(FolderItem *item)
+void news_gtk_synchronise(FolderItem *item, gint days)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
        FolderView *folderview = mainwin->folderview;
-       
+       GSList *mlist;
+       GSList *cur;
+       gint num = 0;
+       gint total = 0;
+       time_t t = time(NULL);
+
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->folder != NULL);
 
        if (mainwin->lock_count || news_folder_locked(item->folder))
                return;
 
+       total = item->total_msgs;
+
        main_window_cursor_wait(mainwin);
        inc_lock();
        main_window_lock(mainwin);
        gtk_widget_set_sensitive(folderview->ctree, FALSE);
        main_window_progress_on(mainwin);
        GTK_EVENTS_FLUSH();
-       if (folder_item_fetch_all_msg(item) < 0) {
-               gchar *name;
-
-               name = trim_string(item->name, 32);
-               if (prefs_common.no_recv_err_panel)
-                       log_error(LOG_PROTOCOL, _("Error occurred while downloading messages in '%s'."), name);
-               else
-                       alertpanel_error(_("Error occurred while downloading messages in '%s'."), name);
-               g_free(name);
+
+       mlist = folder_item_get_msg_list(item);
+       for (cur = mlist; cur != NULL; cur = cur->next) {
+               MsgInfo *msginfo = (MsgInfo *)cur->data;
+               gint age = (t - msginfo->date_t) / (60*60*24);
+               if (days == 0 || age <= days)
+                       folder_item_fetch_msg_full(msginfo->folder, msginfo->msgnum, TRUE, TRUE);
+               statusbar_progress_all(num++,total, 100);
+               if (num % 100 == 0)
+                       GTK_EVENTS_FLUSH();
        }
+
+       statusbar_progress_all(0,0,0);
+       procmsg_msg_list_free(mlist);
        folder_set_ui_func(item->folder, NULL, NULL);
        main_window_progress_off(mainwin);
        gtk_widget_set_sensitive(folderview->ctree, TRUE);
@@ -322,5 +333,5 @@ static void download_cb(FolderView *folderview, guint action,
        if (!folderview->selected) return;
 
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
-       news_gtk_synchronise(item);
+       news_gtk_synchronise(item, 0);
 }
index 0fd4fe3..8408f76 100644 (file)
@@ -27,5 +27,5 @@
 #include "folder.h"
 
 void news_gtk_init(void);
-void news_gtk_synchronise(FolderItem *item);
+void news_gtk_synchronise(FolderItem *item, gint days);
 #endif /* NEWS_GTK_H */
index 19770c0..7ac7a50 100644 (file)
@@ -167,10 +167,17 @@ static MimeViewerFactory dillo_viewer_factory =
 
 gint plugin_init(gchar **error)
 {
+       gchar *dillo_path = NULL;
        if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
                                VERSION_NUMERIC, PLUGIN_NAME, error))
                return -1;
 
+       if ((dillo_path = g_find_program_in_path("dillo")) == NULL) {
+               *error = g_strdup(_("Can't find the dillo executable in PATH. Is it installed?"));
+               return -1;
+       }
+       g_free(dillo_path);
+
         dillo_prefs_init();
 
        mimeview_register_viewer_factory(&dillo_viewer_factory);
index 3d0b3e9..61ae493 100644 (file)
@@ -82,7 +82,11 @@ struct _FolderItemGeneralPage
        GtkWidget *checkbtn_enable_processing;
        GtkWidget *checkbtn_newmailcheck;
        GtkWidget *checkbtn_offlinesync;
-
+       GtkWidget *label_offlinesync;
+       GtkWidget *entry_offlinesync;
+       GtkWidget *label_end_offlinesync;
+       GtkWidget *checkbtn_remove_old_offlinesync;
+       
        /* apply to sub folders */
        GtkWidget *simplify_subject_rec_checkbtn;
        GtkWidget *folder_chmod_rec_checkbtn;
@@ -181,7 +185,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        guint rowcount;
 
        GtkWidget *table;
-       GtkWidget *hbox;
+       GtkWidget *hbox, *hbox2, *hbox_spc;
        GtkWidget *label;
        
        GtkWidget *folder_type_menu;
@@ -206,6 +210,10 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        GtkWidget *checkbtn_enable_processing;
        GtkWidget *checkbtn_newmailcheck;
        GtkWidget *checkbtn_offlinesync;
+       GtkWidget *label_offlinesync;
+       GtkWidget *entry_offlinesync;
+       GtkWidget *label_end_offlinesync;
+       GtkWidget *checkbtn_remove_old_offlinesync;
 
        GtkWidget *simplify_subject_rec_checkbtn;
        GtkWidget *folder_chmod_rec_checkbtn;
@@ -218,7 +226,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->item         = item;
 
        /* Table */
-       table = gtk_table_new(7, 4, FALSE);
+       table = gtk_table_new(9, 4, FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 4);
@@ -443,20 +451,72 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        gtk_table_attach(GTK_TABLE(table), offlinesync_rec_checkbtn, 3, 4, 
                         rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
+       rowcount++;
+
+       hbox = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox);
+       gtk_table_attach(GTK_TABLE(table), hbox, 0, 4,
+                        rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+       rowcount++;
+
+       hbox_spc = gtk_hbox_new (FALSE, 0);
+       gtk_widget_show (hbox_spc);
+       gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
+       gtk_widget_set_size_request (hbox_spc, 12, -1);
+
+       label_offlinesync = gtk_label_new(_("Fetch bodies for the last"));
+       gtk_widget_show (label_offlinesync);
+       gtk_box_pack_start (GTK_BOX (hbox), label_offlinesync, FALSE, FALSE, 0);
+
+       entry_offlinesync = gtk_entry_new();
+       gtk_widget_set_size_request (entry_offlinesync, 64, -1);
+       gtk_widget_show (entry_offlinesync);
+       gtk_box_pack_start (GTK_BOX (hbox), entry_offlinesync, FALSE, FALSE, 0);
+
+       label_end_offlinesync = gtk_label_new(_("days (0: all bodies)"));
+       gtk_widget_show (label_end_offlinesync);
+       gtk_box_pack_start (GTK_BOX (hbox), label_end_offlinesync, FALSE, FALSE, 0);
+
+       checkbtn_remove_old_offlinesync = gtk_check_button_new_with_label(_("Remove older bodies"));
+
+       hbox2 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox2);
+       gtk_table_attach(GTK_TABLE(table), hbox2, 0, 4,
+                        rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+       rowcount++;
+
+       hbox_spc = gtk_hbox_new (FALSE, 0);
+       gtk_widget_show (hbox_spc);
+       gtk_box_pack_start (GTK_BOX (hbox2), hbox_spc, FALSE, FALSE, 0);
+       gtk_widget_set_size_request (hbox_spc, 12, -1);
+       gtk_box_pack_start (GTK_BOX (hbox2), checkbtn_remove_old_offlinesync, FALSE, FALSE, 0);
+
+       SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox);
+       SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox2);
+       
+       gtk_widget_show_all(table);
+
        if (item->folder && (item->folder->klass->type != F_IMAP && 
            item->folder->klass->type != F_NEWS)) {
-                item->prefs->offlinesync = TRUE;
+               item->prefs->offlinesync = TRUE;
+               item->prefs->offlinesync_days = 0;
+               item->prefs->remove_old_bodies = FALSE;
+
                gtk_widget_set_sensitive(GTK_WIDGET(checkbtn_offlinesync),
                                                                 FALSE);
                gtk_widget_set_sensitive(GTK_WIDGET(offlinesync_rec_checkbtn),
                                                                 FALSE);
+               gtk_widget_hide(GTK_WIDGET(checkbtn_offlinesync));
+               gtk_widget_hide(GTK_WIDGET(hbox));
+               gtk_widget_hide(GTK_WIDGET(hbox2));
+               gtk_widget_hide(GTK_WIDGET(offlinesync_rec_checkbtn));
        
        }
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync),
                                                                 item->prefs->offlinesync);
-       rowcount++;
-
-       gtk_widget_show_all(table);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_remove_old_offlinesync),
+                                                                item->prefs->remove_old_bodies);
+       gtk_entry_set_text(GTK_ENTRY(entry_offlinesync), itos(item->prefs->offlinesync_days));
 
        page->table = table;
        page->folder_type = folder_type;
@@ -471,6 +531,10 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->checkbtn_enable_processing = checkbtn_enable_processing;
        page->checkbtn_newmailcheck = checkbtn_newmailcheck;
        page->checkbtn_offlinesync = checkbtn_offlinesync;
+       page->label_offlinesync = label_offlinesync;
+       page->entry_offlinesync = entry_offlinesync;
+       page->label_end_offlinesync = label_end_offlinesync;
+       page->checkbtn_remove_old_offlinesync = checkbtn_remove_old_offlinesync;
 
        page->simplify_subject_rec_checkbtn  = simplify_subject_rec_checkbtn;
        page->folder_chmod_rec_checkbtn      = folder_chmod_rec_checkbtn;
@@ -556,6 +620,10 @@ static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage
        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));
+               prefs->offlinesync_days = 
+                       atoi(gtk_entry_get_text(GTK_ENTRY(page->entry_offlinesync)));
+               prefs->remove_old_bodies =
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_remove_old_offlinesync));
        }
 
        folder_item_prefs_save_config(folder);
index 326255d..8079c46 100644 (file)
@@ -783,11 +783,15 @@ static void activate_compose_button (Toolbar           *toolbar,
                gtk_tool_button_set_icon_widget(
                        GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
                        toolbar->compose_news_icon);
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->compose_mail_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Compose News message"), NULL);       
                gtk_widget_show(toolbar->compose_news_icon);
        } else {
                gtk_tool_button_set_icon_widget(
                        GTK_TOOL_BUTTON(toolbar->compose_mail_btn),
                        toolbar->compose_mail_icon);
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->compose_mail_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Compose Email"), NULL);      
                gtk_widget_show(toolbar->compose_mail_icon);
        }
        toolbar->compose_btn_type = type;
@@ -815,7 +819,9 @@ static void activate_learn_button (Toolbar           *toolbar,
                        toolbar->learn_spam_icon);
                gtk_tool_button_set_label(
                        GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
-                       _("Learn Spam"));
+                       _("Spam"));
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->learn_spam_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Learn spam"), NULL); 
                gtk_widget_show(toolbar->learn_spam_icon);
        } else {
                gtk_tool_button_set_icon_widget(
@@ -823,7 +829,9 @@ static void activate_learn_button (Toolbar           *toolbar,
                        toolbar->learn_ham_icon);
                gtk_tool_button_set_label(
                        GTK_TOOL_BUTTON(toolbar->learn_spam_btn),
-                       _("Learn Ham"));
+                       _("Ham"));
+               gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar->learn_spam_btn), GTK_TOOLTIPS(toolbar->tooltips),
+                       _("Learn ham"), NULL);  
                gtk_widget_show(toolbar->learn_ham_icon);
        }
        toolbar->learn_btn_type = type; 
@@ -1734,7 +1742,7 @@ Toolbar *toolbar_create(ToolbarType        type,
                        break;
                case A_LEARN_SPAM:
                        TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
-                               _("Learn Spam"),
+                               _("Spam"),
                                _("Learn as..."));
                        toolbar_data->learn_spam_btn = item; 
                        toolbar_data->learn_spam_icon = icon_wid; 
@@ -1908,6 +1916,7 @@ Toolbar *toolbar_create(ToolbarType        type,
 
        }
        toolbar_data->toolbar = toolbar;
+       toolbar_data->tooltips = toolbar_tips;
        gtk_widget_show_all(toolbar);
 
        if (type == TOOLBAR_MAIN) {
index 0dd4914..c6c7388 100644 (file)
@@ -101,6 +101,7 @@ struct _Toolbar {
        GSList    *action_list;
        GSList    *item_list;
 
+       GtkTooltips *tooltips;
 };
 
 struct _ToolbarItem {