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 c9dc228..5cc5191 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 6421b6e..d529c2e 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 868cf50..09693e1 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 a8d4d9c..5b80bc8 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 5be3e0b..a039fff 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 3f9ddfd..bfec50a 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 */