+
+typedef struct {
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf_open;
+ GdkPixbuf *pixbuf_close;
+} ThreePixbufs;
+
+
+static inline GdkPixbuf *
+get_composite_pixbuf (const gchar *icon_name,
+ const gint size,
+ GdkPixbuf *base_pixbuf)
+{
+ GdkPixbuf *emblem, *retval = NULL;
+
+ emblem = modest_platform_get_icon (icon_name, size);
+ if (emblem) {
+ retval = gdk_pixbuf_copy (base_pixbuf);
+ gdk_pixbuf_composite (emblem, retval, 0, 0,
+ MIN (gdk_pixbuf_get_width (emblem),
+ gdk_pixbuf_get_width (retval)),
+ MIN (gdk_pixbuf_get_height (emblem),
+ gdk_pixbuf_get_height (retval)),
+ 0, 0, 1, 1, GDK_INTERP_NEAREST, 255);
+ g_object_unref (emblem);
+ }
+ return retval;
+}
+
+static inline ThreePixbufs *
+get_composite_icons (const gchar *icon_code,
+ GdkPixbuf **pixbuf,
+ GdkPixbuf **pixbuf_open,
+ GdkPixbuf **pixbuf_close)
+{
+ ThreePixbufs *retval;
+
+ if (!*pixbuf)
+ *pixbuf = gdk_pixbuf_copy (modest_platform_get_icon (icon_code, FOLDER_ICON_SIZE));
+
+ if (!*pixbuf_open)
+ *pixbuf_open = get_composite_pixbuf ("qgn_list_gene_fldr_exp",
+ FOLDER_ICON_SIZE,
+ *pixbuf);
+
+ if (!*pixbuf_close)
+ *pixbuf_close = get_composite_pixbuf ("qgn_list_gene_fldr_clp",
+ FOLDER_ICON_SIZE,
+ *pixbuf);
+
+ retval = g_slice_new0 (ThreePixbufs);
+ if (*pixbuf)
+ retval->pixbuf = g_object_ref (*pixbuf);
+ if (*pixbuf_open)
+ retval->pixbuf_open = g_object_ref (*pixbuf_open);
+ if (*pixbuf_close)
+ retval->pixbuf_close = g_object_ref (*pixbuf_close);
+
+ return retval;
+}
+
+static inline ThreePixbufs*
+get_folder_icons (TnyFolderType type, GObject *instance)
+{
+ static GdkPixbuf *inbox_pixbuf = NULL, *outbox_pixbuf = NULL,
+ *junk_pixbuf = NULL, *sent_pixbuf = NULL,
+ *trash_pixbuf = NULL, *draft_pixbuf = NULL,
+ *normal_pixbuf = NULL, *anorm_pixbuf = NULL,
+ *ammc_pixbuf = NULL, *avirt_pixbuf = NULL;
+
+ static GdkPixbuf *inbox_pixbuf_open = NULL, *outbox_pixbuf_open = NULL,
+ *junk_pixbuf_open = NULL, *sent_pixbuf_open = NULL,
+ *trash_pixbuf_open = NULL, *draft_pixbuf_open = NULL,
+ *normal_pixbuf_open = NULL, *anorm_pixbuf_open = NULL,
+ *ammc_pixbuf_open = NULL, *avirt_pixbuf_open = NULL;
+
+ static GdkPixbuf *inbox_pixbuf_close = NULL, *outbox_pixbuf_close = NULL,
+ *junk_pixbuf_close = NULL, *sent_pixbuf_close = NULL,
+ *trash_pixbuf_close = NULL, *draft_pixbuf_close = NULL,
+ *normal_pixbuf_close = NULL, *anorm_pixbuf_close = NULL,
+ *ammc_pixbuf_close = NULL, *avirt_pixbuf_close = NULL;
+
+ ThreePixbufs *retval = NULL;
+
+ /* Sometimes an special folder is reported by the server as
+ NORMAL, like some versions of Dovecot */
+ if (type == TNY_FOLDER_TYPE_NORMAL ||