aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
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 /em-format
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.
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format.c46
-rw-r--r--em-format/em-format.h3
2 files changed, 40 insertions, 9 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,