[glib: 1/3] Add g_main_context_new_with_flags()




commit 7ba86be594fe5733c7a3df031d94c1e37765ff88
Author: Vinícius dos Santos Oliveira <vini ipsmaker gmail com>
Date:   Mon Apr 12 19:16:14 2021 -0300

    Add g_main_context_new_with_flags()
    
    This constructor is useful to set options that can't change after
    creation.

 docs/reference/glib/glib-sections.txt |  2 ++
 glib/gmain.c                          | 19 +++++++++++++++++++
 glib/gmain.h                          | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index eff14e1ea..35b58cfb0 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -841,7 +841,9 @@ G_SOURCE_REMOVE
 
 <SUBSECTION>
 GMainContext
+GMainContextFlags
 g_main_context_new
+g_main_context_new_with_flags
 g_main_context_ref
 g_main_context_unref
 g_main_context_default
diff --git a/glib/gmain.c b/glib/gmain.c
index ba8e0b08c..69fca6260 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -270,6 +270,7 @@ struct _GMainContext
   GCond cond;
   GThread *owner;
   guint owner_count;
+  GMainContextFlags flags;
   GSList *waiters;
 
   gint ref_count;  /* (atomic) */
@@ -658,6 +659,23 @@ g_main_context_new_with_next_id (guint next_id)
  **/
 GMainContext *
 g_main_context_new (void)
+{
+  return g_main_context_new_with_flags (G_MAIN_CONTEXT_FLAGS_NONE);
+}
+
+/**
+ * g_main_context_new_with_flags:
+ * @flags: a bitwise-OR combination of #GMainContextFlags flags that can only be
+ *         set at creation time.
+ *
+ * Creates a new #GMainContext structure.
+ *
+ * Returns: (transfer full): the new #GMainContext
+ *
+ * Since: 2.72
+ */
+GMainContext *
+g_main_context_new_with_flags (GMainContextFlags flags)
 {
   static gsize initialised;
   GMainContext *context;
@@ -681,6 +699,7 @@ g_main_context_new (void)
 
   context->sources = g_hash_table_new (NULL, NULL);
   context->owner = NULL;
+  context->flags = flags;
   context->waiters = NULL;
 
   context->ref_count = 1;
diff --git a/glib/gmain.h b/glib/gmain.h
index 8e15f3da4..8e7d77290 100644
--- a/glib/gmain.h
+++ b/glib/gmain.h
@@ -38,6 +38,21 @@ typedef enum /*< flags >*/
   G_IO_NVAL    GLIB_SYSDEF_POLLNVAL
 } GIOCondition;
 
+/**
+ * GMainContextFlags:
+ * @G_MAIN_CONTEXT_FLAGS_NONE: Default behaviour.
+ *
+ * Flags to pass to g_main_context_new_with_flags() which affect the behaviour
+ * of a #GMainContext.
+ *
+ * Since: 2.72
+ */
+GLIB_AVAILABLE_TYPE_IN_2_72
+typedef enum /*< flags >*/
+{
+  G_MAIN_CONTEXT_FLAGS_NONE = 0,
+} GMainContextFlags;
+
 
 /**
  * GMainContext:
@@ -358,6 +373,10 @@ struct _GSourceFuncs
 
 GLIB_AVAILABLE_IN_ALL
 GMainContext *g_main_context_new       (void);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+GLIB_AVAILABLE_IN_2_72
+GMainContext *g_main_context_new_with_flags (GMainContextFlags flags);
+G_GNUC_END_IGNORE_DEPRECATIONS
 GLIB_AVAILABLE_IN_ALL
 GMainContext *g_main_context_ref       (GMainContext *context);
 GLIB_AVAILABLE_IN_ALL


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