aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2000-10-05 08:38:06 +0800
committerIain Holmes <iain@src.gnome.org>2000-10-05 08:38:06 +0800
commit2deab9c41716083286a3c74d1ece13214972399c (patch)
treed6b66432b251460416a3128939be1ec2de7ab7f2 /mail
parent9c6aafaf7203d96cc60adcc192b16e2d50bf7f62 (diff)
downloadgsoc2013-evolution-2deab9c41716083286a3c74d1ece13214972399c.tar.gz
gsoc2013-evolution-2deab9c41716083286a3c74d1ece13214972399c.tar.zst
gsoc2013-evolution-2deab9c41716083286a3c74d1ece13214972399c.zip
Add the stuff to make evolution-mail a summary providing component. :)
svn path=/trunk/; revision=5738
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog15
-rw-r--r--mail/GNOME_Evolution_Mail.oaf.in24
-rw-r--r--mail/GNOME_Evolution_Mail.oafinfo24
-rw-r--r--mail/component-factory.c23
-rw-r--r--mail/evolution-mail.oafinfo24
-rw-r--r--mail/mail-display.c59
-rw-r--r--mail/mail-summary.c128
-rw-r--r--mail/mail-summary.h3
8 files changed, 254 insertions, 46 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d1b46fb100..1083bda253 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,18 @@
+2000-10-05 Iain Holmes <iain@helixcode.com>
+
+ * component-factory.c (component_factory_init): Setup the summary
+ factory as well.
+ (summary_fn): New function to create the ExecutiveSummaryComponent.
+
+ * mail-summary.c: Create the view, and update it when something
+ changes.
+
+2000-10-04 Iain Holmes <iain@helixcode.com>
+
+ * mail-display.c (on_object_requested): Removed the pixbuf cache
+ as it would return the pixbufs in the reverse order every so often
+ and generally get all confused.
+
2000-10-04 Dan Winship <danw@helixcode.com>
* folder-browser-factory.c (control_deactivate): Add back the
diff --git a/mail/GNOME_Evolution_Mail.oaf.in b/mail/GNOME_Evolution_Mail.oaf.in
index 2be622f3f6..5c012e5634 100644
--- a/mail/GNOME_Evolution_Mail.oaf.in
+++ b/mail/GNOME_Evolution_Mail.oaf.in
@@ -38,6 +38,18 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217"
+ type="exe"
+ location="evolution-mail">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME:GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Mail Summary component."/>
+</oaf_server>
+
<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b"
type="factory"
location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6">
@@ -51,4 +63,16 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component:evolution-mail:157f86b4-ff6a-4618-86b8-4789024c4043"
+ type="factory"
+ location="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution:SummaryComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution mail executive summary component."/>
+</oaf_server>
+
</oaf_info>
diff --git a/mail/GNOME_Evolution_Mail.oafinfo b/mail/GNOME_Evolution_Mail.oafinfo
index 2be622f3f6..5c012e5634 100644
--- a/mail/GNOME_Evolution_Mail.oafinfo
+++ b/mail/GNOME_Evolution_Mail.oafinfo
@@ -38,6 +38,18 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217"
+ type="exe"
+ location="evolution-mail">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME:GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Mail Summary component."/>
+</oaf_server>
+
<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b"
type="factory"
location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6">
@@ -51,4 +63,16 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component:evolution-mail:157f86b4-ff6a-4618-86b8-4789024c4043"
+ type="factory"
+ location="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution:SummaryComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution mail executive summary component."/>
+</oaf_server>
+
</oaf_info>
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 0e745414e9..27fd585840 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -41,7 +41,9 @@
#include <gal/widgets/e-gui-utils.h>
#include "mail-local-storage.h"
+#include <executive-summary/evolution-services/executive-summary-component.h>
#include "component-factory.h"
+#include "mail-summary.h"
CamelFolder *drafts_folder = NULL;
CamelFolder *outbox_folder = NULL;
@@ -51,8 +53,10 @@ char *evolution_dir;
static void create_vfolder_storage (EvolutionShellComponent *shell_component);
#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"
+#define SUMMARY_FACTORY_ID "OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217"
static BonoboGenericFactory *factory = NULL;
+static BonoboGenericFactory *summary_factory = NULL;
static gint running_objects = 0;
static const EvolutionShellComponentFolderType folder_types[] = {
@@ -162,6 +166,17 @@ factory_destroy (BonoboEmbeddable *embeddable,
}
static BonoboObject *
+summary_fn (BonoboGenericFactory *factory, void *closure)
+{
+ ExecutiveSummaryComponent *summary_component;
+
+ summary_component = executive_summary_component_new (NULL,
+ create_summary_view,
+ NULL, NULL);
+ return BONOBO_OBJECT (summary_component);
+}
+
+static BonoboObject *
factory_fn (BonoboGenericFactory *factory, void *closure)
{
EvolutionShellComponent *shell_component;
@@ -188,16 +203,22 @@ factory_fn (BonoboGenericFactory *factory, void *closure)
void
component_factory_init (void)
{
- if (factory != NULL)
+ if (factory != NULL && summary_factory != NULL)
return;
factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL);
+ summary_factory = bonobo_generic_factory_new (SUMMARY_FACTORY_ID, summary_fn, NULL);
if (factory == NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("Cannot initialize Evolution's mail component."));
exit (1);
}
+
+ if (summary_factory == NULL) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot initialize Evolution's mail summary component."));
+ }
}
/* FIXME: remove */
diff --git a/mail/evolution-mail.oafinfo b/mail/evolution-mail.oafinfo
index 2be622f3f6..5c012e5634 100644
--- a/mail/evolution-mail.oafinfo
+++ b/mail/evolution-mail.oafinfo
@@ -38,6 +38,18 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217"
+ type="exe"
+ location="evolution-mail">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME:GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Factory for the Mail Summary component."/>
+</oaf_server>
+
<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b"
type="factory"
location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6">
@@ -51,4 +63,16 @@
</oaf_server>
+<oaf_server iid="OAFIID:evolution-executive-summary-component:evolution-mail:157f86b4-ff6a-4618-86b8-4789024c4043"
+ type="factory"
+ location="OAFIID:evolution-executive-summary-component-factory:evolution-mail:be210cba-0eee-4def-84fa-643d50321217">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Evolution:SummaryComponent:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ value="Evolution mail executive summary component."/>
+</oaf_server>
+
</oaf_info>
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 9b2cc4e410..e23f4d229e 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -430,9 +430,7 @@ pixbuf_gen_idle (struct _PixbufLoader *pbl)
because Imlib is not threadsafe, and
it was causing all sorts of problems */
bonobo_ui_toolbar_icon_set_pixbuf (BONOBO_UI_TOOLBAR_ICON (pbl->pixmap), mini);
-
- /* Add to cache for later */
- g_hash_table_insert (pbl->cache, pbl->cid, mini);
+ gtk_widget_set_usize (pbl->pixmap, width, height);
}
camel_object_unref (CAMEL_OBJECT (pbl->mstream));
@@ -449,7 +447,6 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
{
MailDisplay *md = data;
GHashTable *urls;
- GHashTable *pb_cache;
CamelMedium *medium;
CamelDataWrapper *wrapper;
OAF_ServerInfo *component;
@@ -471,9 +468,6 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
urls = g_datalist_get_data (md->data, "urls");
g_return_val_if_fail (urls != NULL, FALSE);
- pb_cache = md->pb_cache;
- g_return_val_if_fail (pb_cache != NULL, FALSE);
-
medium = g_hash_table_lookup (urls, cid);
g_return_val_if_fail (CAMEL_IS_MEDIUM (medium), FALSE);
@@ -484,27 +478,20 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
if (strncmp (eb->type, "image", 5) == 0) {
struct _PixbufLoader *pbl;
- GdkPixbuf *pb;
- /* Check the cache */
- pb = g_hash_table_lookup (pb_cache, cid);
- if (pb) {
- pixmap = bonobo_ui_toolbar_icon_new_from_pixbuf (pb);
- } else {
- pbl = g_new (struct _PixbufLoader, 1);
- pbl->wrapper = camel_medium_get_content_object (medium);
- pbl->loader = NULL;
- pbl->mstream = NULL;
- pbl->cache = pb_cache;
- pbl->cid = g_strdup (cid);
- pbl->type = g_strdup (eb->type);
- pixmap = bonobo_ui_toolbar_icon_new ();
- gtk_widget_set_usize (pixmap, 24, 24);
- pbl->pixmap = pixmap;
-
- g_idle_add_full (G_PRIORITY_LOW, pixbuf_gen_idle,
- pbl, NULL);
- }
+ pbl = g_new (struct _PixbufLoader, 1);
+ pbl->wrapper = camel_medium_get_content_object (medium);
+ pbl->loader = NULL;
+ pbl->mstream = NULL;
+
+ pbl->type = g_strdup (eb->type);
+ pixmap = bonobo_ui_toolbar_icon_new ();
+
+ gtk_widget_set_usize (pixmap, 24, 24);
+ pbl->pixmap = pixmap;
+
+ g_idle_add_full (G_PRIORITY_LOW, pixbuf_gen_idle,
+ pbl, NULL);
} else {
icon = gnome_vfs_mime_get_value (eb->type, "icon-filename");
if (icon) {
@@ -699,22 +686,6 @@ clear_data (CamelObject *object, gpointer event_data, gpointer user_data)
}
static void
-free_pb (gpointer key,
- gpointer pb,
- gpointer data)
-{
- g_free (key);
- gdk_pixbuf_unref ((GdkPixbuf *)pb);
-}
-
-static void
-free_cache (gpointer cache)
-{
- g_hash_table_foreach (cache, free_pb, NULL);
- g_hash_table_destroy (cache);
-}
-
-static void
redisplay (MailDisplay *md, gboolean unscroll)
{
GtkAdjustment *adj;
@@ -804,7 +775,6 @@ mail_display_destroy (GtkObject *object)
g_datalist_clear (mail_display->data);
g_free (mail_display->data);
- free_cache (mail_display->pb_cache);
mail_display_parent_class->destroy (object);
}
@@ -851,7 +821,6 @@ mail_display_new (void)
mail_display->data = g_new0 (GData *, 1);
g_datalist_init (mail_display->data);
- mail_display->pb_cache = g_hash_table_new (g_str_hash, g_str_equal);
return GTK_WIDGET (mail_display);
}
diff --git a/mail/mail-summary.c b/mail/mail-summary.c
new file mode 100644
index 0000000000..553a8d90be
--- /dev/null
+++ b/mail/mail-summary.c
@@ -0,0 +1,128 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* mail-summary.c
+ *
+ * Authors: Iain Holmes <iain@helixcode.com>
+ *
+ * Copyright (C) 2000 Helix Code, 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 <bonobo.h>
+
+#include "camel.h"
+
+#include "mail.h" /* YUCK FIXME */
+#include "mail-tools.h"
+#include "mail-ops.h"
+#include <gal/widgets/e-gui-utils.h>
+#include "mail-local-storage.h"
+
+#include <executive-summary/evolution-services/executive-summary-component.h>
+
+typedef struct {
+ ExecutiveSummaryComponent *component;
+ CamelFolder *folder;
+
+ int mailread, mailunread;
+ char *html;
+} MailSummary;
+
+/* Temporary functions to create the summary
+ FIXME: Need TigerT's designs :) */
+static void
+folder_changed_cb (CamelObject *folder,
+ gpointer event_data,
+ gpointer user_data)
+{
+ MailSummary *summary;
+ char *ret_html, *str1, *str2;
+ int mailread, mailunread;
+
+ summary = (MailSummary *)user_data;
+
+ mailread = camel_folder_get_message_count (CAMEL_FOLDER (folder));
+ mailunread = camel_folder_get_unread_message_count (CAMEL_FOLDER (folder));
+
+ str1 = g_strdup_printf (_("There %s %d %s."),
+ (mailread == 1) ? _("is"): _("are"),
+ mailread,
+ (mailread == 1) ? _("message"): _("messages"));
+ str2 = g_strdup_printf (_("There %s %d unread %s."),
+ (mailunread == 1) ? _("is"): _("are"),
+ mailunread,
+ (mailunread == 1) ? _("message"): _("messages"));
+
+ ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1, str2);
+ g_free (str1);
+ g_free (str2);
+
+ executive_summary_component_update (summary->component, ret_html);
+ g_free (ret_html);
+}
+
+char *
+create_summary_view (ExecutiveSummaryComponent *component,
+ char **title,
+ void *closure)
+{
+ char *str1, *str2, *ret_html;
+ int mailread, mailunread;
+ CamelFolder *folder;
+ CamelException *ex;
+ MailSummary *summary;
+
+ ex = camel_exception_new ();
+ folder = mail_tool_get_local_inbox (ex);
+
+ /* Strdup the title */
+ *title = g_strdup ("Inbox:");
+
+ mailread = camel_folder_get_message_count (folder);
+ mailunread = camel_folder_get_unread_message_count (folder);
+
+ str1 = g_strdup_printf (_("There %s %d %s."),
+ (mailread == 1) ? _("is"): _("are"),
+ mailread,
+ (mailread == 1) ? _("message"): _("messages"));
+ str2 = g_strdup_printf (_("There %s %d unread %s."),
+ (mailunread == 1) ? _("is"): _("are"),
+ mailunread,
+ (mailunread == 1) ? _("message"): _("messages"));
+
+ ret_html = g_strdup_printf ("<table><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr><tr><td><img src=\"evolution-inbox-mini.png\"></td><td>%s</td></tr></table>", str1, str2);
+ g_free (str1);
+ g_free (str2);
+
+ summary = g_new (MailSummary, 1);
+ summary->folder = folder;
+ summary->html = ret_html;
+ summary->mailread = mailread;
+ summary->mailunread = mailunread;
+ summary->component = component;
+
+ camel_object_hook_event (folder, "folder_changed",
+ (CamelObjectEventHookFunc) folder_changed_cb,
+ summary);
+ camel_object_hook_event (folder, "message_changed",
+ (CamelObjectEventHookFunc) folder_changed_cb,
+ summary);
+ return ret_html;
+}
diff --git a/mail/mail-summary.h b/mail/mail-summary.h
new file mode 100644
index 0000000000..52c64cfb52
--- /dev/null
+++ b/mail/mail-summary.h
@@ -0,0 +1,3 @@
+char * create_summary_view (ExecutiveSummaryComponent *component,
+ char **title,
+ void *closure);