2007-05-15 [colin] 2.9.2cvs9
authorColin Leroy <colin@colino.net>
Tue, 15 May 2007 18:45:52 +0000 (18:45 +0000)
committerColin Leroy <colin@colino.net>
Tue, 15 May 2007 18:45:52 +0000 (18:45 +0000)
* src/main.c
* src/main.h
Add a public function to know whether Claws
crashed last time
Store opened folder when exiting
* src/folder.c
* src/folder.h
Store last opened message in each FolderItem;
Reset last seen messages if Claws crashed, so
that one can't go in an infinite crash in case
a particular mail crashes Claws.
* src/messageview.c
* src/prefs_common.c
* src/prefs_common.h
* src/summaryview.c
* src/prefs_summaries.c
Add "Select last opened message" when entering
a folder
Add "Select last opened folder" at startup.

12 files changed:
ChangeLog
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/main.c
src/main.h
src/messageview.c
src/prefs_common.c
src/prefs_common.h
src/prefs_summaries.c
src/summaryview.c

index e0e15a339cfa441ef97517da72015eeb0e78ee43..b49d0e368a3c9edae3c847ad1b4a7394067a3a53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2007-05-15 [colin]     2.9.2cvs9
+
+       * src/main.c
+       * src/main.h
+               Add a public function to know whether Claws
+               crashed last time
+               Store opened folder when exiting
+       * src/folder.c
+       * src/folder.h
+               Store last opened message in each FolderItem;
+               Reset last seen messages if Claws crashed, so 
+               that one can't go in an infinite crash in case 
+               a particular mail crashes Claws.
+       * src/messageview.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/summaryview.c
+       * src/prefs_summaries.c
+               Add "Select last opened message" when entering
+               a folder
+               Add "Select last opened folder" at startup.
+
 2007-05-14 [colin]     2.9.2cvs8
 
        * manual/xml2pdf
index 944677f16c39772b04c4ac1d1232b68729ec0ab9..dc976e481f9eb42320972a6bd19204492e5c37ba 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2.2.33 -r 1.2.2.34 src/gtk/filesel.c;  ) > 2.9.2cvs6.patchset
 ( cvs diff -u -r 1.1.4.29 -r 1.1.4.30 src/gtk/logwindow.c;  ) > 2.9.2cvs7.patchset
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 manual/xml2pdf;  ) > 2.9.2cvs8.patchset
+( cvs diff -u -r 1.213.2.144 -r 1.213.2.145 src/folder.c;  cvs diff -u -r 1.87.2.40 -r 1.87.2.41 src/folder.h;  cvs diff -u -r 1.115.2.152 -r 1.115.2.153 src/main.c;  cvs diff -u -r 1.7.2.10 -r 1.7.2.11 src/main.h;  cvs diff -u -r 1.94.2.133 -r 1.94.2.134 src/messageview.c;  cvs diff -u -r 1.204.2.134 -r 1.204.2.135 src/prefs_common.c;  cvs diff -u -r 1.103.2.82 -r 1.103.2.83 src/prefs_common.h;  cvs diff -u -r 1.1.2.40 -r 1.1.2.41 src/prefs_summaries.c;  cvs diff -u -r 1.395.2.302 -r 1.395.2.303 src/summaryview.c;  ) > 2.9.2cvs9.patchset
index 4b93a53c19445410008b38be2681820e213b0fd1..87402c5212a3d8dab121d4f1301c27f57e0f9c63 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=8
+EXTRA_VERSION=9
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b2a17dc22256c13d1a6703dfcbd2cf03d3963542..665c5fa2b58fd31a3ab7507795a8514b3af18db4 100644 (file)
@@ -57,6 +57,7 @@
 #include "gtkutils.h"
 #include "timing.h"
 #include "compose.h"
+#include "main.h"
 
 /* Dependecies to be removed ?! */
 #include "prefs_common.h"
@@ -586,8 +587,14 @@ void folder_item_set_xml(Folder *folder, FolderItem *item, XMLTag *tag)
                                g_warning("account_id: %s not found\n", attr->value);
                        else
                                item->account = account;
-               } else if (!strcmp(attr->name, "apply_sub"))
+               } else if (!strcmp(attr->name, "apply_sub")) {
                        item->apply_sub = *attr->value == '1' ? TRUE : FALSE;
+               } else if (!strcmp(attr->name, "last_seen")) {
+                       if (!claws_crashed())
+                               item->last_seen = atoi(attr->value);
+                       else
+                               item->last_seen = 0;
+               }
        }
 }
 
@@ -640,6 +647,8 @@ XMLTag *folder_item_get_xml(Folder *folder, FolderItem *item)
        if (item->apply_sub)
                xml_tag_add_attr(tag, xml_attr_new("apply_sub", "1"));
 
+       xml_tag_add_attr(tag, xml_attr_new_int("last_seen", item->last_seen));
+
        return tag;
 }
 
index 773fe02f3fedec8d10b727a9c4e10024e8c27eee..48e4c13a9a2692fb73559b4804fb50e3e6c60b6e 100644 (file)
@@ -661,6 +661,7 @@ struct _FolderItem
        SpecialFolderItemType parent_stype;
        gboolean processing_pending;
        gboolean scanning;
+       guint last_seen;
 };
 
 struct _PersistPrefs
index e856fe4850455f237be05f2cb30cfe472c13502e..d144f15ba59c8b1528e386c93fc6c726f29e295d 100644 (file)
@@ -607,6 +607,11 @@ static void sc_session_manager_connect(MainWindow *mainwin)
 static gboolean sc_exiting = FALSE;
 static gboolean sc_starting = FALSE;
 static gboolean show_at_startup = TRUE;
+static gboolean claws_crashed_bool = FALSE;
+
+gboolean claws_crashed(void) {
+       return claws_crashed_bool;
+}
 
 void main_set_show_at_startup(gboolean show)
 {
@@ -787,6 +792,9 @@ int main(int argc, char *argv[])
        remove_all_files(get_tmp_dir());
        remove_all_files(get_mime_tmp_dir());
 
+       if (!cmd.crash && crash_file_present)
+               claws_crashed_bool = TRUE;
+
        if (is_file_exist("claws.log")) {
                if (rename_force("claws.log", "claws.log.bak") < 0)
                        FILE_OP_ERROR("claws.log", "rename");
@@ -927,7 +935,7 @@ int main(int argc, char *argv[])
 
        /* if crashed, show window early so that the user
         * sees what's happening */
-       if (!cmd.crash && crash_file_present)
+       if (claws_crashed())
                main_window_popup(mainwin);
 
 #ifdef HAVE_LIBETPAN
@@ -944,7 +952,7 @@ int main(int argc, char *argv[])
        folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
 
        /* if claws crashed, rebuild caches */
-       if (!cmd.crash && crash_file_present) {
+       if (claws_crashed()) {
                GTK_EVENTS_FLUSH();
                debug_print("Claws Mail crashed, checking for new messages in local folders\n");
                folder_item_update_thaw();
@@ -1001,7 +1009,7 @@ int main(int argc, char *argv[])
        plugin_load_standard_plugins ();
        
        /* if not crashed, show window now */
-       if (!(!cmd.crash && crash_file_present)) {
+       if (!claws_crashed()) {
                /* apart if something told not to show */
                if (show_at_startup)
                        main_window_popup(mainwin);
@@ -1039,6 +1047,12 @@ int main(int argc, char *argv[])
        gtk_clist_thaw(GTK_CLIST(mainwin->folderview->ctree));
        main_window_cursor_normal(mainwin);
 
+       if (!cmd.target && prefs_common.goto_last_folder_on_startup &&
+           folder_find_item_from_identifier(prefs_common.last_opened_folder) != NULL &&
+           !claws_crashed()) {
+               cmd.target = prefs_common.last_opened_folder;
+       }
+
        if (cmd.receive_all && !cmd.target) {
                g_timeout_add(1000, defer_check_all, GINT_TO_POINTER(FALSE));
        } else if (prefs_common.chk_on_startup && !cmd.target) {
@@ -1092,9 +1106,10 @@ static void save_all_caches(FolderItem *item, gpointer data)
                return;
        }
 
-       if (item->opened)
+       if (item->opened) {
                folder_item_close(item);
-       
+       }
+
        folder_item_free_cache(item, TRUE);
 }
 
@@ -1117,6 +1132,7 @@ static void exit_claws(MainWindow *mainwin)
 
                item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
                summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
+               prefs_common.last_opened_folder = folder_item_get_identifier(item);
        }
 
        /* save all state before exiting */
index 4fa2a6d00224e2ee535424abb0067852d6026fe1..3b35f749e81b46f01738d2ce985b73a38312c342 100644 (file)
@@ -32,5 +32,6 @@ gboolean claws_is_exiting(void);
 gboolean claws_is_starting(void);
 gchar *claws_get_socket_name(void);
 void main_set_show_at_startup(gboolean show);
+gboolean claws_crashed(void);
 
 #endif /* __MAIN_H__ */
index afdc55e10ccafe29b5a16c7f22a648a1c973ca1e..ebbe28307c62dd8ed6ecf7472ad065eec6a53718 100644 (file)
@@ -882,6 +882,10 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
                g_free(subject);
        }
 
+       if (msginfo && msginfo->folder) {
+               msginfo->folder->last_seen = msginfo->msgnum;   
+       }
+
        main_create_mailing_list_menu(messageview->mainwin, messageview->msginfo);
 
        if (messageview->msginfo->extradata
index 4c0faa36deb9ae831504223afcb95f042b25bc05..bde6eda22b0c040173630d5734f1fc20cb67f57a 100644 (file)
@@ -963,6 +963,10 @@ static PrefParam param[] = {
 #endif
        {"thread_by_subject_max_age", "10", &prefs_common.thread_by_subject_max_age,
        P_INT, NULL, NULL, NULL },
+       {"last_opened_folder", "", &prefs_common.last_opened_folder,
+       P_STRING, NULL, NULL, NULL },
+       {"goto_last_folder_on_startup", "FALSE", &prefs_common.goto_last_folder_on_startup,
+       P_BOOL, NULL, NULL, NULL },
        {"summary_quicksearch_sticky", "1", &prefs_common.summary_quicksearch_sticky, P_INT,
         NULL, NULL, NULL},
        {"summary_quicksearch_dynamic", "0", &prefs_common.summary_quicksearch_dynamic, P_INT,
index 3823270a49fafab64c45d6aedbc615f8ead7571f..29b8859afb8bc9cd48ae623683b5688c230a58ba 100644 (file)
@@ -70,7 +70,8 @@ typedef enum
        SELECTONENTRY_NUM,
        SELECTONENTRY_NMU,
        SELECTONENTRY_MNU,
-       SELECTONENTRY_MUN
+       SELECTONENTRY_MUN,
+       SELECTONENTRY_LAST
 } SelectOnEntry;
 
 typedef enum
@@ -199,6 +200,9 @@ struct _PrefsCommon
        gint thread_by_subject_max_age; /*!< Max. age of a thread which was threaded
                                         *   by subject (days) */
 
+       gchar *last_opened_folder;
+       gboolean goto_last_folder_on_startup;
+
        ToolbarStyle toolbar_style;
        gboolean toolbar_detachable;
        gboolean show_statusbar;
index 49c59ca2d92757fc366b8077f1a7c67cc62d37e3..7d45cdb140a3bde641f489173424e8d1e6f6aa46 100644 (file)
@@ -56,6 +56,7 @@ typedef struct _SummariesPage
        GtkWidget *button_datefmt;
        GtkWidget *entry_datefmt;
 
+       GtkWidget *checkbtn_reopen_last_folder;
        GtkWidget *checkbtn_always_show_msg;
        GtkWidget *checkbtn_mark_as_read_on_newwin;
        GtkWidget *spinbtn_mark_as_read_delay;
@@ -321,6 +322,7 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *button_dispitem;
 
        GtkWidget *hbox2;
+       GtkWidget *checkbtn_reopen_last_folder;
        GtkWidget *checkbtn_always_show_msg;
        GtkWidget *checkbtn_mark_as_read_on_newwin;
        GtkWidget *spinbtn_mark_as_read_delay;
@@ -368,6 +370,10 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        gtk_widget_show (hbox1);
        gtk_box_pack_start(GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
 
+       PACK_CHECK_BUTTON
+               (vbox2, checkbtn_reopen_last_folder,
+                _("Open last opened folder at startup"));
+
        label_ng_abbrev = gtk_label_new
                (_("Abbreviate newsgroup names longer than"));
        gtk_widget_show (label_ng_abbrev);
@@ -428,6 +434,8 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
                      SELECTONENTRY_MNU);
        MENUITEM_ADD (menu, menuitem, _("Select first marked (or unread or new) message"),
                      SELECTONENTRY_MUN);
+       MENUITEM_ADD (menu, menuitem, _("Select last opened message"),
+                     SELECTONENTRY_LAST);
 
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_select_on_entry), menu);
        gtk_box_pack_start(GTK_BOX(hbox1), optmenu_select_on_entry, FALSE, FALSE, 0);
@@ -573,6 +581,8 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        gtk_entry_set_text(GTK_ENTRY(entry_datefmt), 
                        prefs_common.date_format?prefs_common.date_format:"");  
 
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_reopen_last_folder),
+                       prefs_common.goto_last_folder_on_startup);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_always_show_msg),
                        prefs_common.always_show_msg);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_mark_as_read_on_newwin),
@@ -596,6 +606,7 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        prefs_summaries->checkbtn_threadsubj = checkbtn_threadsubj;
        prefs_summaries->entry_datefmt = entry_datefmt;
 
+       prefs_summaries->checkbtn_reopen_last_folder = checkbtn_reopen_last_folder;
        prefs_summaries->checkbtn_always_show_msg = checkbtn_always_show_msg;
        prefs_summaries->checkbtn_mark_as_read_on_newwin = checkbtn_mark_as_read_on_newwin;
        prefs_summaries->spinbtn_mark_as_read_delay = spinbtn_mark_as_read_delay;
@@ -632,6 +643,8 @@ static void prefs_summaries_save(PrefsPage *_page)
        prefs_common.date_format = gtk_editable_get_chars(
                        GTK_EDITABLE(page->entry_datefmt), 0, -1);      
 
+       prefs_common.goto_last_folder_on_startup = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_reopen_last_folder));
        prefs_common.always_show_msg = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_always_show_msg));
        prefs_common.mark_as_read_on_new_window = gtk_toggle_button_get_active(
index 99ded0428ed77a366c69d399e85351dc902d8355..56be5f88a6cbf792cafce8a908066a728d94bbc0 100644 (file)
@@ -1373,6 +1373,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                                        node = summary_find_next_flagged_msg(summaryview, NULL,
                                                                     MSG_NEW, FALSE);
                                break;
+                       case SELECTONENTRY_LAST:
+                               if (summaryview->folder_item) {
+                                       node = summary_find_msg_by_msgnum(summaryview, 
+                                                       summaryview->folder_item->last_seen);
+                               }
+                               break;
                        default:
                                node = NULL;
                }