[evolution-data-server] CamelSession: Add camel_session_idle_add().



commit 4d04afeab15da246a79348fc45ab3fde78d537fa
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 19 09:08:11 2012 -0400

    CamelSession: Add camel_session_idle_add().
    
    Schedules an idle callback on CamelSession's GMainContext.

 camel/camel-session.c                   |   53 +++++++++++++++++++++++++++++++
 camel/camel-session.h                   |    5 +++
 docs/reference/camel/camel-sections.txt |    1 +
 3 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-session.c b/camel/camel-session.c
index d45994f..57d060a 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -1361,6 +1361,59 @@ camel_session_set_junk_filter (CamelSession *session,
 }
 
 /**
+ * camel_session_idle_add:
+ * @session: a #CamelSession
+ * @priority: the priority of the idle source
+ * @function: a function to call
+ * @data: data to pass to @function
+ * @notify: function to call when the idle is removed, or %NULL
+ *
+ * Adds a function to be called whenever there are no higher priority events
+ * pending.  If @function returns %FALSE it is automatically removed from the
+ * list of event sources and will not be called again.
+ *
+ * This internally creates a main loop source using g_idle_source_new()
+ * and attaches it to @session's own #CamelSession:main-context using
+ * g_source_attach().
+ *
+ * The @priority is typically in the range between %G_PRIORITY_DEFAULT_IDLE
+ * and %G_PRIORITY_HIGH_IDLE.
+ *
+ * Returns: the ID (greater than 0) of the event source
+ *
+ * Since: 3.6
+ **/
+guint
+camel_session_idle_add (CamelSession *session,
+                        gint priority,
+                        GSourceFunc function,
+                        gpointer data,
+                        GDestroyNotify notify)
+{
+	GMainContext *main_context;
+	GSource *source;
+	guint source_id;
+
+	g_return_val_if_fail (CAMEL_IS_SESSION (session), 0);
+	g_return_val_if_fail (function != NULL, 0);
+
+	main_context = camel_session_get_main_context (session);
+
+	source = g_idle_source_new ();
+
+	if (priority != G_PRIORITY_DEFAULT_IDLE)
+		g_source_set_priority (source, priority);
+
+	g_source_set_callback (source, function, data, notify);
+
+	source_id = g_source_attach (source, main_context);
+
+	g_source_unref (source);
+
+	return source_id;
+}
+
+/**
  * camel_session_submit_job:
  * @session: a #CamelSession
  * @callback: a #CamelSessionCallback
diff --git a/camel/camel-session.h b/camel/camel-session.h
index b03ec78..776fd6a 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -225,6 +225,11 @@ void		camel_session_set_junk_filter	(CamelSession *session,
 gboolean	camel_session_get_check_junk	(CamelSession *session);
 void		camel_session_set_check_junk	(CamelSession *session,
 						 gboolean check_junk);
+guint		camel_session_idle_add		(CamelSession *session,
+						 gint priority,
+						 GSourceFunc function,
+						 gpointer data,
+						 GDestroyNotify notify);
 void		camel_session_submit_job	(CamelSession *session,
 						 CamelSessionCallback callback,
 						 gpointer user_data,
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index e7afd25..4e9c4b0 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -2026,6 +2026,7 @@ camel_session_get_check_junk
 camel_session_set_check_junk
 camel_session_get_junk_filter
 camel_session_set_junk_filter
+camel_session_idle_add
 CamelSessionCallback
 camel_session_submit_job
 camel_session_get_network_available



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