mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
Add g_main_context_new_with_flags()
This constructor is useful to set options that can't change after creation.
This commit is contained in:
parent
6fcad9d288
commit
7ba86be594
@ -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
|
||||
|
19
glib/gmain.c
19
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;
|
||||
|
19
glib/gmain.h
19
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
|
||||
|
Loading…
Reference in New Issue
Block a user