mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 02:32:11 +01:00
Some more work-in-progress
This commit is contained in:
parent
d70501d865
commit
0175222353
@ -154,17 +154,24 @@ on_source_notify (GObject *gobject,
|
||||
GValue *to_values;
|
||||
gboolean res;
|
||||
gint i;
|
||||
gint notified;
|
||||
|
||||
if (binding->is_frozen)
|
||||
return;
|
||||
|
||||
notified = -1;
|
||||
from_values = g_new0 (GValue, binding->n_sources);
|
||||
for (i = 0; i < binding->n_sources; i++)
|
||||
{
|
||||
g_value_init (&from_values[i], G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec[i]));
|
||||
g_object_get_property (binding->source[i], binding->source_pspec[i]->name, &from_values[i]);
|
||||
|
||||
if (gobject == binding->source[i])
|
||||
notified = i;
|
||||
}
|
||||
|
||||
g_assert (0 <= notified && notified < binding->n_sources);
|
||||
|
||||
to_values = g_new0 (GValue, binding->n_targets);
|
||||
for (i = 0; i < binding->n_targets; i++)
|
||||
{
|
||||
@ -172,7 +179,7 @@ on_source_notify (GObject *gobject,
|
||||
g_object_get_property (binding->target[i], binding->target_pspec[i]->name, &to_values[i]);
|
||||
}
|
||||
|
||||
res = binding->transform (binding, (const GValue *)from_values, to_values, binding->transform_data);
|
||||
res = binding->transform (binding, notified, (const GValue *)from_values, to_values, binding->transform_data);
|
||||
|
||||
if (res)
|
||||
{
|
||||
@ -339,6 +346,7 @@ g_object_multi_bind_property_v (gint n_sources,
|
||||
gint n_targets,
|
||||
GObject *targets[],
|
||||
const gchar *target_properties[],
|
||||
GMultiBindingFlags flags,
|
||||
GMultiBindingTransformFunc transform,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
@ -443,5 +451,8 @@ g_object_multi_bind_property_v (gint n_sources,
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & G_MULTI_BINDING_SYNC_CREATE)
|
||||
on_source_notify (binding->source[0], binding->source_pspec[0], binding);
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
@ -34,6 +34,11 @@ G_BEGIN_DECLS
|
||||
#define G_MULTI_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_MULTI_BINDING, GMultiBinding))
|
||||
#define G_IS_MULTI_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_MULTI_BINDING))
|
||||
|
||||
typedef enum { /*< prefix=G_MULTI_BINDING >*/
|
||||
G_MULTI_BINDING_DEFAULT = 0,
|
||||
G_MULTI_BINDING_SYNC_CREATE = 1 << 1
|
||||
} GMultiBindingFlags;
|
||||
|
||||
/**
|
||||
* GMultiBinding:
|
||||
*
|
||||
@ -45,6 +50,7 @@ G_BEGIN_DECLS
|
||||
typedef struct _GMultiBinding GMultiBinding;
|
||||
|
||||
typedef gboolean (* GMultiBindingTransformFunc) (GMultiBinding *binding,
|
||||
gint notified,
|
||||
const GValue from_values[],
|
||||
GValue to_values[],
|
||||
gpointer user_data);
|
||||
@ -74,15 +80,26 @@ GLIB_AVAILABLE_IN_ALL
|
||||
void g_multi_binding_unbind (GMultiBinding *binding);
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GMultiBinding *g_object_multi_bind_property_v (gint n_sources,
|
||||
GMultiBinding *g_object_bind_properties_v (gint n_sources,
|
||||
GObject *sources[],
|
||||
const gchar *source_properties[],
|
||||
gint n_targets,
|
||||
GObject *targets[],
|
||||
const gchar *target_properties[],
|
||||
GMultiBindingFlags flags,
|
||||
GMultiBindingTransformFunc transform,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GMultiBinding *g_object_bind_properties (GObject *source,
|
||||
const gchar *property,
|
||||
...
|
||||
GObject *target,
|
||||
const gchar *property,
|
||||
...
|
||||
GMultiBindingFlags flags,
|
||||
GMultiBindingTransformFunc transform,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
|
||||
#endif /* __G_MULTI_BINDING_H__ */
|
||||
|
@ -237,6 +237,7 @@ binding_target_init (BindingTarget *self)
|
||||
|
||||
static gboolean
|
||||
munge_two_ints (GMultiBinding *binding,
|
||||
gint notified,
|
||||
const GValue from_values[],
|
||||
GValue to_values[],
|
||||
gpointer user_data)
|
||||
@ -273,6 +274,7 @@ multibinding_basic (void)
|
||||
target_props[1] = "bar";
|
||||
binding = g_object_multi_bind_property_v (2, sources, source_props,
|
||||
2, targets, target_props,
|
||||
G_MULTI_BINDING_DEFAULT,
|
||||
munge_two_ints,
|
||||
NULL, NULL);
|
||||
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
|
||||
|
Loading…
x
Reference in New Issue
Block a user