[evolution-patches] folder.expunged and message.changed events
- From: Nat Friedman <nat novell com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] folder.expunged and message.changed events
- Date: Sun, 16 Jan 2005 21:27:51 -0500
Hi,
This patch adds two EPlugin events: message.changed is emitted when
message flags change, and folder.expunged is emitted when the user
expunges the deleted messages in a folder.
I implemented these events for a plugin that I was writing that I've
since abandoned, but I figure they might be useful for someone.
I'm interested in review on both; I think I may have missed some code
paths on folder expunging, in particular.
Thanks,
Nat
cvs server: Diffing .
Index: em-folder-browser.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-browser.c,v
retrieving revision 1.55
diff -u -r1.55 em-folder-browser.c
--- em-folder-browser.c 3 Dec 2004 03:38:03 -0000 1.55
+++ em-folder-browser.c 17 Jan 2005 02:25:00 -0000
@@ -75,6 +75,7 @@
#include "em-folder-properties.h"
#include "em-subscribe-editor.h"
#include "em-menu.h"
+#include "em-event.h"
#include "message-list.h"
#include "mail-component.h"
@@ -573,8 +574,22 @@
{
EMFolderBrowser *emfb = data;
- if (emfb->view.folder)
+ if (emfb->view.folder) {
+ EMEvent *e;
+ EMEventTargetFolder *t;
+
em_utils_expunge_folder(gtk_widget_get_toplevel((GtkWidget *)emfb), emfb->view.folder);
+
+ /** @Event: folder.expunged
+ * @Title: Folder expunged
+ * @Target: EMEventTargetFolder
+ *
+ * folder.expunged is emitted whenever a folder is expunged.
+ */
+ e = em_event_peek();
+ t = em_event_target_new_folder(e, emfb->view.folder_uri, 0);
+ e_event_emit((EEvent *)e, "folder.expunged", (EEventTarget *)t);
+ }
}
static void
Index: em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.99
diff -u -r1.99 em-folder-view.c
--- em-folder-view.c 7 Jan 2005 06:33:26 -0000 1.99
+++ em-folder-view.c 17 Jan 2005 02:25:00 -0000
@@ -337,6 +337,26 @@
return (GtkWidget *)emfv;
}
+static void
+emfv_emit_flags_changed_event(EMFolderView *emfv, const char *uid)
+{
+ EMEventTargetMessage *target;
+ CamelMimeMessage *m;
+ EMEvent *eme;
+
+ /** @Event: message.changed
+ * @Title: Message being changed, in its new changed state
+ * @Target: EMEventTargetMessage
+ *
+ * message.changed is emitted when a message's flags change.
+ */
+
+ eme = em_event_peek();
+ m = camel_folder_get_message(emfv->folder, uid, NULL);
+ target = em_event_target_new_message(eme, emfv->folder, m, uid, 0);
+ e_event_emit((EEvent *)eme, "message.changed", (EEventTarget *)target);
+}
+
/* flag all selected messages. Return number flagged */
/* FIXME: Should this be part of message-list instead? */
int
@@ -351,9 +371,11 @@
uids = message_list_get_selected(emfv->list);
camel_folder_freeze(emfv->folder);
- for (i=0; i<uids->len; i++)
+ for (i=0; i<uids->len; i++) {
camel_folder_set_message_flags(emfv->folder, uids->pdata[i], mask, set);
+ emfv_emit_flags_changed_event(emfv, uids->pdata[i]);
+ }
message_list_free_uids(emfv->list, uids);
camel_folder_thaw(emfv->folder);
@@ -1984,9 +2006,10 @@
EMFolderView *emfv = mst->emfv;
MessageList *list = emfv->list;
- if (mst->uid && list->cursor_uid && !strcmp (mst->uid, list->cursor_uid))
+ if (mst->uid && list->cursor_uid && !strcmp (mst->uid, list->cursor_uid)) {
camel_folder_set_message_flags (emfv->folder, mst->uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
-
+ emfv_emit_flags_changed_event(emfv, mst->uid);
+ }
return FALSE;
}
@@ -2032,6 +2055,7 @@
(GSourceFunc)do_mark_seen, mst, (GDestroyNotify)mst_free);
} else {
camel_folder_set_message_flags(emfv->folder, uid, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ emfv_emit_flags_changed_event(emfv, uid);
}
}
@@ -2109,6 +2133,7 @@
flags &= ~CAMEL_MESSAGE_DELETED;
camel_folder_set_message_flags(emfv->folder, uids->pdata[i],
CAMEL_MESSAGE_FLAGGED|CAMEL_MESSAGE_DELETED, flags);
+ emfv_emit_flags_changed_event(emfv, uids->pdata[i]);
}
camel_folder_thaw(emfv->folder);
cvs server: Diffing default
cvs server: Diffing default/C
cvs server: Diffing default/ja
cvs server: Diffing default/nl
cvs server: Diffing default/zh_CN
cvs server: Diffing importers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]