[glib/wip/chergert/add-gbindinggroup] incremental patch to apply from web
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/chergert/add-gbindinggroup] incremental patch to apply from web
- Date: Fri, 28 Jan 2022 01:27:42 +0000 (UTC)
commit 5beb5c22c395f9fecddee1221121ad488d33b4f3
Author: Philip Withnall <philip tecnocode co uk>
Date: Fri Jan 28 01:27:41 2022 +0000
incremental patch to apply from web
gobject/gbindinggroup.c | 64 ++++++++++++++++++++++----------------------
gobject/gsignalgroup.c | 39 +++++++++++++--------------
gobject/gsignalgroup.h | 2 +-
gobject/tests/bindinggroup.c | 8 ++----
gobject/tests/signalgroup.c | 4 +--
5 files changed, 56 insertions(+), 61 deletions(-)
---
diff --git a/gobject/gbindinggroup.c b/gobject/gbindinggroup.c
index 9e4a0689e..38e31f29c 100644
--- a/gobject/gbindinggroup.c
+++ b/gobject/gbindinggroup.c
@@ -37,7 +37,7 @@
*
* Use the various methods to bind properties from a single source
* object to multiple destination objects. Properties can be bound
- * bidrectionally and are connected when the source object is set
+ * bidirectionally and are connected when the source object is set
* with g_binding_group_set_source().
*
* Since: 2.72
@@ -50,8 +50,8 @@
struct _GBindingGroup
{
GObject parent_instance;
- GObject *source;
- GPtrArray *lazy_bindings;
+ GObject *source; /* (owned weak) */
+ GPtrArray *lazy_bindings; /* (owned) (element-type LazyBinding) */
};
typedef struct _GBindingGroupClass
@@ -61,29 +61,28 @@ typedef struct _GBindingGroupClass
typedef struct
{
- GBindingGroup *group;
- const char *source_property;
- const char *target_property;
- GObject *target;
- GBinding *binding;
+ GBindingGroup *group; /* (unowned) */
+ const char *source_property; /* (interned) */
+ const char *target_property; /* (interned) */
+ GObject *target; /* (owned weak) */
+ GBinding *binding; /* (unowned) */
gpointer user_data;
GDestroyNotify user_data_destroy;
- gpointer transform_to;
- gpointer transform_from;
+ gpointer transform_to; /* (nullable) (owned) */
+ gpointer transform_from; /* (nullable) (owned) */
GBindingFlags binding_flags;
guint using_closures : 1;
} LazyBinding;
G_DEFINE_TYPE (GBindingGroup, g_binding_group, G_TYPE_OBJECT)
-enum
+typedef enum
{
- PROP_0,
- PROP_SOURCE,
+ PROP_SOURCE = 1,
N_PROPS
-};
+} GBindingGroupProperty;
-static GParamSpec *properties [N_PROPS];
+static GParamSpec *properties[N_PROPS];
static void
g_binding_group_connect (GBindingGroup *self,
@@ -273,7 +272,7 @@ g_binding_group_get_property (GObject *object,
{
GBindingGroup *self = G_BINDING_GROUP (object);
- switch (prop_id)
+ switch ((GBindingGroupProperty) prop_id)
{
case PROP_SOURCE:
g_value_set_object (value, g_binding_group_get_source (self));
@@ -292,7 +291,7 @@ g_binding_group_set_property (GObject *object,
{
GBindingGroup *self = G_BINDING_GROUP (object);
- switch (prop_id)
+ switch ((GBindingGroupProperty) prop_id)
{
case PROP_SOURCE:
g_binding_group_set_source (self, g_value_get_object (value));
@@ -314,13 +313,13 @@ g_binding_group_class_init (GBindingGroupClass *klass)
object_class->set_property = g_binding_group_set_property;
/**
- * GBindingGroup:source:
+ * GBindingGroup:source: (nullable)
*
* The source object used for binding properties.
*
* Since: 2.72
*/
- properties [PROP_SOURCE] =
+ properties[PROP_SOURCE] =
g_param_spec_object ("source",
"Source",
"The source GObject used for binding properties.",
@@ -341,7 +340,7 @@ g_binding_group_init (GBindingGroup *self)
*
* Creates a new #GBindingGroup.
*
- * Returns: a new #GBindingGroup
+ * Returns: (transfer full): a new #GBindingGroup
*
* Since: 2.72
*/
@@ -390,7 +389,8 @@ g_binding_group_check_source (GBindingGroup *self,
/**
* g_binding_group_set_source:
* @self: the #GBindingGroup
- * @source: (type GObject) (nullable): the source #GObject
+ * @source: (type GObject) (nullable) (transfer none): the source #GObject,
+ * or %NULL to clear it
*
* Sets @source as the source object used for creating property
* bindings. If there is already a source object all bindings from it
@@ -447,7 +447,7 @@ g_binding_group_set_source (GBindingGroup *self,
}
}
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SOURCE]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SOURCE]);
}
static void
@@ -512,14 +512,14 @@ g_binding_group_bind_helper (GBindingGroup *self,
* g_binding_group_bind:
* @self: the #GBindingGroup
* @source_property: the property on the source to bind
- * @target: (type GObject): the target #GObject
+ * @target: (type GObject) (transfer none) (not nullable): the target #GObject
* @target_property: the property on @target to bind
* @flags: the flags used to create the #GBinding
*
* Creates a binding between @source_property on the source object
* and @target_property on @target. Whenever the @source_property
* is changed the @target_property is updated using the same value.
- * The binding flags #G_BINDING_SYNC_CREATE is automatically specified.
+ * The binding flag %G_BINDING_SYNC_CREATE is automatically specified.
*
* See g_object_bind_property() for more information.
*
@@ -543,7 +543,7 @@ g_binding_group_bind (GBindingGroup *self,
* g_binding_group_bind_full:
* @self: the #GBindingGroup
* @source_property: the property on the source to bind
- * @target: (type GObject): the target #GObject
+ * @target: (type GObject) (transfer none) (not nullable): the target #GObject
* @target_property: the property on @target to bind
* @flags: the flags used to create the #GBinding
* @transform_to: (scope notified) (nullable): the transformation function
@@ -557,8 +557,8 @@ g_binding_group_bind (GBindingGroup *self,
*
* Creates a binding between @source_property on the source object and
* @target_property on @target, allowing you to set the transformation
- * functions to be used by the binding. The binding flags
- * #G_BINDING_SYNC_CREATE is automatically specified.
+ * functions to be used by the binding. The binding flag
+ * %G_BINDING_SYNC_CREATE is automatically specified.
*
* See g_object_bind_property_full() for more information.
*
@@ -587,20 +587,20 @@ g_binding_group_bind_full (GBindingGroup *self,
* g_binding_group_bind_with_closures: (rename-to g_binding_group_bind_full)
* @self: the #GBindingGroup
* @source_property: the property on the source to bind
- * @target: (type GObject): the target #GObject
+ * @target: (type GObject) (transfer none) (not nullable): the target #GObject
* @target_property: the property on @target to bind
* @flags: the flags used to create the #GBinding
- * @transform_to: (nullable): a #GClosure wrapping the
+ * @transform_to: (nullable) (transfer none): a #GClosure wrapping the
* transformation function from the source object to the @target,
* or %NULL to use the default
- * @transform_from: (nullable): a #GClosure wrapping the
+ * @transform_from: (nullable) (transfer none): a #GClosure wrapping the
* transformation function from the @target to the source object,
* or %NULL to use the default
*
* Creates a binding between @source_property on the source object and
* @target_property on @target, allowing you to set the transformation
- * functions to be used by the binding. The binding flags
- * #G_BINDING_SYNC_CREATE is automatically specified.
+ * functions to be used by the binding. The binding flag
+ * %G_BINDING_SYNC_CREATE is automatically specified.
*
* This function is the language bindings friendly version of
* g_binding_group_bind_property_full(), using #GClosures
diff --git a/gobject/gsignalgroup.c b/gobject/gsignalgroup.c
index 2be9fd032..fde8d4fe4 100644
--- a/gobject/gsignalgroup.c
+++ b/gobject/gsignalgroup.c
@@ -86,13 +86,12 @@ typedef struct
G_DEFINE_TYPE (GSignalGroup, g_signal_group, G_TYPE_OBJECT)
-enum
+typedef enum
{
- PROP_0,
- PROP_TARGET,
+ PROP_TARGET = 1,
PROP_TARGET_TYPE,
LAST_PROP
-};
+} GSignalGroupProperty;
enum
{
@@ -101,8 +100,8 @@ enum
LAST_SIGNAL
};
-static GParamSpec *properties [LAST_PROP];
-static guint signals [LAST_SIGNAL];
+static GParamSpec *properties[LAST_PROP];
+static guint signals[LAST_SIGNAL];
static void
g_signal_group_set_target_type (GSignalGroup *self,
@@ -169,8 +168,8 @@ g_signal_group__target_weak_notify (gpointer data,
handler->handler_id = 0;
}
- g_signal_emit (self, signals [UNBIND], 0);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TARGET]);
+ g_signal_emit (self, signals[UNBIND], 0);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TARGET]);
}
static void
@@ -430,7 +429,7 @@ g_signal_group_get_target (GSignalGroup *self)
/**
* g_signal_group_set_target:
* @self: the #GSignalGroup.
- * @target: (nullable) (type GObject): The target instance used
+ * @target: (nullable) (type GObject) (transfer none): The target instance used
* when connecting signals.
*
* Sets the target instance used when connecting signals. Any signal
@@ -464,7 +463,7 @@ g_signal_group_set_target (GSignalGroup *self,
g_signal_group_bind (self, target);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TARGET]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TARGET]);
unref:
g_clear_object (&object);
@@ -532,7 +531,7 @@ g_signal_group_get_property (GObject *object,
{
GSignalGroup *self = G_SIGNAL_GROUP (object);
- switch (prop_id)
+ switch ((GSignalGroupProperty) prop_id)
{
case PROP_TARGET:
g_value_take_object (value, g_weak_ref_get (&self->target_ref));
@@ -555,7 +554,7 @@ g_signal_group_set_property (GObject *object,
{
GSignalGroup *self = G_SIGNAL_GROUP (object);
- switch (prop_id)
+ switch ((GSignalGroupProperty) prop_id)
{
case PROP_TARGET:
g_signal_group_set_target (self, g_value_get_object (value));
@@ -588,7 +587,7 @@ g_signal_group_class_init (GSignalGroupClass *klass)
*
* Since: 2.72
*/
- properties [PROP_TARGET] =
+ properties[PROP_TARGET] =
g_param_spec_object ("target",
"Target",
"The target instance used when connecting signals.",
@@ -598,11 +597,11 @@ g_signal_group_class_init (GSignalGroupClass *klass)
/**
* GSignalGroup:target-type
*
- * The GType of the target property.
+ * The #GType of the target property.
*
* Since: 2.72
*/
- properties [PROP_TARGET_TYPE] =
+ properties[PROP_TARGET_TYPE] =
g_param_spec_gtype ("target-type",
"Target Type",
"The GType of the target property.",
@@ -623,7 +622,7 @@ g_signal_group_class_init (GSignalGroupClass *klass)
*
* Since: 2.72
*/
- signals [BIND] =
+ signals[BIND] =
g_signal_new ("bind",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -645,7 +644,7 @@ g_signal_group_class_init (GSignalGroupClass *klass)
*
* Since: 2.72
*/
- signals [UNBIND] =
+ signals[UNBIND] =
g_signal_new ("unbind",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -668,7 +667,7 @@ g_signal_group_init (GSignalGroup *self)
*
* Creates a new #GSignalGroup for target instances of @target_type.
*
- * Returns: a new #GSignalGroup
+ * Returns: (transfer full): a new #GSignalGroup
*
* Since: 2.72
*/
@@ -744,9 +743,9 @@ g_signal_group_connect_full (GSignalGroup *self,
/**
* g_signal_group_connect_object: (skip)
* @self: a #GSignalGroup
- * @detailed_signal: a string of the form "signal-name::detail"
+ * @detailed_signal: a string of the form `signal-name::detail`
* @c_handler: (scope notified): the #GCallback to connect
- * @object: the #GObject to pass as data to @callback calls
+ * @object: (not nullable) (transfer none): the #GObject to pass as data to @callback calls
* @flags: #GConnectFlags for the signal connection
*
* Connects @callback to the signal @detailed_signal
diff --git a/gobject/gsignalgroup.h b/gobject/gsignalgroup.h
index cd988f64a..96a7c2ece 100644
--- a/gobject/gsignalgroup.h
+++ b/gobject/gsignalgroup.h
@@ -39,7 +39,7 @@ G_BEGIN_DECLS
/**
* GSignalGroup:
*
- * GSignalGroup is an opaque structure whose members
+ * #GSignalGroup is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 2.72
diff --git a/gobject/tests/bindinggroup.c b/gobject/tests/bindinggroup.c
index a143f611c..31ee5938b 100644
--- a/gobject/tests/bindinggroup.c
+++ b/gobject/tests/bindinggroup.c
@@ -18,9 +18,7 @@ typedef struct _BindingSourceClass
enum
{
- PROP_SOURCE_0,
-
- PROP_SOURCE_FOO,
+ PROP_SOURCE_FOO = 1,
PROP_SOURCE_BAR,
PROP_SOURCE_VALUE,
PROP_SOURCE_TOGGLE
@@ -141,9 +139,7 @@ typedef struct _BindingTargetClass
enum
{
- PROP_TARGET_0,
-
- PROP_TARGET_BAR,
+ PROP_TARGET_BAR = 1,
PROP_TARGET_VALUE,
PROP_TARGET_TOGGLE
};
diff --git a/gobject/tests/signalgroup.c b/gobject/tests/signalgroup.c
index 49348222c..fb9fc8be3 100644
--- a/gobject/tests/signalgroup.c
+++ b/gobject/tests/signalgroup.c
@@ -17,7 +17,7 @@ enum {
LAST_SIGNAL
};
-static guint signals [LAST_SIGNAL];
+static guint signals[LAST_SIGNAL];
static void
signal_target_class_init (SignalTargetClass *klass)
@@ -274,7 +274,7 @@ test_signal_group_simple (void)
/* Set the target before connecting the signals */
g_assert_null (g_signal_group_get_target (group));
g_signal_group_set_target (group, target);
- g_assert (g_signal_group_get_target (group) == (GObject *)target);
+ g_assert_true (g_signal_group_get_target (group) == (GObject *)target);
connect_all_signals (group);
assert_signals (target, group, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]