[Commits] [SCM] claws branch, master, updated. 3.9.3-221-ga873d8f
colin at claws-mail.org
colin at claws-mail.org
Thu May 22 22:46:52 CEST 2014
The branch master of project "claws" (Claws Mail) has been updated
via a873d8f791b069ffee24e524477165deda81558e (commit)
via dd8b4d95d4d605aeb641ae2786b16c2392eaf42e (commit)
from 6086f18b8586d0cf6fdcec0ed33809ae8636b3ec (commit)
- Log -----------------------------------------------------------------
commit a873d8f791b069ffee24e524477165deda81558e
Author: Colin Leroy <colin at colino.net>
Date: Thu May 22 22:46:07 2014 +0200
Better solution than a global function call, use our hook infrastructure
(with minor modifications for moving)
diff --git a/src/compose.c b/src/compose.c
index d0123db..68f29a1 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -2109,6 +2109,44 @@ static gboolean compose_is_sig_separator(Compose *compose, GtkTextBuffer *textbu
return FALSE;
}
+static gboolean compose_update_folder_hook(gpointer source, gpointer data)
+{
+ FolderUpdateData *hookdata = (FolderUpdateData *)source;
+ Compose *compose = (Compose *)data;
+ FolderItem *old_item = NULL;
+ FolderItem *new_item = NULL;
+ gchar *old_id, *new_id;
+
+ if (!(hookdata->update_flags & FOLDER_REMOVE_FOLDERITEM)
+ && !(hookdata->update_flags & FOLDER_MOVE_FOLDERITEM))
+ return FALSE;
+
+ old_item = hookdata->item;
+ new_item = hookdata->item2;
+
+ old_id = folder_item_get_identifier(old_item);
+ new_id = new_item ? folder_item_get_identifier(new_item) : g_strdup("NULL");
+
+ if (compose->targetinfo && compose->targetinfo->folder == old_item) {
+ debug_print("updating targetinfo folder: %s -> %s\n", old_id, new_id);
+ compose->targetinfo->folder = new_item;
+ }
+
+ if (compose->replyinfo && compose->replyinfo->folder == old_item) {
+ debug_print("updating replyinfo folder: %s -> %s\n", old_id, new_id);
+ compose->replyinfo->folder = new_item;
+ }
+
+ if (compose->fwdinfo && compose->fwdinfo->folder == old_item) {
+ debug_print("updating fwdinfo folder: %s -> %s\n", old_id, new_id);
+ compose->fwdinfo->folder = new_item;
+ }
+
+ g_free(old_id);
+ g_free(new_id);
+ return FALSE;
+}
+
static void compose_colorize_signature(Compose *compose)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(compose->text));
@@ -5976,17 +6014,25 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
}
/* Message-ID of message replying to */
if ((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
- gchar *folderid;
-
- folderid = folder_item_get_identifier(compose->replyinfo->folder);
+ gchar *folderid = NULL;
+
+ if (compose->replyinfo->folder)
+ folderid = folder_item_get_identifier(compose->replyinfo->folder);
+ if (folderid == NULL)
+ folderid = g_strdup("NULL");
+
err |= (fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid) < 0);
g_free(folderid);
}
/* Message-ID of message forwarding to */
if ((compose->fwdinfo != NULL) && (compose->fwdinfo->msgid != NULL)) {
- gchar *folderid;
+ gchar *folderid = NULL;
- folderid = folder_item_get_identifier(compose->fwdinfo->folder);
+ if (compose->fwdinfo->folder)
+ folderid = folder_item_get_identifier(compose->fwdinfo->folder);
+ if (folderid == NULL)
+ folderid = g_strdup("NULL");
+
err |= (fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid) < 0);
g_free(folderid);
}
@@ -7899,6 +7945,11 @@ static Compose *compose_create(PrefsAccount *account,
compose->exteditor_tag = -1;
compose->draft_timeout_tag = COMPOSE_DRAFT_TIMEOUT_FORBIDDEN; /* inhibit auto-drafting while loading */
+ compose->folder_update_callback_id =
+ hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
+ compose_update_folder_hook,
+ (gpointer) compose);
+
#if USE_ENCHANT
cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Spelling", FALSE);
if (mode != COMPOSE_REDIRECT) {
@@ -8654,6 +8705,9 @@ static void compose_destroy(Compose *compose)
g_hash_table_destroy(compose->email_hashtable);
+ hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST,
+ compose->folder_update_callback_id);
+
procmsg_msginfo_free(compose->targetinfo);
procmsg_msginfo_free(compose->replyinfo);
procmsg_msginfo_free(compose->fwdinfo);
@@ -9765,17 +9819,25 @@ gboolean compose_draft (gpointer data, guint action)
/* Message-ID of message replying to */
if ((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
- gchar *folderid;
-
- folderid = folder_item_get_identifier(compose->replyinfo->folder);
+ gchar *folderid = NULL;
+
+ if (compose->replyinfo->folder)
+ folderid = folder_item_get_identifier(compose->replyinfo->folder);
+ if (folderid == NULL)
+ folderid = g_strdup("NULL");
+
err |= (fprintf(fp, "RMID:%s\t%d\t%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid) < 0);
g_free(folderid);
}
/* Message-ID of message forwarding to */
if ((compose->fwdinfo != NULL) && (compose->fwdinfo->msgid != NULL)) {
- gchar *folderid;
-
- folderid = folder_item_get_identifier(compose->fwdinfo->folder);
+ gchar *folderid = NULL;
+
+ if (compose->fwdinfo->folder)
+ folderid = folder_item_get_identifier(compose->fwdinfo->folder);
+ if (folderid == NULL)
+ folderid = g_strdup("NULL");
+
err |= (fprintf(fp, "FMID:%s\t%d\t%s\n", folderid, compose->fwdinfo->msgnum, compose->fwdinfo->msgid) < 0);
g_free(folderid);
}
@@ -11803,33 +11865,6 @@ static void compose_subject_entry_activated(GtkWidget *widget, gpointer data)
gtk_widget_grab_focus(compose->text);
}
-void compose_list_update_folders(FolderItem *old_item, FolderItem *new_item)
-{
- const GList *compose_list = compose_get_compose_list();
- const GList *elem = NULL;
-
- if (compose_list) {
- for (elem = compose_list; elem != NULL && elem->data != NULL;
- elem = elem->next) {
- Compose *c = (Compose*)elem->data;
-
- if (c->targetinfo && c->targetinfo->folder == old_item)
- c->targetinfo->folder = new_item;
-
- if (c->replyinfo && c->replyinfo->folder == old_item)
- c->replyinfo->folder = new_item;
-
- if (c->fwdinfo && c->fwdinfo->folder == old_item)
- c->fwdinfo->folder = new_item;
-
- if (c->autosaved_draft && c->autosaved_draft->folder == old_item)
- c->autosaved_draft->folder = new_item;
-
- }
- }
-}
-
-
/*
* End of Source.
*/
diff --git a/src/compose.h b/src/compose.h
index b7eb416..51d0e7e 100644
--- a/src/compose.h
+++ b/src/compose.h
@@ -238,14 +238,16 @@ struct _Compose
gint close_timeout_tag;
gchar *orig_charset;
gint set_cursor_pos;
-
+
gboolean updating;
gboolean deferred_destroy;
ComposeMode rmode;
GtkWidget *first_combo;
GtkWidget *first_entry;
-
+
GtkUIManager *ui_manager;
+
+ gint folder_update_callback_id;
#if USE_ENCHANT
/* GNU/aspell spell checker */
GtkAspell *gtkaspell;
@@ -342,6 +344,5 @@ void compose_clear_exit_drafts (void);
void compose_reopen_exit_drafts (void);
void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
void compose_check_for_email_account(Compose *compose);
-void compose_list_update_folders(FolderItem *old_item, FolderItem *new_item);
#endif /* __COMPOSE_H__ */
diff --git a/src/folder.c b/src/folder.c
index 52fc192..781b24c 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -258,6 +258,7 @@ void folder_item_change_type(FolderItem *item, SpecialFolderItemType newtype)
hookdata.folder = folder;
hookdata.update_flags = FOLDER_TREE_CHANGED;
hookdata.item = NULL;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
}
@@ -432,7 +433,6 @@ void folder_item_remove(FolderItem *item)
}
}
- compose_list_update_folders(item, NULL);
/* remove myself */
if (item->cache != NULL) {
msgcache_destroy(item->cache);
@@ -451,6 +451,7 @@ void folder_item_remove(FolderItem *item)
hookdata.folder = item->folder;
hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_REMOVE_FOLDERITEM;
hookdata.item = item;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
node = start_node;
@@ -794,6 +795,7 @@ void folder_add(Folder *folder)
hookdata.folder = folder;
hookdata.update_flags = FOLDER_ADD_FOLDER;
hookdata.item = NULL;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
}
@@ -808,6 +810,7 @@ void folder_remove(Folder *folder)
hookdata.folder = folder;
hookdata.update_flags = FOLDER_REMOVE_FOLDER;
hookdata.item = NULL;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
}
@@ -948,6 +951,7 @@ void folder_scan_tree(Folder *folder, gboolean rebuild)
hookdata.folder = folder;
hookdata.update_flags = FOLDER_TREE_CHANGED;
hookdata.item = NULL;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
if (rebuild)
@@ -980,6 +984,7 @@ FolderItem *folder_create_folder(FolderItem *parent, const gchar *name)
hookdata.folder = new_item->folder;
hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDERITEM;
hookdata.item = new_item;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
}
@@ -1006,6 +1011,7 @@ gint folder_item_rename(FolderItem *item, gchar *newname)
hookdata2.folder = item->folder;
hookdata2.item = item;
+ hookdata2.item2 = NULL;
hookdata2.update_flags = FOLDER_RENAME_FOLDERITEM;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata2);
}
@@ -3231,6 +3237,7 @@ static FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest,
FolderItem *next_item;
GNode *srcnode;
gchar *old_id, *new_id;
+ FolderUpdateData hookdata;
/* move messages */
debug_print("%s %s to %s\n", copy?"Copying":"Moving", src->path, dest->path);
@@ -3293,7 +3300,11 @@ static FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest,
old_id = folder_item_get_identifier(src);
new_id = folder_item_get_identifier(new_item);
- compose_list_update_folders(src, new_item);
+ hookdata.folder = src->folder;
+ hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_MOVE_FOLDERITEM;
+ hookdata.item = src;
+ hookdata.item2 = new_item;
+ hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
/* if src supports removing, otherwise only copy folder */
if (src->folder->klass->remove_folder != NULL && !copy)
diff --git a/src/folder.h b/src/folder.h
index b54c9f4..e0ad21a 100644
--- a/src/folder.h
+++ b/src/folder.h
@@ -107,7 +107,8 @@ typedef enum
FOLDER_TREE_CHANGED = 1 << 2,
FOLDER_ADD_FOLDERITEM = 1 << 3,
FOLDER_REMOVE_FOLDERITEM = 1 << 4,
- FOLDER_RENAME_FOLDERITEM = 1 << 5
+ FOLDER_RENAME_FOLDERITEM = 1 << 5,
+ FOLDER_MOVE_FOLDERITEM = 1 << 6
} FolderUpdateFlags;
typedef enum
@@ -803,6 +804,7 @@ struct _FolderUpdateData
Folder *folder;
FolderUpdateFlags update_flags;
FolderItem *item;
+ FolderItem *item2;
};
struct _FolderItemUpdateData
diff --git a/src/folderview.c b/src/folderview.c
index 209c617..5e55e91 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -2709,6 +2709,8 @@ static gboolean folderview_update_folder(gpointer source, gpointer userdata)
if (folderview->opened == node)
folderview->opened = NULL;
}
+ } else if (hookdata->update_flags & FOLDER_MOVE_FOLDERITEM) {
+ /* do nothing, it's done by the ADD and REMOVE) */
} else if (hookdata->update_flags & (FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDER | FOLDER_REMOVE_FOLDER))
folderview_set(folderview);
diff --git a/src/news_gtk.c b/src/news_gtk.c
index c848853..74d82df 100644
--- a/src/news_gtk.c
+++ b/src/news_gtk.c
@@ -226,6 +226,7 @@ static void subscribe_newsgroup_cb(GtkAction *action, gpointer data)
hookdata.folder = newitem->folder;
hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDERITEM;
hookdata.item = newitem;
+ hookdata.item2 = NULL;
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
}
commit dd8b4d95d4d605aeb641ae2786b16c2392eaf42e
Author: Colin Leroy <colin at colino.net>
Date: Thu May 22 22:12:56 2014 +0200
Constify messageview_get_msgview_list()
diff --git a/src/messageview.c b/src/messageview.c
index b3b815b..2d9c677 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -442,7 +442,7 @@ MessageView *messageview_create(MainWindow *mainwin)
return messageview;
}
-GList *messageview_get_msgview_list(void)
+const GList *messageview_get_msgview_list(void)
{
return msgview_list;
}
diff --git a/src/messageview.h b/src/messageview.h
index 7ef1931..e2e429b 100644
--- a/src/messageview.h
+++ b/src/messageview.h
@@ -98,7 +98,7 @@ void messageview_copy_clipboard (MessageView *messageview);
void messageview_select_all (MessageView *messageview);
void messageview_set_position (MessageView *messageview,
gint pos);
-GList *messageview_get_msgview_list (void);
+const GList *messageview_get_msgview_list (void);
void messageview_delete (MessageView *messageview);
gboolean messageview_search_string (MessageView *messageview,
const gchar *str,
diff --git a/src/summaryview.c b/src/summaryview.c
index 13ad155..a0935d2 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -6895,7 +6895,7 @@ static void summary_unselected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
static void summary_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row,
gint column, SummaryView *summaryview)
{
- GList *list, *cur;
+ const GList *list, *cur;
MessageView *msgview;
MsgInfo *msginfo;
gboolean marked_unread = FALSE;
-----------------------------------------------------------------------
Summary of changes:
src/compose.c | 111 +++++++++++++++++++++++++++++++++++------------------
src/compose.h | 7 ++--
src/folder.c | 15 +++++++-
src/folder.h | 4 +-
src/folderview.c | 2 +
src/messageview.c | 2 +-
src/messageview.h | 2 +-
src/news_gtk.c | 1 +
src/summaryview.c | 2 +-
9 files changed, 99 insertions(+), 47 deletions(-)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list