Add macros for GSourceFunc return values
authorEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 5 Oct 2010 13:01:05 +0000 (14:01 +0100)
committerRyan Lortie <desrt@desrt.ca>
Sat, 10 Sep 2011 02:08:58 +0000 (22:08 -0400)
The boolean values to be returned by a GSourceFunc are always ambiguous,
and even in case of experienced developers then can lead to confusion.

The Perl bindings for GLib have two simple constants, mapping to TRUE
and FALSE, that make the return values less confusing: G_SOURCE_CONTINUE
and G_SOURCE_REMOVE respectively.

https://bugzilla.gnome.org/show_bug.cgi?id=631413

docs/reference/glib/glib-sections.txt
glib/gmain.h

index 069270c..13f3526 100644 (file)
@@ -447,6 +447,10 @@ G_PRIORITY_DEFAULT_IDLE
 G_PRIORITY_LOW
 
 <SUBSECTION>
+G_SOURCE_CONTINUE
+G_SOURCE_REMOVE
+
+<SUBSECTION>
 GMainContext
 g_main_context_new
 g_main_context_ref
index e6336b8..80895e2 100644 (file)
@@ -258,6 +258,26 @@ struct _GSourceFuncs
  */
 #define G_PRIORITY_LOW              300
 
+/**
+ * G_SOURCE_REMOVE:
+ *
+ * Use this macro as the return value of a #GSourceFunc to remove
+ * the #GSource from the main loop.
+ *
+ * Since: 2.28
+ */
+#define G_SOURCE_REMOVE         FALSE
+
+/**
+ * G_SOURCE_CONTINUE:
+ *
+ * Use this macro as the return value of a #GSourceFunc to leave
+ * the #GSource in the main loop.
+ *
+ * Since: 2.28
+ */
+#define G_SOURCE_CONTINUE       TRUE
+
 /* GMainContext: */
 
 GMainContext *g_main_context_new       (void);