diff options
Diffstat (limited to 'mail/message-list.c')
-rw-r--r-- | mail/message-list.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/mail/message-list.c b/mail/message-list.c index 4f02e1d7b8..22f6cb741d 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -87,6 +87,7 @@ static void select_msg (MessageList *message_list, gint row); static char *filter_date (const void *data); static void nuke_uids (GtkObject *o); +static char *folder_to_cachename(CamelFolder *folder, const char *prefix); static void save_tree_state(MessageList *ml); static struct { @@ -933,6 +934,20 @@ message_list_init_header (MessageList *message_list) } } +static void +save_header_state(MessageList *ml) +{ + char *filename; + + if (ml->folder == NULL + || ml->etable == NULL) + return; + + filename = folder_to_cachename(ml->folder, "et-header-"); + e_table_scrolled_save_specification(E_TABLE_SCROLLED(ml->etable), filename); + g_free(filename); +} + static char * message_list_get_layout (MessageList *message_list) { @@ -940,6 +955,39 @@ message_list_get_layout (MessageList *message_list) return g_strdup ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 3 </column> <column> 4 </column> <column> 5 </column> </columns-shown> <grouping> </grouping> </ETableSpecification>"); } +static void +message_list_setup_etable(MessageList *message_list) +{ + char *spec = "<ETableSpecification> <columns-shown> " + "<column> 0 </column> <column> 7 </column>" + "<column> 4 </column> <column> 5 </column> " + "</columns-shown> <grouping> </grouping> </ETableSpecification>"; + + /* build the spec based on the folder, and possibly from a saved file */ + /* otherwise, leave default */ + if (message_list->folder) { + char *name; + char *path; + struct stat st; + + path = folder_to_cachename(message_list->folder, "et-header-"); + if (stat(path, &st) == 0 && st.st_size > 0 && S_ISREG(st.st_mode)) { + e_table_scrolled_load_specification(E_TABLE_SCROLLED(message_list->etable), path); + } else { + /* I wonder if there's a better way to do this ...? */ + name = camel_service_get_name((CAMEL_SERVICE(message_list->folder->parent_store)), TRUE); + printf("folder name is '%s'\n", name); + if (strstr(name, "/Drafts") == 0 + || strstr(name, "/Outbox") == 0 + || strstr(name, "/Sent") == 0) { + e_table_scrolled_set_specification(E_TABLE_SCROLLED(message_list->etable), spec); + } + g_free(name); + } + g_free(path); + } +} + /* * GtkObject::init */ @@ -997,7 +1045,7 @@ message_list_init (GtkObject *object) GTK_SIGNAL_FUNC (on_double_click), message_list); gtk_widget_show (message_list->etable); - + gtk_object_ref (GTK_OBJECT (message_list->table_model)); gtk_object_sink (GTK_OBJECT (message_list->table_model)); @@ -1020,8 +1068,10 @@ message_list_destroy (GtkObject *object) MessageList *message_list = MESSAGE_LIST (object); int i; - if (message_list->folder) + if (message_list->folder) { save_tree_state(message_list); + save_header_state(message_list); + } gtk_object_unref (GTK_OBJECT (message_list->table_model)); gtk_object_unref (GTK_OBJECT (message_list->header_model)); @@ -1425,6 +1475,9 @@ message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) message_list->folder = camel_folder; + /* build the etable suitable for this folder */ + message_list_setup_etable(message_list); + camel_object_hook_event(CAMEL_OBJECT (camel_folder), "folder_changed", folder_changed, message_list); camel_object_hook_event(CAMEL_OBJECT (camel_folder), "message_changed", |