0.9.0claws55
authorChristoph Hohmann <reboot@gmx.ch>
Sun, 22 Jun 2003 18:25:59 +0000 (18:25 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sun, 22 Jun 2003 18:25:59 +0000 (18:25 +0000)
* src/folder.[ch]
        o add notification hook for folder tree changes
        o invoke hooks after folder tree scanning

* src/folderview.[ch]
        register hook for folder tree changes that
        updates the ctree

(there are more places that should be updated, like add, remove
 or move folder)

(closes Bug 164 Crash on rebuild folder tree)
(closes Bug 190 Crash on 'rebuilding folder tree')

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

index c9dc22872350b574bd4936b3f6badf51c50f4988..5cc5191a3b04fbba19e4d0b4d9e0fd9986014762 100644 (file)
@@ -1,3 +1,19 @@
+2003-06-22 [christoph] 0.9.0claws55
+
+       * src/folder.[ch]
+               o add notification hook for folder tree changes
+               o invoke hooks after folder tree scanning
+
+       * src/folderview.[ch]
+               register hook for folder tree changes that
+               updates the ctree
+
+       (there are more places that should be updated, like add, remove 
+        or move folder)
+
+       (closes Bug 164 Crash on rebuild folder tree)
+       (closes Bug 190 Crash on 'rebuilding folder tree')
+
 2003-06-21 [leandro]   0.9.0claws54
 
        * src/compose.[ch]
index 6421b6e60843e513dceba2b9d9df1c0d64c0f1f9..d529c2e39e39799cbb7eaee6c264d6ab60dd3176 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws54
+EXTRA_VERSION=claws55
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 868cf5073c4d8092d82e8c75190be9e1b082fddf..09693e17840049de1bae041d9e27092cc1b9c17e 100644 (file)
@@ -420,6 +420,7 @@ gboolean folder_scan_tree_func(GNode *node, gpointer data)
 void folder_scan_tree(Folder *folder)
 {
        GHashTable *pptable;
+       FolderUpdateData hookdata;
        
        if (!folder->klass->scan_tree)
                return;
@@ -433,6 +434,10 @@ void folder_scan_tree(Folder *folder)
        folder_tree_destroy(folder);
        folder->klass->scan_tree(folder);
 
+       hookdata.folder = folder;
+       hookdata.update_flags = FOLDER_TREE_CHANGED;
+       hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
+
        g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1, folder_scan_tree_func, pptable);
        folder_persist_prefs_free(pptable);
 
index a8d4d9c0c1d38ccf4990c090739de37739150c38..5b80bc8bea8cac0cfc4ec3d09aa6aa2785f137fd 100644 (file)
@@ -31,6 +31,8 @@ typedef struct _RemoteFolder          RemoteFolder;
 typedef struct _MaildirFolder          MaildirFolder;
 #endif
 typedef struct _FolderItem             FolderItem;
+
+typedef struct _FolderUpdateData       FolderUpdateData;
 typedef struct _FolderItemUpdateData   FolderItemUpdateData;
 
 #define FOLDER(obj)            ((Folder *)obj)
@@ -50,6 +52,7 @@ typedef struct _FolderItemUpdateData  FolderItemUpdateData;
 
 #define FOLDER_ITEM(obj)       ((FolderItem *)obj)
 
+#define FOLDER_UPDATE_HOOKLIST "folder_update"
 #define FOLDER_ITEM_UPDATE_HOOKLIST "folder_item_update"
 
 typedef enum
@@ -104,6 +107,16 @@ typedef enum
        F_MOVE_FAILED = -4,
 } FolderItemMoveResult;
 
+typedef enum
+{
+       FOLDER_TREE_CHANGED = 1 << 0,
+/*
+       maybe enhance with:
+       FOLDER_NEW_FOLDERITEM
+       FOLDER_REMOVE_FOLDERITEM
+*/
+} FolderUpdateFlags;
+
 typedef enum
 {
        F_ITEM_UPDATE_MSGCNT = 1 << 0,
@@ -300,6 +313,15 @@ typedef struct {
        guint           ret_rcpt        : 1; /* CLAWS */
 } PersistPrefs;
 
+struct _FolderUpdateData
+{
+       Folder                  *folder;
+       FolderUpdateFlags        update_flags;
+/*
+       FolderItem              *item
+*/
+};
+
 struct _FolderItemUpdateData
 {
        FolderItem              *item;
index 5be3e0b8da51b448b53f0f523ccf2d6c51babd23..a039fff73047ac7582a82f47150d28c0485053a2 100644 (file)
@@ -264,6 +264,8 @@ static void folderview_drag_data_get     (GtkWidget        *widget,
 
 void folderview_create_folder_node       (FolderView       *folderview, 
                                          FolderItem       *item);
+gboolean folderview_update_folder       (gpointer          source,
+                                         gpointer          userdata);
 gboolean folderview_update_item                 (gpointer          source,
                                          gpointer          data);
 
@@ -509,6 +511,8 @@ FolderView *folderview_create(void)
        folderview->mbox_popup   = mbox_popup;
        folderview->mbox_factory = mbox_factory;
 
+       folderview->folder_update_callback_id =
+               hooks_register_hook(FOLDER_UPDATE_HOOKLIST, folderview_update_folder, (gpointer) folderview);
        folderview->folder_item_update_callback_id =
                hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST, folderview_update_item, (gpointer) folderview);
 
@@ -2846,3 +2850,23 @@ static void folderview_drag_data_get(GtkWidget        *widget,
        }
 }
 
+gboolean folderview_update_folder(gpointer source, gpointer userdata)
+{
+       FolderUpdateData *hookdata;
+       FolderView *folderview;
+       GtkWidget *ctree;
+
+       hookdata = source;
+       folderview = (FolderView *) userdata;   
+       g_return_val_if_fail(hookdata != NULL, FALSE);
+       g_return_val_if_fail(folderview != NULL, FALSE);
+
+       ctree = folderview->ctree;
+       g_return_val_if_fail(ctree != NULL, FALSE);
+
+       if (hookdata->update_flags & FOLDER_TREE_CHANGED) {
+               folderview_set(folderview);
+       }
+
+       return FALSE;
+}
index 3f9ddfdf10080f2d4f956ab43a94645f7d2588b2..bfec50a05ac1b84cf636072aab4d93d09e8b6bbf 100644 (file)
@@ -56,6 +56,7 @@ struct _FolderView
        MainWindow   *mainwin;
        SummaryView  *summaryview;
 
+       gint folder_update_callback_id;
        gint folder_item_update_callback_id;
        
        /* for drag and drop */