[evolution-patches] mailer: vtrash/vjunk folder info patch for evo/HEAD



Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1922
diff -u -p -r1.1922 ChangeLog
--- camel/ChangeLog	26 Nov 2003 19:32:15 -0000	1.1922
+++ camel/ChangeLog	28 Nov 2003 09:48:32 -0000
@@ -1,3 +1,8 @@
+2003-11-28  Radek Doulik  <rodo ximian com>
+
+	* camel-store.c (camel_store_get_folder_info): use old code from
+	mail-ops to add vtrash/vjunk info
+
 2003-11-26  JP Rosevear <jpr ximian com>
 
 	* Makefile.am: make sure we always dist the smime stuff
Index: camel/camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-store.c,v
retrieving revision 1.121
diff -u -p -r1.121 camel-store.c
--- camel/camel-store.c	12 Nov 2003 21:12:48 -0000	1.121
+++ camel/camel-store.c	28 Nov 2003 09:48:36 -0000
@@ -689,6 +689,72 @@ get_folder_info (CamelStore *store, cons
 	return NULL;
 }
 
+static void
+add_vtrash_or_vjunk_info (CamelStore *store, CamelFolderInfo *info, gchar *name, gchar *full_name, gchar *url_base, gboolean unread_count)
+{
+	CamelFolderInfo *fi, *vinfo, *parent;
+	char *uri, *path;
+	CamelURL *url;
+	
+	g_return_if_fail (info != NULL);
+
+	parent = NULL;
+	for (fi = info; fi; fi = fi->sibling) {
+		if (!strcmp (fi->name, name))
+			break;
+		parent = fi;
+	}
+	
+	/* create our vTrash/vJunk URL */
+	url = camel_url_new (info->url, NULL);
+	path = g_strdup_printf ("/%s", name);
+	if (url->fragment)
+		camel_url_set_fragment (url, path);
+	else
+		camel_url_set_path (url, path);
+	g_free (path);
+	uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+	camel_url_free (url);
+	
+	if (fi) {
+		/* We're going to replace the physical Trash/Junk folder with our vTrash/vJunk folder */
+		vinfo = fi;
+		g_free (vinfo->full_name);
+		g_free (vinfo->name);
+		g_free (vinfo->url);
+	} else {
+		/* There wasn't a Trash/Junk folder so create a new folder entry */
+		vinfo = g_new0 (CamelFolderInfo, 1);
+
+		g_assert(parent != NULL);
+
+		/* link it into the right spot */
+		vinfo->sibling = parent->sibling;
+		parent->sibling = vinfo;
+	}
+	
+	/* Fill in the new fields */
+	vinfo->full_name = g_strdup (full_name);
+	vinfo->name = g_strdup(vinfo->full_name);
+	vinfo->url = g_strdup_printf ("%s:%s", url_base, uri);
+	if (!unread_count)
+		vinfo->unread_message_count = -1;
+	vinfo->path = g_strdup_printf("/%s", vinfo->name);
+	g_free (uri);
+}
+
+static void
+add_vtrash_info (CamelStore *store, CamelFolderInfo *info)
+{
+	add_vtrash_or_vjunk_info (store, info, CAMEL_VTRASH_NAME, _("Trash"), "vtrash", FALSE);
+}
+
+static void
+add_vjunk_info (CamelStore *store, CamelFolderInfo *info)
+{
+	add_vtrash_or_vjunk_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), "vjunk", TRUE);
+}
+
 /**
  * camel_store_get_folder_info:
  * @store: a CamelStore
@@ -725,6 +791,13 @@ camel_store_get_folder_info (CamelStore 
 	CAMEL_STORE_LOCK(store, folder_lock);
 	ret = CS_CLASS (store)->get_folder_info (store, top, flags, ex);
 	CAMEL_STORE_UNLOCK(store, folder_lock);
+
+	if (ret) {
+		if (ret->url && (store->flags & CAMEL_STORE_VTRASH))
+			add_vtrash_info(store, ret);
+		if (ret->url && (store->flags & CAMEL_STORE_VJUNK))
+			add_vjunk_info(store, ret);
+	}
 
 	return ret;
 }
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2901
diff -u -p -r1.2901 ChangeLog
--- mail/ChangeLog	26 Nov 2003 15:26:42 -0000	1.2901
+++ mail/ChangeLog	28 Nov 2003 09:48:46 -0000
@@ -1,3 +1,8 @@
+2003-11-28  Radek Doulik  <rodo ximian com>
+
+	* em-folder-tree.c (render_pixbuf): added junk icon to folder
+	icons
+
 2003-11-26  JP Rosevear  <jpr ximian com>
 
 	* Makefile.am: turn on deprecated Gtk stuff
Index: mail/em-folder-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v
retrieving revision 1.19
diff -u -p -r1.19 em-folder-tree.c
--- mail/em-folder-tree.c	25 Nov 2003 03:54:13 -0000	1.19
+++ mail/em-folder-tree.c	28 Nov 2003 09:48:47 -0000
@@ -233,10 +233,12 @@ enum {
 	FOLDER_ICON_NORMAL,
 	FOLDER_ICON_INBOX,
 	FOLDER_ICON_OUTBOX,
-	FOLDER_ICON_TRASH
+	FOLDER_ICON_TRASH,
+	FOLDER_ICON_JUNK,
+	FOLDER_ICON_LAST
 };
 
-static GdkPixbuf *folder_icons[4];
+static GdkPixbuf *folder_icons[FOLDER_ICON_LAST];
 
 static void
 render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
@@ -248,10 +250,11 @@ render_pixbuf (GtkTreeViewColumn *column
 	char *path;
 	
 	if (!initialised) {
-		folder_icons[0] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/folder-mini.png", NULL);
-		folder_icons[1] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/inbox-mini.png", NULL);
-		folder_icons[2] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/outbox-mini.png", NULL);
-		folder_icons[3] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/evolution-trash-mini.png", NULL);
+		folder_icons[FOLDER_ICON_NORMAL] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/folder-mini.png", NULL);
+		folder_icons[FOLDER_ICON_INBOX] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/inbox-mini.png", NULL);
+		folder_icons[FOLDER_ICON_OUTBOX] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/outbox-mini.png", NULL);
+		folder_icons[FOLDER_ICON_TRASH] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/evolution-trash-mini.png", NULL);
+		folder_icons[FOLDER_ICON_JUNK] = gdk_pixbuf_new_from_file (EVOLUTION_ICONSDIR "/evolution-junk-mini.png", NULL);
 		initialised = TRUE;
 	}
 	
@@ -265,6 +268,8 @@ render_pixbuf (GtkTreeViewColumn *column
 			pixbuf = folder_icons[FOLDER_ICON_OUTBOX];
 		else if (!strcasecmp (path, "/Trash"))
 			pixbuf = folder_icons[FOLDER_ICON_TRASH];
+		else if (!strcasecmp (path, "/Junk"))
+			pixbuf = folder_icons[FOLDER_ICON_JUNK];
 		else
 			pixbuf = folder_icons[FOLDER_ICON_NORMAL];
 	}


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