mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-18 03:12:52 +02:00
Add g_source_set_static_name_by_id
After adding g_source_set_static_name, I realized that the majority of GSources in the GTK sources still rely on g_source_set_name_by_id, and open-coding this in a million places is no fun.
This commit is contained in:
@@ -918,6 +918,7 @@ g_source_get_name
|
||||
g_source_set_name
|
||||
g_source_set_static_name
|
||||
g_source_set_name_by_id
|
||||
g_source_set_static_name_by_id
|
||||
g_source_get_context
|
||||
g_source_set_callback
|
||||
GSourceFunc
|
||||
|
45
glib/gmain.c
45
glib/gmain.c
@@ -2097,6 +2097,22 @@ g_source_set_name_full (GSource *source,
|
||||
UNLOCK_CONTEXT (context);
|
||||
}
|
||||
|
||||
static void
|
||||
g_source_set_name_by_id_full (guint tag,
|
||||
const char *name,
|
||||
gboolean is_static)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
g_return_if_fail (tag > 0);
|
||||
|
||||
source = g_main_context_find_source_by_id (NULL, tag);
|
||||
if (source == NULL)
|
||||
return;
|
||||
|
||||
g_source_set_name_full (source, name, is_static);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_source_set_name:
|
||||
* @source: a #GSource
|
||||
@@ -2190,23 +2206,34 @@ g_source_get_name (GSource *source)
|
||||
* been reissued, leading to the operation being performed against the
|
||||
* wrong source.
|
||||
*
|
||||
* Also see g_source_set_static_name_by_id().
|
||||
*
|
||||
* Since: 2.26
|
||||
**/
|
||||
void
|
||||
g_source_set_name_by_id (guint tag,
|
||||
const char *name)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
g_return_if_fail (tag > 0);
|
||||
|
||||
source = g_main_context_find_source_by_id (NULL, tag);
|
||||
if (source == NULL)
|
||||
return;
|
||||
|
||||
g_source_set_name (source, name);
|
||||
g_source_set_name_by_id_full (tag, name, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_source_set_static_name_by_id:
|
||||
* @tag: a #GSource ID
|
||||
* @name: debug name for the source
|
||||
*
|
||||
* A variant of g_source_set_name_by_id() that does not
|
||||
* duplicate the @name, and can only be used with
|
||||
* string literals.
|
||||
*
|
||||
* Since: 2.70
|
||||
*/
|
||||
void
|
||||
g_source_set_static_name_by_id (guint tag,
|
||||
const char *name)
|
||||
{
|
||||
g_source_set_name_by_id_full (tag, name, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_source_ref:
|
||||
|
@@ -613,6 +613,9 @@ const char * g_source_get_name (GSource *source);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
void g_source_set_name_by_id (guint tag,
|
||||
const char *name);
|
||||
GLIB_AVAILABLE_IN_2_70
|
||||
void g_source_set_static_name_by_id (guint tag,
|
||||
const char *name);
|
||||
|
||||
GLIB_AVAILABLE_IN_2_36
|
||||
void g_source_set_ready_time (GSource *source,
|
||||
|
Reference in New Issue
Block a user