aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-08-11 06:08:55 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-08-11 06:53:31 +0800
commit699e36491b564069bce8c36a79d4803b5d9492d1 (patch)
treeb5a6e652ed45d589eeb6416bf11194c2e8175130
parent18813ccd8f4367ac98348f08e183d858cfe963f5 (diff)
downloadgsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar.gz
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar.bz2
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar.lz
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar.xz
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.tar.zst
gsoc2013-evolution-699e36491b564069bce8c36a79d4803b5d9492d1.zip
Change em_format_redraw() to em_format_queue_redraw().
This changes the behavior of the function: instead of redrawing immediately it schedules the redraw from an idle callback. This allows us to make multiple changes to EMFormat before redrawing.
-rw-r--r--em-format/em-format.c46
-rw-r--r--em-format/em-format.h3
-rw-r--r--mail/e-mail-browser.c2
-rw-r--r--mail/e-mail-display.c4
-rw-r--r--mail/e-mail-paned-view.c2
-rw-r--r--mail/e-mail-reader-utils.c2
-rw-r--r--mail/e-mail-reader.c4
-rw-r--r--mail/em-format-html.c4
-rw-r--r--mail/em-utils.c2
9 files changed, 50 insertions, 19 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 5892bd772d..8b3d069e2e 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -36,8 +36,16 @@
#include "shell/e-shell.h"
#include "shell/e-shell-settings.h"
+#define EM_FORMAT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), EM_TYPE_FORMAT, EMFormatPrivate))
+
#define d(x)
+struct _EMFormatPrivate {
+ guint redraw_idle_id;
+};
+
/* Used to cache various data/info for redraws
The validity stuff could be cached at a higher level but this is easier
This absolutely relies on the partid being _globally unique_
@@ -106,6 +114,9 @@ emf_finalize (GObject *object)
{
EMFormat *emf = EM_FORMAT (object);
+ if (emf->priv->redraw_idle_id > 0)
+ g_source_remove (emf->priv->redraw_idle_id);
+
if (emf->session)
g_object_unref (emf->session);
@@ -142,6 +153,12 @@ emf_format_clone (EMFormat *emf,
CamelMimeMessage *msg,
EMFormat *emfsource)
{
+ /* Cancel any pending redraws. */
+ if (emf->priv->redraw_idle_id > 0) {
+ g_source_remove (emf->priv->redraw_idle_id);
+ emf->priv->redraw_idle_id = 0;
+ }
+
em_format_clear_puri_tree(emf);
if (emf != emfsource) {
@@ -276,6 +293,7 @@ emf_class_init (EMFormatClass *class)
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMFormatPrivate));
object_class = G_OBJECT_CLASS (class);
object_class->finalize = emf_finalize;
@@ -305,6 +323,8 @@ emf_init (EMFormat *emf)
EShell *shell;
EShellSettings *shell_settings;
+ emf->priv = EM_FORMAT_GET_PRIVATE (emf);
+
emf->inline_table = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
@@ -884,13 +904,25 @@ em_format_format (EMFormat *emf,
em_format_format_clone (emf, folder, uid, message, NULL);
}
-void
-em_format_redraw (EMFormat *emf)
+static gboolean
+format_redraw_idle_cb (EMFormat *emf)
{
- g_return_if_fail (EM_IS_FORMAT (emf));
+ emf->priv->redraw_idle_id = 0;
em_format_format_clone (
emf, emf->folder, emf->uid, emf->message, emf);
+
+ return FALSE;
+}
+
+void
+em_format_queue_redraw (EMFormat *emf)
+{
+ g_return_if_fail (EM_IS_FORMAT (emf));
+
+ if (emf->priv->redraw_idle_id == 0)
+ emf->priv->redraw_idle_id = g_idle_add (
+ (GSourceFunc) format_redraw_idle_cb, emf);
}
/**
@@ -914,7 +946,7 @@ em_format_set_mode (EMFormat *emf,
/* force redraw if type changed afterwards */
if (emf->message != NULL)
- em_format_redraw (emf);
+ em_format_queue_redraw (emf);
}
/**
@@ -938,7 +970,7 @@ em_format_set_charset (EMFormat *emf,
emf->charset = g_strdup(charset);
if (emf->message)
- em_format_redraw(emf);
+ em_format_queue_redraw(emf);
}
/**
@@ -963,7 +995,7 @@ em_format_set_default_charset (EMFormat *emf,
emf->default_charset = g_strdup(charset);
if (emf->message && emf->charset == NULL)
- em_format_redraw(emf);
+ em_format_queue_redraw (emf);
}
/**
@@ -1143,7 +1175,7 @@ em_format_set_inline (EMFormat *emf,
emfc->state = state?INLINE_ON:INLINE_OFF;
if (emf->message)
- em_format_redraw(emf);
+ em_format_queue_redraw (emf);
}
void
diff --git a/em-format/em-format.h b/em-format/em-format.h
index ec805e7cd8..ebe9e840b9 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -186,7 +186,6 @@ struct _EMFormatHeader {
**/
struct _EMFormat {
GObject parent;
-
EMFormatPrivate *priv;
CamelMimeMessage *message; /* the current message */
@@ -359,7 +358,7 @@ void em_format_format (EMFormat *emf,
CamelFolder *folder,
const gchar *uid,
CamelMimeMessage *message);
-void em_format_redraw (EMFormat *emf);
+void em_format_queue_redraw (EMFormat *emf);
void em_format_format_attachment (EMFormat *emf,
CamelStream *stream,
CamelMimePart *mime_part,
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 86cc929182..9d4fdf95ba 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -618,7 +618,7 @@ mail_browser_constructed (GObject *object)
g_signal_connect_swapped (
search_bar, "changed",
- G_CALLBACK (em_format_redraw), priv->formatter);
+ G_CALLBACK (em_format_queue_redraw), priv->formatter);
/* Bind GObject properties to GConf keys. */
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index fda1f3a034..58f4824799 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -204,7 +204,7 @@ mail_display_style_set (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
mail_display_update_formatter_colors (E_MAIL_DISPLAY (widget));
- em_format_redraw (EM_FORMAT (priv->formatter));
+ em_format_queue_redraw (EM_FORMAT (priv->formatter));
}
static void
@@ -264,7 +264,7 @@ mail_display_link_clicked (GtkHTML *html,
}
priv->formatter->header_wrap_flags = flags;
- em_format_redraw (EM_FORMAT (priv->formatter));
+ em_format_queue_redraw (EM_FORMAT (priv->formatter));
} else if (*uri == '#')
gtk_html_jump_to_anchor (html, uri + 1);
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 106e761492..2195f8740f 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -592,7 +592,7 @@ mail_paned_view_constructed (GObject *object)
g_signal_connect_swapped (
search_bar, "changed",
- G_CALLBACK (em_format_redraw), priv->formatter);
+ G_CALLBACK (em_format_queue_redraw), priv->formatter);
/* Load the view instance. */
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 7d8be346bc..bdef954709 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -720,7 +720,7 @@ headers_changed_cb (GConfClient *client,
/* force a redraw */
if (EM_FORMAT (formatter)->message)
- em_format_redraw (EM_FORMAT (formatter));
+ em_format_queue_redraw (EM_FORMAT (formatter));
}
static void
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 3675b5209b..63cbba1cf5 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -377,7 +377,7 @@ action_mail_flag_clear_cb (GtkAction *action,
em_utils_flag_for_followup_clear (window, folder, uids);
- em_format_redraw (EM_FORMAT (formatter));
+ em_format_queue_redraw (EM_FORMAT (formatter));
}
static void
@@ -396,7 +396,7 @@ action_mail_flag_completed_cb (GtkAction *action,
em_utils_flag_for_followup_completed (window, folder, uids);
- em_format_redraw (EM_FORMAT (formatter));
+ em_format_queue_redraw (EM_FORMAT (formatter));
}
static void
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 5818ad2a35..d8f4869577 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -980,7 +980,7 @@ efh_init (EMFormatHTML *efh,
g_signal_connect_swapped (
efh, "notify::mark-citations",
- G_CALLBACK (em_format_redraw), NULL);
+ G_CALLBACK (em_format_queue_redraw), NULL);
e_extensible_load_extensions (E_EXTENSIBLE (efh));
}
@@ -1040,7 +1040,7 @@ em_format_html_load_images (EMFormatHTML *efh)
/* This will remain set while we're still
* rendering the same message, then it wont be. */
efh->priv->load_images_now = TRUE;
- em_format_redraw (EM_FORMAT (efh));
+ em_format_queue_redraw (EM_FORMAT (efh));
}
void
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 2bc0143eb3..fe7c248d0e 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -455,7 +455,7 @@ em_utils_flag_for_followup (EMailReader *reader,
camel_tag_list_free (&tags);
formatter = e_mail_reader_get_formatter (reader);
- em_format_redraw (EM_FORMAT (formatter));
+ em_format_queue_redraw (EM_FORMAT (formatter));
exit:
/* XXX We shouldn't be freeing this. */