mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +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;
|
GValue *to_values;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
gint i;
|
gint i;
|
||||||
|
gint notified;
|
||||||
|
|
||||||
if (binding->is_frozen)
|
if (binding->is_frozen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
notified = -1;
|
||||||
from_values = g_new0 (GValue, binding->n_sources);
|
from_values = g_new0 (GValue, binding->n_sources);
|
||||||
for (i = 0; i < binding->n_sources; i++)
|
for (i = 0; i < binding->n_sources; i++)
|
||||||
{
|
{
|
||||||
g_value_init (&from_values[i], G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec[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]);
|
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);
|
to_values = g_new0 (GValue, binding->n_targets);
|
||||||
for (i = 0; i < binding->n_targets; i++)
|
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]);
|
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)
|
if (res)
|
||||||
{
|
{
|
||||||
@ -339,6 +346,7 @@ g_object_multi_bind_property_v (gint n_sources,
|
|||||||
gint n_targets,
|
gint n_targets,
|
||||||
GObject *targets[],
|
GObject *targets[],
|
||||||
const gchar *target_properties[],
|
const gchar *target_properties[],
|
||||||
|
GMultiBindingFlags flags,
|
||||||
GMultiBindingTransformFunc transform,
|
GMultiBindingTransformFunc transform,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify)
|
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;
|
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_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))
|
#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:
|
* GMultiBinding:
|
||||||
*
|
*
|
||||||
@ -45,6 +50,7 @@ G_BEGIN_DECLS
|
|||||||
typedef struct _GMultiBinding GMultiBinding;
|
typedef struct _GMultiBinding GMultiBinding;
|
||||||
|
|
||||||
typedef gboolean (* GMultiBindingTransformFunc) (GMultiBinding *binding,
|
typedef gboolean (* GMultiBindingTransformFunc) (GMultiBinding *binding,
|
||||||
|
gint notified,
|
||||||
const GValue from_values[],
|
const GValue from_values[],
|
||||||
GValue to_values[],
|
GValue to_values[],
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@ -74,15 +80,26 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
void g_multi_binding_unbind (GMultiBinding *binding);
|
void g_multi_binding_unbind (GMultiBinding *binding);
|
||||||
|
|
||||||
GLIB_AVAILABLE_IN_ALL
|
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[],
|
GObject *sources[],
|
||||||
const gchar *source_properties[],
|
const gchar *source_properties[],
|
||||||
gint n_targets,
|
gint n_targets,
|
||||||
GObject *targets[],
|
GObject *targets[],
|
||||||
const gchar *target_properties[],
|
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,
|
GMultiBindingTransformFunc transform,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __G_MULTI_BINDING_H__ */
|
#endif /* __G_MULTI_BINDING_H__ */
|
||||||
|
@ -237,6 +237,7 @@ binding_target_init (BindingTarget *self)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
munge_two_ints (GMultiBinding *binding,
|
munge_two_ints (GMultiBinding *binding,
|
||||||
|
gint notified,
|
||||||
const GValue from_values[],
|
const GValue from_values[],
|
||||||
GValue to_values[],
|
GValue to_values[],
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@ -273,6 +274,7 @@ multibinding_basic (void)
|
|||||||
target_props[1] = "bar";
|
target_props[1] = "bar";
|
||||||
binding = g_object_multi_bind_property_v (2, sources, source_props,
|
binding = g_object_multi_bind_property_v (2, sources, source_props,
|
||||||
2, targets, target_props,
|
2, targets, target_props,
|
||||||
|
G_MULTI_BINDING_DEFAULT,
|
||||||
munge_two_ints,
|
munge_two_ints,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
|
g_object_add_weak_pointer (G_OBJECT (binding), (gpointer *) &binding);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user