evolution r35437 - trunk/mail



Author: mcrha
Date: Tue Apr 29 08:35:05 2008
New Revision: 35437
URL: http://svn.gnome.org/viewvc/evolution?rev=35437&view=rev

Log:
2008-04-29  Milan Crha  <mcrha redhat com>

	** Fix for bug #511337

	* em-format-html.h: (EMFormatHTMLState), (struct _EMFormatHTML):
	* em-format-html.c: (efh_init), (efh_format_done),
	(efh_format_timeout): Track state of the object to recognize
	whether rendering new content or doing nothing.
	* em-format-html-display.c: (efhd_can_process_attachment),
	(efhd_attachment_show), (efhd_attachment_popup),
	(efhd_attachment_image), (efhd_attachment_button):
	Do nothing when EMFormatHTML object's state is RENDERING,
	the puri object instance is not valid anyway.



Modified:
   trunk/mail/ChangeLog
   trunk/mail/em-format-html-display.c
   trunk/mail/em-format-html.c
   trunk/mail/em-format-html.h

Modified: trunk/mail/em-format-html-display.c
==============================================================================
--- trunk/mail/em-format-html-display.c	(original)
+++ trunk/mail/em-format-html-display.c	Tue Apr 29 08:35:05 2008
@@ -1424,6 +1424,21 @@
 
 /* ********************************************************************** */
 
+/* Checks on the widget whether it can be processed, based on the state of EMFormatHTML.
+   The widget should have set "efh" data as the EMFormatHTML instance. */
+static gboolean
+efhd_can_process_attachment (GtkWidget *button)
+{
+	EMFormatHTML *efh;
+
+	if (!button)
+		return FALSE;
+
+	efh = g_object_get_data (G_OBJECT (button), "efh");
+
+	return efh && efh->state != EM_FORMAT_HTML_STATE_RENDERING;
+}
+
 /* if it hasn't been processed yet, format the attachment */
 static void
 efhd_attachment_show(EPopup *ep, EPopupItem *item, void *data)
@@ -1439,6 +1454,9 @@
 static void
 efhd_attachment_button_show(GtkWidget *w, void *data)
 {
+	if (!efhd_can_process_attachment (w))
+		return;
+
 	efhd_attachment_show(NULL, NULL, data);
 }
 
@@ -1499,6 +1517,9 @@
 		return FALSE;
 	}
 
+	if (!efhd_can_process_attachment (w))
+		return FALSE;
+
 	/** @HookPoint-EMPopup: Attachment Button Context Menu
 	 * @Id: org.gnome.evolution.mail.formathtmldisplay.popup
 	 * @Class: org.gnome.evolution.mail.popup:1.0
@@ -1765,6 +1786,8 @@
 	g_signal_connect(box, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info);
 	g_signal_connect(box, "button-press-event", G_CALLBACK(efhd_image_fit_width), info);
 
+	g_object_set_data (G_OBJECT (box), "efh", efh);
+
 	return TRUE;
 }
 
@@ -1840,9 +1863,10 @@
 
 	button = gtk_button_new();
 
-	if (info->handle)
+	if (info->handle) {
 		g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_button_show), info);
-	else {
+		g_object_set_data (G_OBJECT (button), "efh", efh);
+	} else {
 		gtk_widget_set_sensitive(button, FALSE);
 		GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
 	}
@@ -1916,6 +1940,8 @@
 	g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info);
 	gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0);
 
+	g_object_set_data (G_OBJECT (button), "efh", efh);
+
 	gtk_widget_show_all(mainbox);
 
 	if (info->shown)

Modified: trunk/mail/em-format-html.c
==============================================================================
--- trunk/mail/em-format-html.c	(original)
+++ trunk/mail/em-format-html.c	Tue Apr 29 08:35:05 2008
@@ -170,6 +170,7 @@
 	efh->text_html_flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
 		| CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
 	efh->show_icon = TRUE;
+	efh->state = EM_FORMAT_HTML_STATE_NONE;
 }
 
 static void
@@ -1330,6 +1331,7 @@
 
 	m->format->load_http_now = FALSE;
 	m->format->priv->format_id = -1;
+	m->format->state = EM_FORMAT_HTML_STATE_NONE;
 	g_signal_emit_by_name(m->format, "complete");
 }
 
@@ -1398,6 +1400,8 @@
 		mail_msg_unref(m);
 		p->last_part = NULL;
 	} else {
+		efh->state = EM_FORMAT_HTML_STATE_RENDERING;
+
 		if (p->last_part != m->message) {
 			hstream = gtk_html_begin (efh->html);
 			gtk_html_stream_printf (hstream, "<h5>%s</h5>", _("Formatting Message..."));

Modified: trunk/mail/em-format-html.h
==============================================================================
--- trunk/mail/em-format-html.h	(original)
+++ trunk/mail/em-format-html.h	Tue Apr 29 08:35:05 2008
@@ -49,6 +49,11 @@
 	EM_FORMAT_HTML_HEADER_BCC = 1<<2,
 };
 
+typedef enum {
+	EM_FORMAT_HTML_STATE_NONE = 0,
+	EM_FORMAT_HTML_STATE_RENDERING
+} EMFormatHTMLState;
+
 /* A HTMLJob will be executed in another thread, in sequence,
    It's job is to write to its stream, close it if successful,
    then exit */
@@ -196,6 +201,8 @@
 	unsigned int hide_headers:1; /* no headers at all */
 	unsigned int show_icon:1; /* show an icon when the sender used Evo */
 	guint32 header_wrap_flags;
+
+	EMFormatHTMLState state; /* actual state of the object */
 };
 
 struct _EMFormatHTMLClass {



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