* src/folder.[ch]
authorChristoph Hohmann <reboot@gmx.ch>
Sat, 9 Nov 2002 22:06:23 +0000 (22:06 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sat, 9 Nov 2002 22:06:23 +0000 (22:06 +0000)
* src/folderview.c
        add functions to open and close a folder
        o opending call execute scanning for remote folders
          and processing
        o closing will unset new flag for messages

ChangeLog.claws
src/folder.c
src/folder.h
src/folderview.c

index b6d491b..baf114c 100644 (file)
@@ -1,3 +1,12 @@
+2002-11-09 [christoph] 0.8.5claws109
+
+       * src/folder.[ch]
+       * src/folderview.c
+               add functions to open and close a folder
+               o opending call execute scanning for remote folders
+                 and processing
+               o closing will unset new flag for messages
+
 2002-11-09 [colin]     0.8.5claws108
 
        * src/folder.c
index 7163627..a572f41 100644 (file)
@@ -941,6 +941,50 @@ static gint folder_sort_folder_list(gconstpointer a, gconstpointer b)
        return (gint_a - gint_b);
 }
 
+gint folder_item_open(FolderItem *item)
+{
+       if(((item->folder->type == F_IMAP) && !item->no_select) || (item->folder->type == F_NEWS)) {
+               folder_item_scan(item);
+       }
+
+       /* Processing */
+       if(item->prefs->processing != NULL) {
+               gchar *buf;
+               
+               buf = g_strdup_printf(_("Processing (%s)...\n"), item->path);
+               debug_print("%s\n", buf);
+               g_free(buf);
+       
+               folder_item_apply_processing(item);
+
+               debug_print("done.\n");
+       }
+
+       return 0;
+}
+
+void folder_item_close(FolderItem *item)
+{
+       GSList *mlist, *cur;
+       
+       g_return_if_fail(item != NULL);
+       
+       mlist = folder_item_get_msg_list(item);
+       
+       for (cur = mlist ; cur != NULL ; cur = cur->next) {
+               MsgInfo * msginfo;
+
+               msginfo = (MsgInfo *) cur->data;
+               if (MSG_IS_NEW(msginfo->flags))
+                       procmsg_msginfo_unset_flags(msginfo, MSG_NEW, 0);
+               procmsg_msginfo_free(msginfo);
+       }
+       
+       folder_update_item(item, FALSE);
+
+       g_slist_free(mlist);
+}
+
 gint folder_item_scan(FolderItem *item)
 {
        Folder *folder;
index 4cdf09b..a7aa8b9 100644 (file)
@@ -343,6 +343,8 @@ void folder_unref_account_all               (PrefsAccount   *account);
 gchar *folder_get_path                 (Folder         *folder);
 gchar *folder_item_get_path            (FolderItem     *item);
 
+gint   folder_item_open                        (FolderItem     *item);
+void   folder_item_close               (FolderItem     *item);
 gint   folder_item_scan                        (FolderItem     *item);
 void   folder_item_scan_foreach                (GHashTable     *table);
 MsgInfo *folder_item_fetch_msginfo     (FolderItem     *item,
index c6f093a..822875b 100644 (file)
@@ -1632,6 +1632,7 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
        static gboolean can_select = TRUE;      /* exclusive lock */
        gboolean opened;
        FolderItem *item;
+       gchar *buf;
 
        folderview->selected = row;
 
@@ -1663,6 +1664,7 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
                        /* will be null if we just moved the previously opened folder */
                        folder_item_write_cache(olditem);
                        summary_save_prefs_to_folderitem(folderview->summaryview, olditem);
+                       folder_item_close(olditem);
                }
        }
 
@@ -1690,28 +1692,23 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
                        gdk_pointer_ungrab(GDK_CURRENT_TIME);
        }
 
-       if(((item->folder->type == F_IMAP) && !item->no_select) || (item->folder->type == F_NEWS)) {
-               folder_item_scan(item);
-       }
+       /* Open Folder */
+       buf = g_strdup_printf(_("Opening Folder %s..."), item->path);
+       debug_print("%s\n", buf);
+       STATUSBAR_PUSH(folderview->mainwin, buf);
+       g_free(buf);
 
-       /* Processing */
-       if(item->prefs->processing != NULL) {
-               gchar *buf;
-               
-               buf = g_strdup_printf(_("Processing (%s)..."), item->path);
-               debug_print("%s\n", buf);
-               STATUSBAR_PUSH(folderview->mainwin, buf);
-               g_free(buf);
+       main_window_cursor_wait(folderview->mainwin);
        
-               main_window_cursor_wait(folderview->mainwin);
-       
-               folder_item_apply_processing(item);
-
-               debug_print("done.\n");
+       if (folder_item_open(item) != 0) {
                STATUSBAR_POP(folderview->mainwin);
                main_window_cursor_normal(folderview->mainwin);
-       }
-               
+
+               alertpanel_error(_("Folder cound not be opened."));
+
+               return;
+        }
+
        /* Show messages */
        summary_set_prefs_from_folderitem(folderview->summaryview, item);
        opened = summary_show(folderview->summaryview, item);
@@ -1728,6 +1725,9 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
                        gtk_ctree_node_moveto(ctree, row, -1, 0.5, 0);
        }
 
+       STATUSBAR_POP(folderview->mainwin);
+       main_window_cursor_normal(folderview->mainwin);
+
        folderview->open_folder = FALSE;
        can_select = TRUE;
 }