Commit 6153940b authored by Christian Hergert's avatar Christian Hergert
Browse files

object: add vfuncs for getter/setter and use them

Chain up here instead of doing our funky only chain-up after setting
phase. This should make things more predictable for subclasses that
need to do anything funny, and Vala.

https://bugzilla.gnome.org/show_bug.cgi?id=779891
parent 47f1172f
...@@ -94,6 +94,14 @@ ide_object_release_context (gpointer data, ...@@ -94,6 +94,14 @@ ide_object_release_context (gpointer data,
ide_object_destroy (self); ide_object_destroy (self);
} }
static IdeContext *
ide_object_real_get_context (IdeObject *self)
{
IdeObjectPrivate *priv = ide_object_get_instance_private (self);
return priv->context;
}
/** /**
* ide_object_get_context: * ide_object_get_context:
* *
...@@ -104,16 +112,24 @@ ide_object_release_context (gpointer data, ...@@ -104,16 +112,24 @@ ide_object_release_context (gpointer data,
IdeContext * IdeContext *
ide_object_get_context (IdeObject *self) ide_object_get_context (IdeObject *self)
{ {
IdeObjectPrivate *priv = ide_object_get_instance_private (self);
g_return_val_if_fail (IDE_IS_OBJECT (self), NULL); g_return_val_if_fail (IDE_IS_OBJECT (self), NULL);
return priv->context; return IDE_OBJECT_GET_CLASS (self)->get_context (self);
} }
void void
ide_object_set_context (IdeObject *self, ide_object_set_context (IdeObject *self,
IdeContext *context) IdeContext *context)
{
g_return_if_fail (IDE_IS_OBJECT (self));
g_return_if_fail (!context || IDE_IS_CONTEXT (context));
IDE_OBJECT_GET_CLASS (self)->set_context (self, context);
}
static void
ide_object_real_set_context (IdeObject *self,
IdeContext *context)
{ {
IdeObjectPrivate *priv = ide_object_get_instance_private (self); IdeObjectPrivate *priv = ide_object_get_instance_private (self);
...@@ -138,9 +154,6 @@ ide_object_set_context (IdeObject *self, ...@@ -138,9 +154,6 @@ ide_object_set_context (IdeObject *self,
self); self);
} }
if (IDE_OBJECT_GET_CLASS (self)->set_context)
IDE_OBJECT_GET_CLASS (self)->set_context (self, context);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONTEXT]); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CONTEXT]);
} }
} }
...@@ -211,6 +224,9 @@ ide_object_class_init (IdeObjectClass *klass) ...@@ -211,6 +224,9 @@ ide_object_class_init (IdeObjectClass *klass)
object_class->get_property = ide_object_get_property; object_class->get_property = ide_object_get_property;
object_class->set_property = ide_object_set_property; object_class->set_property = ide_object_set_property;
klass->get_context = ide_object_real_get_context;
klass->set_context = ide_object_real_set_context;
properties [PROP_CONTEXT] = properties [PROP_CONTEXT] =
g_param_spec_object ("context", g_param_spec_object ("context",
"Context", "Context",
......
...@@ -33,9 +33,10 @@ struct _IdeObjectClass ...@@ -33,9 +33,10 @@ struct _IdeObjectClass
{ {
GObjectClass parent; GObjectClass parent;
void (*destroy) (IdeObject *self); void (*destroy) (IdeObject *self);
void (*set_context) (IdeObject *self, IdeContext *(*get_context) (IdeObject *self);
IdeContext *context); void (*set_context) (IdeObject *self,
IdeContext *context);
}; };
IdeContext *ide_object_get_context (IdeObject *self); IdeContext *ide_object_get_context (IdeObject *self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment