[Evolution-hackers] camel folderinfo type changes



FYI

I've added a 3-bit bitfield to the CamelFolderInfo.flags field, so that
providers can specify certain types of folders.  This is used primarily
to give the folder the right icon, and also for some sorting priorities.
This removes the hard-coded hacks of comparing translated folder names -
so in some cases the icons may revert.  "bummer", they were iconised
wrong to start with if they do.

It is up to the providers to specify these values, the mailer hard-codes
it for the "local folders", since only it applies any meaning to the
various folders.

I fixed maildir and imap providers, imap4 will need its own fixing, as
will groupwise/exchange.

Patches attached to outline the changes for those interested/needing to
know.

PS means you need to update eds and evo to rebuild too

? camel/c.diff
? camel/camel-mime-tables.c
? camel/gpg
? camel/trace
? camel/providers/m.diff
? camel/tests/folder/test11
? camel/tests/message/test4
? camel/tests/mime-filter/test1
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2421
diff -u -p -r1.2421 ChangeLog
--- camel/ChangeLog	1 Feb 2005 05:57:15 -0000	1.2421
+++ camel/ChangeLog	1 Feb 2005 07:39:50 -0000
@@ -1,5 +1,11 @@
 2005-02-01  Not Zed  <NotZed Ximian com>
 
+	* camel-store.c (camel_store_get_folder_info): set the folder type
+	hint.
+
+	* camel-store.h: add a bitfield for a folder-type hint.  used to
+	indicate inbox/trash/etc (mainly for gui icons).
+
 	** See bug #38791 and bug #36142.
 
 	* camel-gpg-context.c (gpg_ctx_op_step): use poll rather than
Index: camel/camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-store.c,v
retrieving revision 1.158
diff -u -p -r1.158 camel-store.c
--- camel/camel-store.c	1 Feb 2005 00:47:43 -0000	1.158
+++ camel/camel-store.c	1 Feb 2005 07:39:51 -0000
@@ -663,7 +663,7 @@ get_folder_info (CamelStore *store, cons
 }
 
 static void
-add_special_info (CamelStore *store, CamelFolderInfo *info, const char *name, const char *translated, gboolean unread_count)
+add_special_info (CamelStore *store, CamelFolderInfo *info, const char *name, const char *translated, gboolean unread_count, guint32 flags)
 {
 	CamelFolderInfo *fi, *vinfo, *parent;
 	char *uri, *path;
@@ -711,7 +711,7 @@ add_special_info (CamelStore *store, Cam
 	}
 	
 	/* Fill in the new fields */
-	vinfo->flags |= CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH;
+	vinfo->flags |= flags;
 	vinfo->full_name = g_strdup (name);
 	vinfo->name = g_strdup (translated);
 	vinfo->uri = uri;
@@ -775,9 +775,9 @@ camel_store_get_folder_info(CamelStore *
 	
 	if (info && (top == NULL || *top == '\0') && (flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0) {
 		if (info->uri && (store->flags & CAMEL_STORE_VTRASH))
-			add_special_info (store, info, CAMEL_VTRASH_NAME, _("Trash"), FALSE);
+			add_special_info (store, info, CAMEL_VTRASH_NAME, _("Trash"), FALSE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_TRASH);
 		if (info->uri && (store->flags & CAMEL_STORE_VJUNK))
-			add_special_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), TRUE);
+			add_special_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), TRUE, CAMEL_FOLDER_VIRTUAL|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VTRASH|CAMEL_FOLDER_TYPE_JUNK);
 	}
 
 	if (camel_debug_start("store:folder_info")) {
Index: camel/camel-store.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-store.h,v
retrieving revision 1.71
diff -u -p -r1.71 camel-store.h
--- camel/camel-store.h	11 Jan 2005 06:12:45 -0000	1.71
+++ camel/camel-store.h	1 Feb 2005 07:39:51 -0000
@@ -74,8 +74,26 @@ typedef struct _CamelFolderInfo {
 #define CAMEL_FOLDER_SYSTEM (1<<6)
 /* a virtual folder that can't be copied to, and can only be moved to if in an existing folder */
 #define CAMEL_FOLDER_VTRASH (1<<7)
+/* a shared folder i'm accessing */
 #define CAMEL_FOLDER_SHARED_TO_ME (1<<8)
+/* a folder that i'm sharing */
 #define CAMEL_FOLDER_SHARED_BY_ME (1<<9)
+
+/* use 3 bits as a hint for a folder type */
+#define CAMEL_FOLDER_TYPE_MASK (7 << 10)
+#define CAMEL_FOLDER_TYPE_BIT (10)
+/* a normal folder */
+#define CAMEL_FOLDER_TYPE_NORMAL (0 << 10)
+/* an inbox folder */
+#define CAMEL_FOLDER_TYPE_INBOX (1 << 10)
+/* an outbox folder */
+#define CAMEL_FOLDER_TYPE_OUTBOX (2 << 10)
+/* a rubbish folder */
+#define CAMEL_FOLDER_TYPE_TRASH (3 << 10)
+/* a spam folder */
+#define CAMEL_FOLDER_TYPE_JUNK (4 << 10)
+
+/* next bit is 1<<13 */
 
 /* Structure of rename event's event_data */
 typedef struct _CamelRenameInfo {
Index: camel/providers/imap/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/ChangeLog,v
retrieving revision 1.3
diff -u -p -r1.3 ChangeLog
--- camel/providers/imap/ChangeLog	31 Jan 2005 03:48:16 -0000	1.3
+++ camel/providers/imap/ChangeLog	1 Feb 2005 07:39:51 -0000
@@ -1,3 +1,9 @@
+2005-02-01  Not Zed  <NotZed Ximian com>
+
+	* camel-imap-store.c (parse_list_response_as_folder_info): set the
+	folder-type of inbox to inbox & use the right flags field for
+	noinferiors hack.
+
 2005-01-31  Not Zed  <NotZed Ximian com>
 
 	** See bug #69757.
Index: camel/providers/imap/camel-imap-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap/camel-imap-store.c,v
retrieving revision 1.312
diff -u -p -r1.312 camel-imap-store.c
--- camel/providers/imap/camel-imap-store.c	31 Jan 2005 03:48:16 -0000	1.312
+++ camel/providers/imap/camel-imap-store.c	1 Feb 2005 07:39:52 -0000
@@ -2401,12 +2401,12 @@ parse_list_response_as_folder_info (Came
 	fi->name = g_strdup(camel_store_info_name(imap_store->summary, si));
 	fi->full_name = g_strdup(camel_store_info_path(imap_store->summary, si));
 	if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
-		flags |= CAMEL_FOLDER_SYSTEM;
+		flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_TYPE_INBOX;
 	/* HACK: some servers report noinferiors for all folders (uw-imapd)
 	   We just translate this into nochildren, and let the imap layer enforce
 	   it.  See create folder */
 	if (flags & CAMEL_FOLDER_NOINFERIORS)
-		flags = (fi->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
+		flags = (flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN;
 	fi->flags = flags;
 	
 	url = camel_url_new (imap_store->base_url, NULL);
Index: camel/providers/local/ChangeLog
===================================================================
RCS file: camel/providers/local/ChangeLog
diff -N camel/providers/local/ChangeLog
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ camel/providers/local/ChangeLog	1 Feb 2005 07:39:52 -0000
@@ -0,0 +1,8 @@
+
+2005-02-01  Not Zed  <NotZed Ximian com>
+
+	* camel-maildir-store.c (get_folder_info): set the
+	folder type of inbox properly.
+
+	* started new chnagelog.
+
Index: camel/providers/local/camel-maildir-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-maildir-store.c,v
retrieving revision 1.42
diff -u -p -r1.42 camel-maildir-store.c
--- camel/providers/local/camel-maildir-store.c	17 Jan 2005 09:01:54 -0000	1.42
+++ camel/providers/local/camel-maildir-store.c	1 Feb 2005 07:39:52 -0000
@@ -519,10 +519,10 @@ get_folder_info (CamelStore *store, cons
 			scan = scan->next;
 		}
 		fi->flags &= ~CAMEL_FOLDER_CHILDREN;
-		fi->flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS;
+		fi->flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS|CAMEL_FOLDER_TYPE_INBOX;
 	} else if (!strcmp(top, ".")) {
 		fi = scan_fi(store, flags, url, ".", _("Inbox"));
-		fi->flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS;
+		fi->flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS|CAMEL_FOLDER_TYPE_INBOX;
 	} else {
 		const char *name = strrchr(top, '/');
 
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3561
diff -u -p -r1.3561 ChangeLog
--- mail/ChangeLog	1 Feb 2005 00:33:53 -0000	1.3561
+++ mail/ChangeLog	1 Feb 2005 07:37:22 -0000
@@ -1,5 +1,20 @@
 2005-02-01  Not Zed  <NotZed Ximian com>
 
+	* em-folder-tree-model.c (sort_cb): use the type hint to sort for
+	inbox, not the name.
+	(emft_is_special_local_folder): removed.
+	(em_folder_tree_model_set_folder_info): special-case the
+	local-store case, handle translated names and the name hints.
+
+	* em-folder-tree.c (render_pixbuf): use the camel folderinfo
+	folder type to determine the icon, don't hardcode based on name.
+
+	** See bug #71310
+
+	* em-composer-prefs.c (sig_add_script_response): force a save of
+	the signatures as soon as they change.  Also save the script name
+	if we were just editing it, not just the signature name.
+
 	** See bug #71312.
 
 	* em-folder-view.c (em_folder_view_open_selected): if we're
Index: mail/em-composer-prefs.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-composer-prefs.c,v
retrieving revision 1.24
diff -u -p -r1.24 em-composer-prefs.c
--- mail/em-composer-prefs.c	24 Jan 2005 21:11:07 -0000	1.24
+++ mail/em-composer-prefs.c	1 Feb 2005 07:37:23 -0000
@@ -390,6 +390,8 @@ sig_add_script_response (GtkWidget *widg
 					/* we're just editing an existing signature script */
 					g_free (sig->name);
 					sig->name = g_strdup (name);
+					g_free(sig->filename);
+					sig->filename = g_strdup(script);
 					e_signature_list_change (mail_config_get_signatures (), sig);
 				} else {
 					sig = mail_config_signature_new (script, TRUE, TRUE);
@@ -399,6 +401,8 @@ sig_add_script_response (GtkWidget *widg
 					g_object_unref (sig);
 				}
 				
+				mail_config_save_signatures();
+
 				gtk_widget_hide (prefs->sig_script_dialog);
 				g_strfreev (argv);
 				g_free (script);
Index: mail/em-folder-tree-model.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree-model.c,v
retrieving revision 1.64
diff -u -p -r1.64 em-folder-tree-model.c
--- mail/em-folder-tree-model.c	24 Sep 2004 04:23:29 -0000	1.64
+++ mail/em-folder-tree-model.c	1 Feb 2005 07:37:23 -0000
@@ -184,12 +184,13 @@ sort_cb (GtkTreeModel *model, GtkTreeIte
 	char *aname, *bname;
 	CamelStore *store;
 	gboolean is_store;
+	guint32 aflags, bflags;
 	int rv = -2;
 	
 	gtk_tree_model_get (model, a, COL_BOOL_IS_STORE, &is_store,
 			    COL_POINTER_CAMEL_STORE, &store,
-			    COL_STRING_DISPLAY_NAME, &aname, -1);
-	gtk_tree_model_get (model, b, COL_STRING_DISPLAY_NAME, &bname, -1);
+			    COL_STRING_DISPLAY_NAME, &aname, COL_UINT_FLAGS, &aflags, -1);
+	gtk_tree_model_get (model, b, COL_STRING_DISPLAY_NAME, &bname, COL_UINT_FLAGS, &bflags, -1);
 	
 	if (is_store) {
 		/* On This Computer is always first and VFolders is always last */
@@ -209,9 +210,9 @@ sort_cb (GtkTreeModel *model, GtkTreeIte
 			rv = -1;
 	} else {
 		/* Inbox is always first */
-		if (aname && (!strcmp (aname, "INBOX") || !strcmp (aname, _("Inbox"))))
+		if ((aflags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX)
 			rv = -1;
-		else if (bname && (!strcmp (bname, "INBOX") || !strcmp (bname, _("Inbox"))))
+		else if ((bflags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX)
 			rv = 1;
 	}
 	
@@ -414,16 +415,6 @@ account_removed (EAccountList *accounts,
 	em_folder_tree_model_remove_store (model, si->store);
 }
 
-/* NB: more-or-less copied from em-folder-tree.c */
-static gboolean
-emft_is_special_local_folder(CamelStore *store, const char *name)
-{
-	/* Bit of a hack to translate local mailbox names */
-	return store == mail_component_peek_local_store(NULL)
-		&& (!strcmp (name, "Drafts") || !strcmp (name, "Inbox")
-		    || !strcmp (name, "Outbox") || !strcmp (name, "Sent"));
-}
-
 void
 em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *iter,
 				      struct _EMFolderTreeModelStoreInfo *si,
@@ -437,6 +428,7 @@ em_folder_tree_model_set_folder_info (EM
 	struct _CamelFolder *folder;
 	gboolean emitted = FALSE;
 	const char *name;
+	guint32 flags;
 
 	if (!fully_loaded)
 		load = fi->child == NULL && !(fi->flags & (CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_NOINFERIORS));
@@ -468,10 +460,22 @@ em_folder_tree_model_set_folder_info (EM
 		camel_object_unref(folder);
 	}
 
-	if (emft_is_special_local_folder(si->store, fi->full_name))
-		name = _(fi->name);
-	else
-		name = fi->name;
+	/* TODO: maybe this should be handled by mail_get_folderinfo (except em-folder-tree doesn't use it, duh) */
+	flags = fi->flags;
+	name = fi->name;
+	if (si->store == mail_component_peek_local_store(NULL)) {
+		if (!strcmp(fi->full_name, "Drafts")) {
+			name = _("Drafts");
+		} else if (!strcmp(fi->full_name, "Inbox")) {
+			flags = (flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_INBOX;
+			name = _("Inbox");
+		} else if (!strcmp(fi->full_name, "Outbox")) {
+			flags = (flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_OUTBOX;
+			name = _("Outbox");
+		} else if (!strcmp(fi->full_name, "Sent")) {
+			name = _("Sent");
+		}
+	}
 
 	gtk_tree_store_set ((GtkTreeStore *) model, iter,
 			    COL_STRING_DISPLAY_NAME, name,
@@ -479,7 +483,7 @@ em_folder_tree_model_set_folder_info (EM
 			    COL_STRING_FULL_NAME, fi->full_name,
 			    COL_STRING_URI, fi->uri,
 			    COL_UINT_UNREAD, unread,
-			    COL_UINT_FLAGS, fi->flags,
+			    COL_UINT_FLAGS, flags,
 			    COL_BOOL_IS_STORE, FALSE,
 			    COL_BOOL_LOAD_SUBDIRS, load,
 			    -1);
Index: mail/em-folder-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v
retrieving revision 1.142
diff -u -p -r1.142 em-folder-tree.c
--- mail/em-folder-tree.c	27 Jan 2005 07:05:56 -0000	1.142
+++ mail/em-folder-tree.c	1 Feb 2005 07:37:24 -0000
@@ -279,7 +279,6 @@ render_pixbuf (GtkTreeViewColumn *column
 	GdkPixbuf *pixbuf = NULL;
 	gboolean is_store;
 	guint32 flags;
-	char *full_name;
 	
 	if (!initialised) {
 		folder_icons[FOLDER_ICON_NORMAL] = e_icon_factory_get_icon ("stock_folder", E_ICON_SIZE_MENU);
@@ -292,27 +291,33 @@ render_pixbuf (GtkTreeViewColumn *column
 		initialised = TRUE;
 	}
 	
-	gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &full_name,
-			    COL_BOOL_IS_STORE, &is_store, COL_UINT_FLAGS, &flags, -1);
-	if (!is_store && full_name != NULL) {
-		if (!g_ascii_strcasecmp (full_name, "Inbox"))
+	gtk_tree_model_get (model, iter, COL_BOOL_IS_STORE, &is_store, COL_UINT_FLAGS, &flags, -1);
+
+	if (!is_store) {
+		switch((flags & CAMEL_FOLDER_TYPE_MASK)) {
+		case CAMEL_FOLDER_TYPE_INBOX:
 			pixbuf = folder_icons[FOLDER_ICON_INBOX];
-		else if (!g_ascii_strcasecmp (full_name, "Outbox"))
+			break;
+		case CAMEL_FOLDER_TYPE_OUTBOX:
 			pixbuf = folder_icons[FOLDER_ICON_OUTBOX];
-		else if (!strcmp (full_name, CAMEL_VTRASH_NAME))
+			break;
+		case CAMEL_FOLDER_TYPE_TRASH:
 			pixbuf = folder_icons[FOLDER_ICON_TRASH];
-		else if (!strcmp (full_name, CAMEL_VJUNK_NAME))
+			break;
+		case CAMEL_FOLDER_TYPE_JUNK:
 			pixbuf = folder_icons[FOLDER_ICON_JUNK];
-		else if (flags & CAMEL_FOLDER_SHARED_TO_ME) 
-			pixbuf = folder_icons[FOLDER_ICON_SHARED_TO_ME];
-		else if (flags & CAMEL_FOLDER_SHARED_BY_ME) 
-			pixbuf = folder_icons[FOLDER_ICON_SHARED_BY_ME];
-		else
-			pixbuf = folder_icons[FOLDER_ICON_NORMAL];
+			break;
+		default:
+			if (flags & CAMEL_FOLDER_SHARED_TO_ME) 
+				pixbuf = folder_icons[FOLDER_ICON_SHARED_TO_ME];
+			else if (flags & CAMEL_FOLDER_SHARED_BY_ME) 
+				pixbuf = folder_icons[FOLDER_ICON_SHARED_BY_ME];
+			else
+				pixbuf = folder_icons[FOLDER_ICON_NORMAL];
+		}
 	}
 		
 	g_object_set (renderer, "pixbuf", pixbuf, "visible", !is_store, NULL);
-	g_free (full_name);
 }
 
 static void


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