Callback system for MsgInfo (better fix for updating the summaryview
authorColin Leroy <colin@colino.net>
Fri, 15 Nov 2002 14:04:35 +0000 (14:04 +0000)
committerColin Leroy <colin@colino.net>
Fri, 15 Nov 2002 14:04:35 +0000 (14:04 +0000)
after sending a mail)

ChangeLog.claws
configure.in
src/procmsg.c
src/procmsg.h
src/summaryview.c
src/summaryview.h

index 9d387805faf361882b61502c3969651d41b25658..c5a6760b6854f376f3e9c814d90065b44b262132 100644 (file)
@@ -1,3 +1,12 @@
+2002-11-14 [colin]     0.8.5claws153
+
+       * src/procmsg.[ch]
+               Implemented a callback for MsgInfo updates, 
+               heavily copy/pasted from Christoph's folder 
+               callback system
+       * src/summaryview.[ch]
+               Register summary_update_msg as callback
+
 2002-11-14 [colin]     0.8.5claws152
        
        * src/procmsg.c
index 42cfd5c10487eafada5ad35afc830d881fef1764..b81f1d062f9b15b4849bfa34e1897dbe61f9aee6 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws152
+EXTRA_VERSION=claws153
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 13ed42d2ded504d6ea5ce6be9034b41171881c38..994694f11e0a5c57490b86e6c9c3c5209a7082e9 100644 (file)
@@ -1409,8 +1409,8 @@ gint procmsg_send_message_queue(const gchar *file)
                                procmsg_msginfo_unset_flags(msginfo, MSG_FORWARDED, 0);
                                procmsg_msginfo_set_flags(msginfo, MSG_REPLIED, 0);
 
+                               msginfo_update_item(msginfo);
                                procmsg_msginfo_free(msginfo);
-                               folder_update_item(item,TRUE);
                        }
                }
                g_strfreev(tokens);
@@ -1532,3 +1532,70 @@ void procmsg_msginfo_write_flags(MsgInfo *msginfo)
        
        g_free(destdir);
 }
+
+/*
+ * callback handling
+ */
+GSList *msginfo_update_callbacks_list = NULL;
+gint   msginfo_update_callbacks_nextid = 0;
+
+struct MsgInfoUpdateCallback
+{
+       gint                    id;
+       MsgInfoUpdateFunc       func;
+       gpointer                data;
+};
+
+gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data)
+{
+       struct MsgInfoUpdateCallback *callback;
+
+       g_return_val_if_fail(func != NULL, -1);
+
+       msginfo_update_callbacks_nextid++;
+
+       callback = g_new0(struct MsgInfoUpdateCallback, 1);
+       callback->id = msginfo_update_callbacks_nextid;
+       callback->func = func;
+       callback->data = data;
+
+       msginfo_update_callbacks_list =
+               g_slist_append(msginfo_update_callbacks_list, callback);
+
+       return msginfo_update_callbacks_nextid;
+}
+
+void msginfo_update_callback_unregister(gint id)
+{
+       GSList *list, *next;
+
+       for (list = msginfo_update_callbacks_list; list != NULL; list = next) {
+               struct MsgInfoUpdateCallback *callback;
+
+               next = list->next;
+
+               callback = list->data;
+               if (callback->id == id) {
+                       msginfo_update_callbacks_list =
+                               g_slist_remove(msginfo_update_callbacks_list, callback);
+                       g_free(callback);
+               }
+       }
+}
+
+static void msginfo_update_callback_execute(MsgInfo *info)
+{
+       GSList *list;
+
+       for (list = msginfo_update_callbacks_list; list != NULL; list = list->next) {
+               struct MsgInfoUpdateCallback *callback;
+
+               callback = list->data;
+               callback->func(info, callback->data);
+       }
+}
+
+void msginfo_update_item(MsgInfo *info)
+{
+       msginfo_update_callback_execute(info);
+}
index cfbff25ba2b0b062d653e183de4233ceb0fab635..e618b32d5182f1d63c5c14cd28cb7da4234e5ed3 100644 (file)
@@ -280,4 +280,11 @@ void procmsg_msginfo_unset_flags   (MsgInfo *msginfo,
                                         MsgPermFlags perm_flags,
                                          MsgTmpFlags tmp_flags);
 
+/* callback system for updates */
+typedef void (*MsgInfoUpdateFunc)      (MsgInfo        *info,
+                                        gpointer        data);
+gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data);
+void msginfo_update_callback_unregister(gint id);
+
+void msginfo_update_item               (MsgInfo        *info);
 #endif /* __PROCMSG_H__ */
index 72f3a868d31b6c0964df45fb4da6c43dad8105b4..45cfa27b1d587e09cdced5ee11c9e5beb1fa6e5d 100644 (file)
@@ -377,6 +377,7 @@ static void news_flag_crosspost             (MsgInfo *msginfo);
 static void tog_searchbar_cb           (GtkWidget      *w,
                                         gpointer        data);
 
+static void summary_update_msg         (MsgInfo *info, gpointer data);
 
 GtkTargetEntry summary_drag_types[1] =
 {
@@ -604,6 +605,8 @@ SummaryView *summary_create(void)
        summaryview->search_type_opt = search_type_opt;
        summaryview->search_type = search_type;
        summaryview->search_string = search_string;
+       summaryview->msginfo_update_callback_id =
+               msginfo_update_callback_register(summary_update_msg, (gpointer) summaryview);
 
        /* CLAWS: need this to get the SummaryView * from
         * the CList */
@@ -5311,6 +5314,15 @@ void summary_save_prefs_to_folderitem(SummaryView *summaryview, FolderItem *item
        item->threaded = summaryview->threaded;
 }
 
+static void summary_update_msg(MsgInfo *msginfo, gpointer data) {
+       GtkCTreeNode *node;
+       SummaryView *summaryview = (SummaryView *)data;
+       node = gtk_ctree_find_by_row_data(GTK_CTREE(summaryview->ctree), NULL, msginfo);
+       
+       if (node) 
+               summary_set_row_marks(summaryview, node);
+}
+
 /*
  * End of Source.
  */
index 5b56d87934f92ba032141bfeed928c1ff7b3e69e..8d67c631a6ed902160ed777a654c8210410519e2 100644 (file)
@@ -160,6 +160,7 @@ private:
 
        /* list for moving/deleting messages */
        GSList *mlist;
+       int msginfo_update_callback_id;
 };
 
 SummaryView    *summary_create(void);