[Evolution-hackers] [PATCH] folder-tree mark all as read plugin



This patch adds a plugin which provides two menu items for the
folder-tree popup to allow marking all messages of a given folder either
as read or unread.

I'd love to see a additional flag for folders to determine whether they
contain any read (unread) messages.  This would allow to show (hide) the
corresponding menu items depending on the folder's content.

Thanks,

   Timo
diff -Nur evolution-cvs/configure.in evolution/configure.in
--- evolution-cvs/configure.in	2005-04-01 01:49:48.000000000 +0200
+++ evolution/configure.in	2005-04-02 18:29:54.920396812 +0200
@@ -1335,7 +1335,7 @@
 AC_ARG_ENABLE(plugins, [  --enable-plugins=[no/base/all/experimental/list]      Enable plugins.],enable_plugins="$enableval",enable_plugins=all)
 
 dnl Add any new plugins here
-plugins_base="calendar-file calendar-http calendar-weather groupwise-account-setup itip-formatter plugin-manager send-options shared-folder groupwise-send-options exchange-account-setup groupwise-status-tracking default-source addressbook-file addressbook-groupwise startup-wizard" 
+plugins_base="calendar-file calendar-http calendar-weather groupwise-account-setup itip-formatter plugin-manager send-options shared-folder groupwise-send-options exchange-account-setup groupwise-status-tracking default-source addressbook-file addressbook-groupwise startup-wizard folder-mark-as-read" 
 
 plugins_standard="bbdb subject-thread save-attachments prefer-plain save-calendar select-one-source copy-tool mail-to-task mark-calendar-offline audio-inline mailing-list-actions new-mail-notify" 
 
@@ -1590,6 +1590,7 @@
 plugins/addressbook-file/Makefile
 plugins/addressbook-groupwise/Makefile
 plugins/startup-wizard/Makefile
+plugins/folder-mark-as-read/Makefile
 smime/Makefile
 smime/lib/Makefile
 smime/gui/Makefile
diff -urN evolution-cvs/plugins/folder-mark-as-read/ChangeLog evolution/plugins/folder-mark-as-read/ChangeLog
--- evolution-cvs/plugins/folder-mark-as-read/ChangeLog	1970-01-01 01:00:00.000000000 +0100
+++ evolution/plugins/folder-mark-as-read/ChangeLog	2005-04-02 19:32:21.000000000 +0200
@@ -0,0 +1,7 @@
+2005-04-01  Timo Hoenig  <thoenig suse de>
+
+	* eplugin to mark folders as read/unread from the folder-tree popup
+	menu (closes #45229)
+	* folder-mark_as_read-eplugin.c: initial version
+	* org-gnome-mail-folder-mark_as_read.eplug.in: initial version
+
diff -urN evolution-cvs/plugins/folder-mark-as-read/Makefile.am evolution/plugins/folder-mark-as-read/Makefile.am
--- evolution-cvs/plugins/folder-mark-as-read/Makefile.am	1970-01-01 01:00:00.000000000 +0100
+++ evolution/plugins/folder-mark-as-read/Makefile.am	2005-04-01 20:36:25.000000000 +0200
@@ -0,0 +1,13 @@
+INCLUDES =				\
+	-I$(top_srcdir)		\
+	$(EVOLUTION_MAIL_CFLAGS)
+
+ EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-mail-folder-mark_as_read.eplug
+plugin_LTLIBRARIES = liborg-gnome-mail-folder-mark_as_read.la
+
+liborg_gnome_mail_folder_mark_as_read_la_SOURCES = folder-mark_as_read-eplugin.c
+liborg_gnome_mail_folder_mark_as_read_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = org-gnome-mail-folder-mark_as_read.eplug.in
diff -urN evolution-cvs/plugins/folder-mark-as-read/folder-mark_as_read-eplugin.c evolution/plugins/folder-mark-as-read/folder-mark_as_read-eplugin.c
--- evolution-cvs/plugins/folder-mark-as-read/folder-mark_as_read-eplugin.c	1970-01-01 01:00:00.000000000 +0100
+++ evolution/plugins/folder-mark-as-read/folder-mark_as_read-eplugin.c	2005-04-02 23:15:53.819305533 +0200
@@ -0,0 +1,93 @@
+/* 
+ * Author(s): Timo Hoenig <thoenig novell com>
+ *
+ * Copyright 2005 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <mail/em-popup.h>
+#include <mail/mail-tools.h>
+
+#include <camel/camel-folder.h>
+
+void folder_mark_as_read                  (const char *, int);
+void org_gnome_mail_folder_mark_as_unread (void *, EMPopupTargetFolder *);
+void org_gnome_mail_folder_mark_as_read   (void *, EMPopupTargetFolder *);
+int  e_plugin_lib_enable                  (EPluginLib *, int);
+
+static void
+folder_mark_all (const char *uri, int messageflags)
+{
+	CamelFolder    *folder;
+	CamelException ex;
+	GPtrArray      *uids;
+	int            i;
+
+	camel_exception_init (&ex);
+	folder = mail_tool_uri_to_folder (uri, 0, &ex);
+	if (folder == NULL) {
+		camel_exception_clear (&ex);
+		return;
+	}
+
+	uids = camel_folder_get_uids (folder);
+	camel_folder_freeze (folder);
+	for (i = 0; i < uids->len; i++)
+		camel_folder_set_message_flags (folder,
+						 uids->pdata[i],
+						 messageflags,
+						 (messageflags & CAMEL_MESSAGE_DELETED) ? 0 : messageflags);
+	camel_folder_thaw (folder);
+
+	camel_folder_free_uids (folder, uids);
+	camel_object_unref(folder);
+
+	return;
+}
+
+void
+org_gnome_mail_folder_mark_as_unread (void *ep, EMPopupTargetFolder *t)
+{
+	if (t->uri == NULL) 
+		return;
+
+	folder_mark_all (t->uri, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED);
+			 
+	return;
+}
+
+void
+org_gnome_mail_folder_mark_as_read (void *ep, EMPopupTargetFolder *t)
+{
+	if (t->uri == NULL) 
+		return;
+
+	folder_mark_all (t->uri, CAMEL_MESSAGE_SEEN);
+
+	return;
+}
+
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+	return 0;
+}
+
diff -urN evolution-cvs/plugins/folder-mark-as-read/org-gnome-mail-folder-mark_as_read.eplug.in evolution/plugins/folder-mark-as-read/org-gnome-mail-folder-mark_as_read.eplug.in
--- evolution-cvs/plugins/folder-mark-as-read/org-gnome-mail-folder-mark_as_read.eplug.in	1970-01-01 01:00:00.000000000 +0100
+++ evolution/plugins/folder-mark-as-read/org-gnome-mail-folder-mark_as_read.eplug.in	2005-04-02 18:25:24.000000000 +0200
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+
+  <e-plugin
+    type="shlib"
+    id="org.gnome.mail.folder.mark_as_read"
+    location="@PLUGINDIR@/liborg-gnome-mail-folder-mark_as_read.so"
+    name="Mark Folder as Read or Unread">
+
+    <description>Allows marking all messages of a folder as read or unread directly from a folder's context menu.</description>
+
+    <author name="Timo Hoenig" email="thoenig novell com"/>
+
+    <hook class="org.gnome.evolution.mail.popup:1.0">
+      <menu
+        id="org.gnome.evolution.mail.foldertree.popup"
+	   target="folder">
+
+	   <item
+	     type="bar"
+	     path="30.emc"
+		visible="folder"
+		activate=""/>
+
+        <item
+          type="item"
+          path="30.emc.01"
+          icon="stock_mail-open"
+          label="Mar_k as Read"
+          visible="folder"
+          activate="org_gnome_mail_folder_mark_as_read"/>
+		
+        <item
+          type="item"
+          path="30.emc.01"
+          icon="stock_mail-unread"
+          label="Mark as _Unread"
+          visible="folder"
+          activate="org_gnome_mail_folder_mark_as_unread"/>
+
+      </menu>
+    </hook>
+  </e-plugin>
+</e-plugin-list>

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]