From c467b293c8b8c450f1cd8384a55dc989063f16f9 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 8 Jun 2005 05:02:16 +0000 Subject: make this run a timeout so we don't update too often and suck loads of cpu 2005-06-08 Not Zed * mail-component.c (view_changed_cb): make this run a timeout so we don't update too often and suck loads of cpu time. svn path=/trunk/; revision=29471 --- mail/ChangeLog | 5 +++++ mail/mail-component.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 4c1fea8bc1..48845ae2ad 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2005-06-08 Not Zed + + * mail-component.c (view_changed_cb): make this run a timeout so + we don't update too often and suck loads of cpu time. + 2005-06-07 Andre Klapper <9016009@gmx.de> * mail.error.xml: Fixing typo (bug 306151) diff --git a/mail/mail-component.c b/mail/mail-component.c index e6d77bba9d..a63fe06ff3 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -487,7 +487,7 @@ view_on_url (GObject *emitter, const char *url, const char *nice_url, MailCompon } static void -view_changed_cb(EMFolderView *emfv, EInfoLabel *el) +view_changed(EMFolderView *emfv, EInfoLabel *el) { if (emfv->folder) { char *name; @@ -559,6 +559,42 @@ view_changed_cb(EMFolderView *emfv, EInfoLabel *el) } } +static int +view_changed_timeout(void *d) +{ + EInfoLabel *el = d; + EMFolderView *emfv = g_object_get_data((GObject *)el, "folderview"); + + view_changed(emfv, el); + + g_object_set_data((GObject *)emfv, "view-changed-timeout", NULL); + + g_object_unref(el); + g_object_unref(emfv); + + return 0; +} + +static void +view_changed_cb(EMFolderView *emfv, EInfoLabel *el) +{ + void *v; + + /* This can get called 3 times every cursor move, so + we don't need to/want to run it immediately */ + + /* NB: we should have a 'view' struct/object to manage this crap, but this'll do for now */ + v = g_object_get_data((GObject *)emfv, "view-changed-timeout"); + if (v) { + g_source_remove(GPOINTER_TO_INT(v)); + } else { + g_object_ref(emfv); + g_object_ref(el); + } + + g_object_set_data((GObject *)emfv, "view-changed-timeout", GINT_TO_POINTER(g_timeout_add(250, view_changed_timeout, el))); +} + /* Evolution::Component CORBA methods. */ static void @@ -630,6 +666,8 @@ impl_createControls (PortableServer_Servant servant, g_signal_connect(view_widget, "changed", G_CALLBACK(view_changed_cb), info); g_signal_connect(view_widget, "loaded", G_CALLBACK(view_changed_cb), info); + + g_object_set_data((GObject*)info, "folderview", view_widget); } static CORBA_boolean -- cgit v1.2.3