FIXME in gtk_text_tag_set_property()
- From: Tim Janik <timj gtk org>
- To: Havoc Pennington <hp redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: FIXME in gtk_text_tag_set_property()
- Date: Sat, 24 Aug 2002 11:45:53 +0200 (CEST)
hey havoc.
i noticed a FIXME in gtk_text_tag_set_property():
static void
gtk_text_tag_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
[...]
switch (prop_id)
{
case PROP_NAME:
[...]
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
/* FIXME I would like to do this after all set_property in a single
* g_object_set () have been called. But an idle function won't
* work; we need to emit when the tag is changed, not when we get
* around to the event loop. So blah, we eat some inefficiency.
*/
/* This is also somewhat weird since we emit another object's
* signal here, but the two objects are already tightly bound.
*/
if (text_tag->table)
g_signal_emit_by_name (G_OBJECT (text_tag->table),
"tag_changed",
text_tag, size_changed);
}
the tag_changed signal should essentially be emitted when
GtkTextTag::notify is emitted, however you'll want to coalesce
multiple notify emissions there. this is actually pretty easy
to achive, except for maintaining the size_changed flag:
gtk_text_tag_class_init () {
gobject_class->dispatch_properties_changed = tag_dispatch_properties_changed;
}
static void
gtk_text_tag_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
[...]
switch (prop_id)
{
case PROP_NAME:
[...]
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
- /* FIXME I would like to do this after all set_property in a single
- * g_object_set () have been called. But an idle function won't
- * work; we need to emit when the tag is changed, not when we get
- * around to the event loop. So blah, we eat some inefficiency.
- */
-
- /* This is also somewhat weird since we emit another object's
- * signal here, but the two objects are already tightly bound.
- */
-
- if (text_tag->table)
- g_signal_emit_by_name (G_OBJECT (text_tag->table),
- "tag_changed",
- text_tag, size_changed);
+ /* save this for later notification */
+ text_tag->pad1 |= size_changed;
}
static void
tag_dispatch_properties_changed (GObject *object,
guint n_pspecs,
GParamSpec **pspecs)
{
GtkTextTag *self = GTK_TEXT_TAG (object);
/* save size_changed flag around set_property() recursion during ::notify emissions */
gboolean size_changed = self->pad1;
self->pad1 = FALSE;
/* chain to parent class, emits ::notify for all pspecs */
G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs);
/* let the tag table know we changed */
if (self->table)
g_signal_emit_by_name (self->table,
"tag_changed",
self, size_changed);
}
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]