[evolution-patches] Patch to implement menu item enabling/disabling on mark-all-read plugin



    There were a TODO on mark-all-read to enable / disable the menu item according to the folder type.

    I have develop a patch to resolve this TODO added a check to display the mark-all-read menu item only when on the folder summary there are unread messages.

    The patch is attached.


--
Regards,
  Alexandre Rocha Lima e Marcondes
   P4 Tecnologia e Desenvolvimento Humano
alexandre p4tecnologia com
alexandre psl-pr softwarelivre org
arlm users sourceforge net
www.p4tecnologia.com
alexandre.p4tecnologia.com
Projetos:
MonoBrasil MonoBASIC ACBr
Freedom ERP
To validate this message's signature follow the instructions: http://www.cacert.org/index.php?id=3&lang=en_US
Index: plugins/mark-all-read/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/mark-all-read/ChangeLog,v
retrieving revision 1.3
diff -p -U3 -r1.3 ChangeLog
--- plugins/mark-all-read/ChangeLog	27 Jun 2005 00:55:24 -0000	1.3
+++ plugins/mark-all-read/ChangeLog	12 Nov 2005 20:30:47 -0000
@@ -1,3 +1,8 @@
+2005-06-27  Alexandre Rocha Lima e Marcondes <alexandre p4tecnologia com>
+
+	* org-gnome-send-options.eplug.in: Added support to menu item factories.
+  	* mark-all-read.c: Implemented menu smart enabling/disabling TODO with menu item factories.	
+
 2005-06-27  Tor Lillqvist  <tml novell com>
 
 	* Makefile.am: Use NO_UNDEFINED. Link with more libraries.
@@ -11,5 +16,5 @@
 	* MakeFile.am:
 	* org-gnome-send-options.eplug.in: Plugin file to add
           the Mark all Messages read menu item.
-  	* send-options.c: Contains methods to mark messages as read.	
+  	* mark-all-read.c: Contains methods to mark messages as read.	
 
Index: plugins/mark-all-read/mark-all-read.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/mark-all-read/mark-all-read.c,v
retrieving revision 1.1
diff -p -U3 -r1.1 mark-all-read.c
--- plugins/mark-all-read/mark-all-read.c	19 May 2005 17:32:41 -0000	1.1
+++ plugins/mark-all-read/mark-all-read.c	12 Nov 2005 20:30:47 -0000
@@ -33,13 +33,19 @@
 #include <camel/camel-vee-folder.h>
 #include "e-util/e-error.h"
 
-void org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *target);
+void org_gnome_mark_all_read (EPopup *ep, EPopupItem *p, void *data);
 static void mar_got_folder (char *uri, CamelFolder *folder, void *data); 
+static void mar_got_factory_folder (char *uri, CamelFolder *folder, void *data); 
 static void mar_all_sub_folders (CamelStore *store, CamelFolderInfo *fi, CamelException *ex);
+static void mar_popup_free (EPopup *ep, GSList *items, void *data);
+void mar_menu_factory (EPlugin *ep, EMPopupTargetFolder *t);
+
 
 void 
-org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *t)
+org_gnome_mark_all_read (EPopup *ep, EPopupItem *p, void *data)
 {
+	EMPopupTargetFolder *t = (EMPopupTargetFolder *) data;
+
 	if (t->uri == NULL) {
 		return;
 	}
@@ -120,3 +126,42 @@ mar_all_sub_folders (CamelStore *store, 
 		fi = fi->next;
 	}
 }
+
+static EPopupItem mar_popup_items[] = {
+{ E_POPUP_ITEM, "10.emc.01", N_("Mark me_ssages as read"), org_gnome_mark_all_read, NULL, NULL, 0, EM_POPUP_FOLDER_FOLDER }
+};
+
+void
+mar_read_menu_factory (EPlugin *ep, EMPopupTargetFolder *t)
+{
+	if (t->uri == NULL) {
+		return;
+	}
+	
+	mail_get_folder(t->uri, 0, mar_got_factory_folder, NULL, mail_thread_new);
+}
+
+static void
+mar_got_factory_folder (char *uri, CamelFolder *folder, void *data)
+{
+	EMPopupTargetFolder *t = (EMPopupTargetFolder *) data;
+
+	GSList *menus = NULL;
+	int i;
+
+	if (folder->summary->unread_count > 0) {		
+		mar_popup_items[0].label =  _(mar_popup_items[0].label);
+
+		for (i = 0; i < sizeof (mar_popup_items) / sizeof (mar_popup_items[0]); i++)
+			menus = g_slist_prepend (menus, &mar_popup_items[i]);
+		e_popup_add_items (t->target.popup, menus, NULL, mar_popup_free, t);
+	}
+
+	return;
+}
+
+static void 
+mar_popup_free (EPopup *ep, GSList *items, void *data)
+{
+	g_slist_free (items);
+}
\ No newline at end of file
Index: plugins/mark-all-read/org-gnome-mark-all-read.eplug.in
===================================================================
RCS file: /cvs/gnome/evolution/plugins/mark-all-read/org-gnome-mark-all-read.eplug.in,v
retrieving revision 1.2
diff -p -U3 -r1.2 org-gnome-mark-all-read.eplug.in
--- plugins/mark-all-read/org-gnome-mark-all-read.eplug.in	18 Jun 2005 11:42:23 -0000	1.2
+++ plugins/mark-all-read/org-gnome-mark-all-read.eplug.in	12 Nov 2005 20:30:47 -0000
@@ -6,9 +6,8 @@
     <description>Used for marking all the messages under a folder as read</description>
     <author name="Chenthill Palanisamy" email="pchenthill novell com"/>
     <hook class="org.gnome.evolution.mail.popup:1.0">
-      <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder">
-        <item type="item" path="10.emc.01" label="Mark me_ssages as read"
-	activate="org_gnome_mark_all_read" enable="folder" visible="folder"/>
+      <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder"
+	factory = "mar_menu_factory" >
 	</menu>
     </hook>
  </e-plugin>

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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