2006-11-16 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-alpha.h:
	* clutter/clutter-alpha.c: ClutterAlpha is an initially
	floating object, as it makes sense only when bound to
	a ClutterBehaviour; add checks for public API.

	* clutter/clutter-behaviour.h:
	* clutter/clutter-behaviour.c: Remove the ClutterBehaviour
	constructor: ClutterBehaviour is an abstract class which
	must be implemented by subclassing; add checks for public
	API; unref the actors on finalize; sink the ClutterAlpha
	object.

	* clutter/clutter-behaviours.h: ClutterKnot is a boxed
	type: add the _get_type() function declaration and the
	type macro.
This commit is contained in:
Emmanuele Bassi 2006-11-14 14:12:56 +00:00
parent ddab271272
commit 3f62c72d07
9 changed files with 155 additions and 133 deletions

View File

@ -1,3 +1,21 @@
2006-11-16 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-alpha.h:
* clutter/clutter-alpha.c: ClutterAlpha is an initially
floating object, as it makes sense only when bound to
a ClutterBehaviour; add checks for public API.
* clutter/clutter-behaviour.h:
* clutter/clutter-behaviour.c: Remove the ClutterBehaviour
constructor: ClutterBehaviour is an abstract class which
must be implemented by subclassing; add checks for public
API; unref the actors on finalize; sink the ClutterAlpha
object.
* clutter/clutter-behaviours.h: ClutterKnot is a boxed
type: add the _get_type() function declaration and the
type macro.
2006-10-23 Matthew Allum <mallum@openedhand.com> 2006-10-23 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-alpha.h: * clutter/clutter-alpha.h:

View File

@ -40,7 +40,7 @@
G_DEFINE_TYPE (ClutterAlpha, clutter_alpha, G_TYPE_OBJECT); G_DEFINE_TYPE (ClutterAlpha, clutter_alpha, G_TYPE_OBJECT);
struct ClutterAlphaPrivate struct _ClutterAlphaPrivate
{ {
ClutterTimeline *timeline; ClutterTimeline *timeline;
guint timeline_new_frame_id; guint timeline_new_frame_id;
@ -316,6 +316,8 @@ clutter_alpha_set_timeline (ClutterAlpha *alpha,
ClutterTimeline * ClutterTimeline *
clutter_alpha_get_timeline (ClutterAlpha *alpha) clutter_alpha_get_timeline (ClutterAlpha *alpha)
{ {
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), NULL);
return alpha->priv->timeline; return alpha->priv->timeline;
} }
@ -332,6 +334,9 @@ ClutterAlpha*
clutter_alpha_new (ClutterTimeline *timeline, clutter_alpha_new (ClutterTimeline *timeline,
ClutterAlphaFunc func) ClutterAlphaFunc func)
{ {
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);
g_return_val_if_fail (func != NULL, NULL);
return g_object_new (CLUTTER_TYPE_ALPHA, return g_object_new (CLUTTER_TYPE_ALPHA,
"timeline", timeline, "timeline", timeline,
"func", func, "func", func,

View File

@ -57,21 +57,21 @@ G_BEGIN_DECLS
(G_TYPE_INSTANCE_GET_CLASS ((obj), \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
CLUTTER_TYPE_ALPHA, ClutterAlphaClass)) CLUTTER_TYPE_ALPHA, ClutterAlphaClass))
typedef struct _ClutterAlpha ClutterAlpha; typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAlphaClass ClutterAlphaClass; typedef struct _ClutterAlphaClass ClutterAlphaClass;
typedef struct ClutterAlphaPrivate ClutterAlphaPrivate; typedef struct _ClutterAlphaPrivate ClutterAlphaPrivate;
typedef guint32 (*ClutterAlphaFunc) (ClutterAlpha *alpha); typedef guint32 (*ClutterAlphaFunc) (ClutterAlpha *alpha);
struct _ClutterAlpha struct _ClutterAlpha
{ {
GObject parent; GInitiallyUnowned parent;
ClutterAlphaPrivate *priv; ClutterAlphaPrivate *priv;
}; };
struct _ClutterAlphaClass struct _ClutterAlphaClass
{ {
GObjectClass parent_class; GInitiallyUnownedClass parent_class;
void (*_clutter_alpha_1) (void); void (*_clutter_alpha_1) (void);
void (*_clutter_alpha_2) (void); void (*_clutter_alpha_2) (void);

View File

@ -34,13 +34,16 @@
#include "clutter-actor.h" #include "clutter-actor.h"
#include "clutter-behaviour.h" #include "clutter-behaviour.h"
G_DEFINE_TYPE (ClutterBehaviour, clutter_behaviour, G_TYPE_OBJECT); G_DEFINE_ABSTRACT_TYPE (ClutterBehaviour,
clutter_behaviour,
G_TYPE_OBJECT);
struct ClutterBehaviourPrivate struct _ClutterBehaviourPrivate
{ {
ClutterAlpha *alpha; ClutterAlpha *alpha;
guint notify_id;
GSList *actors; guint notify_id;
GSList *actors;
}; };
enum enum
@ -60,39 +63,23 @@ enum {
ClutterBehaviourPrivate)) ClutterBehaviourPrivate))
static void static void
_clutter_behaviour_dispose (GObject *object) clutter_behaviour_finalize (GObject *object)
{ {
ClutterBehaviour *self = CLUTTER_BEHAVIOUR(object); ClutterBehaviour *self = CLUTTER_BEHAVIOUR (object);
if (self->priv) clutter_behaviour_set_alpha (self, NULL);
{
/* FIXME: remove all actors */ g_slist_foreach (self->priv->actors, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->actors);
clutter_behaviour_set_alpha (self, NULL);
}
G_OBJECT_CLASS (clutter_behaviour_parent_class)->dispose (object);
}
static void
_clutter_behaviour_finalize (GObject *object)
{
ClutterBehaviour *self = CLUTTER_BEHAVIOUR(object);
if (self->priv)
{
g_free(self->priv);
self->priv = NULL;
}
G_OBJECT_CLASS (clutter_behaviour_parent_class)->finalize (object); G_OBJECT_CLASS (clutter_behaviour_parent_class)->finalize (object);
} }
static void static void
_clutter_behaviour_set_property (GObject *object, clutter_behaviour_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterBehaviour *behaviour; ClutterBehaviour *behaviour;
@ -110,10 +97,10 @@ _clutter_behaviour_set_property (GObject *object,
} }
static void static void
_clutter_behaviour_get_property (GObject *object, clutter_behaviour_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterBehaviour *behaviour; ClutterBehaviour *behaviour;
ClutterBehaviourPrivate *priv; ClutterBehaviourPrivate *priv;
@ -136,24 +123,22 @@ _clutter_behaviour_get_property (GObject *object,
static void static void
clutter_behaviour_class_init (ClutterBehaviourClass *klass) clutter_behaviour_class_init (ClutterBehaviourClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class = (GObjectClass*) klass; object_class->finalize = clutter_behaviour_finalize;
object_class->set_property = clutter_behaviour_set_property;
object_class->get_property = clutter_behaviour_get_property;
object_class->finalize = _clutter_behaviour_finalize; g_object_class_install_property (object_class,
object_class->dispose = _clutter_behaviour_dispose; PROP_ALPHA,
object_class->set_property = _clutter_behaviour_set_property; g_param_spec_object ("alpha",
object_class->get_property = _clutter_behaviour_get_property; "Alpha",
"Alpha Object to drive the behaviour",
CLUTTER_TYPE_ALPHA,
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE));
g_object_class_install_property g_type_class_add_private (klass, sizeof (ClutterBehaviourPrivate));
(object_class, PROP_ALPHA,
g_param_spec_object ("alpha",
"Alpha",
"Alpha Object to drive the behaviour",
CLUTTER_TYPE_ALPHA,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (ClutterBehaviourPrivate));
} }
static void static void
@ -165,48 +150,44 @@ clutter_behaviour_init (ClutterBehaviour *self)
} }
ClutterBehaviour*
clutter_behaviour_new (GObject *object,
const char *property)
{
ClutterBehaviour *behave;
behave = g_object_new (CLUTTER_TYPE_BEHAVIOUR,
"object", object,
"property", property,
NULL);
return behave;
}
void void
clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor) clutter_behaviour_apply (ClutterBehaviour *behave,
ClutterActor *actor)
{ {
g_return_if_fail (actor != NULL); g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave));
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
if (g_slist_find (behave->priv->actors, (gconstpointer)actor)) if (g_slist_find (behave->priv->actors, actor))
return; {
g_warning ("The behaviour of type %s already applies "
"to the actor of type %s",
g_type_name (G_OBJECT_TYPE (behave)),
g_type_name (G_OBJECT_TYPE (actor)));
return;
}
g_object_ref (actor); g_object_ref (actor);
behave->priv->actors = g_slist_append (behave->priv->actors, actor); behave->priv->actors = g_slist_prepend (behave->priv->actors, actor);
} }
void void
clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor) clutter_behaviour_remove (ClutterBehaviour *behave,
ClutterActor *actor)
{ {
g_return_if_fail (actor != NULL); g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave));
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
if (g_slist_find (behave->priv->actors, (gconstpointer)actor)) if (!g_slist_find (behave->priv->actors, actor))
{ {
g_object_unref (actor); g_warning ("The behaviour of type %s does not apply "
behave->priv->actors = g_slist_remove (behave->priv->actors, actor); "to the actor of type %s",
g_type_name (G_OBJECT_TYPE (behave)),
g_type_name (G_OBJECT_TYPE (actor)));
return;
} }
}
g_object_unref (actor);
void behave->priv->actors = g_slist_remove (behave->priv->actors, actor);
clutter_behaviour_remove_all (ClutterBehaviour *behave)
{
/* tofix */
} }
void void
@ -214,12 +195,17 @@ clutter_behaviour_actors_foreach (ClutterBehaviour *behave,
GFunc func, GFunc func,
gpointer userdata) gpointer userdata)
{ {
g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave));
g_return_if_fail (func != NULL);
g_slist_foreach (behave->priv->actors, func, userdata); g_slist_foreach (behave->priv->actors, func, userdata);
} }
ClutterAlpha* ClutterAlpha*
clutter_behaviour_get_alpha (ClutterBehaviour *behave) clutter_behaviour_get_alpha (ClutterBehaviour *behave)
{ {
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR (behave), NULL);
return behave->priv->alpha; return behave->priv->alpha;
} }
@ -240,27 +226,32 @@ void
clutter_behaviour_set_alpha (ClutterBehaviour *behave, clutter_behaviour_set_alpha (ClutterBehaviour *behave,
ClutterAlpha *alpha) ClutterAlpha *alpha)
{ {
if (behave->priv->notify_id) ClutterBehaviourPrivate *priv;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR (behave));
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
priv = behave->priv;
if (priv->notify_id)
{ {
g_signal_handler_disconnect (behave->priv->alpha, g_signal_handler_disconnect (priv->alpha, priv->notify_id);
behave->priv->notify_id); priv->notify_id = 0;
behave->priv->notify_id = 0;
} }
if (behave->priv->alpha) if (priv->alpha)
{ {
g_object_unref (behave->priv->alpha); g_object_unref (priv->alpha);
behave->priv->alpha = NULL; priv->alpha = NULL;
} }
if (alpha) if (alpha)
{ {
behave->priv->alpha = alpha; priv->alpha = alpha;
g_object_ref (behave->priv->alpha); g_object_ref_sink (priv->alpha);
behave->priv->notify_id = g_signal_connect (behave->priv->alpha, priv->notify_id = g_signal_connect (priv->alpha, "notify::alpha",
"notify::alpha", G_CALLBACK(notify_cb),
G_CALLBACK(notify_cb), behave);
behave);
} }
} }

View File

@ -28,9 +28,9 @@ G_BEGIN_DECLS
(G_TYPE_INSTANCE_GET_CLASS ((obj), \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
CLUTTER_TYPE_BEHAVIOUR, ClutterBehaviourClass)) CLUTTER_TYPE_BEHAVIOUR, ClutterBehaviourClass))
typedef struct _ClutterBehaviour ClutterBehaviour; typedef struct _ClutterBehaviour ClutterBehaviour;
typedef struct ClutterBehaviourPrivate ClutterBehaviourPrivate; typedef struct _ClutterBehaviourPrivate ClutterBehaviourPrivate;
typedef struct _ClutterBehaviourClass ClutterBehaviourClass; typedef struct _ClutterBehaviourClass ClutterBehaviourClass;
struct _ClutterBehaviour struct _ClutterBehaviour
{ {
@ -47,19 +47,12 @@ struct _ClutterBehaviourClass
GType clutter_behaviour_get_type (void); GType clutter_behaviour_get_type (void);
ClutterBehaviour*
clutter_behaviour_new (GObject *object,
const char *property);
void void
clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor); clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor);
void void
clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor); clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor);
void
clutter_behaviour_remove_all (ClutterBehaviour *behave);
void void
clutter_behaviour_actors_foreach (ClutterBehaviour *behave, clutter_behaviour_actors_foreach (ClutterBehaviour *behave,
GFunc func, GFunc func,

View File

@ -78,7 +78,7 @@ G_DEFINE_TYPE (ClutterBehaviourPath, \
clutter_behaviour_path, \ clutter_behaviour_path, \
CLUTTER_TYPE_BEHAVIOUR); CLUTTER_TYPE_BEHAVIOUR);
struct ClutterBehaviourPathPrivate struct _ClutterBehaviourPathPrivate
{ {
GSList *knots; GSList *knots;
}; };

View File

@ -7,6 +7,8 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define CLUTTER_TYPE_KNOT (clutter_knot_get_type ())
typedef struct _ClutterKnot ClutterKnot; typedef struct _ClutterKnot ClutterKnot;
struct _ClutterKnot struct _ClutterKnot
@ -15,7 +17,9 @@ struct _ClutterKnot
/* FIXME: optionally include bezier control points also ? */ /* FIXME: optionally include bezier control points also ? */
}; };
#define CLUTTER_TYPE_BEHAVIOUR_PATH clutter_behaviour_path_get_type() GType clutter_knot_get_type (void) G_GNUC_CONST;
#define CLUTTER_TYPE_BEHAVIOUR_PATH (clutter_behaviour_path_get_type ())
#define CLUTTER_BEHAVIOUR_PATH(obj) \ #define CLUTTER_BEHAVIOUR_PATH(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
@ -37,9 +41,9 @@ struct _ClutterKnot
(G_TYPE_INSTANCE_GET_CLASS ((obj), \ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
CLUTTER_TYPE_BEHAVIOUR_PATH, ClutterBehaviourPathClass)) CLUTTER_TYPE_BEHAVIOUR_PATH, ClutterBehaviourPathClass))
typedef struct _ClutterBehaviourPath ClutterBehaviourPath; typedef struct _ClutterBehaviourPath ClutterBehaviourPath;
typedef struct ClutterBehaviourPathPrivate ClutterBehaviourPathPrivate; typedef struct _ClutterBehaviourPathPrivate ClutterBehaviourPathPrivate;
typedef struct _ClutterBehaviourPathClass ClutterBehaviourPathClass; typedef struct _ClutterBehaviourPathClass ClutterBehaviourPathClass;
struct _ClutterBehaviourPath struct _ClutterBehaviourPath
{ {

View File

@ -23,11 +23,26 @@ ClutterLabel
</para> </para>
<!-- ##### ARG ClutterLabel:alignment ##### -->
<para>
</para>
<!-- ##### ARG ClutterLabel:attributes ##### -->
<para>
</para>
<!-- ##### ARG ClutterLabel:color ##### --> <!-- ##### ARG ClutterLabel:color ##### -->
<para> <para>
</para> </para>
<!-- ##### ARG ClutterLabel:ellipsize ##### -->
<para>
</para>
<!-- ##### ARG ClutterLabel:font-name ##### --> <!-- ##### ARG ClutterLabel:font-name ##### -->
<para> <para>
@ -38,6 +53,21 @@ ClutterLabel
</para> </para>
<!-- ##### ARG ClutterLabel:use-markup ##### -->
<para>
</para>
<!-- ##### ARG ClutterLabel:wrap ##### -->
<para>
</para>
<!-- ##### ARG ClutterLabel:wrap-mode ##### -->
<para>
</para>
<!-- ##### FUNCTION clutter_label_new ##### --> <!-- ##### FUNCTION clutter_label_new ##### -->
<para> <para>
@ -110,23 +140,3 @@ ClutterLabel
@color: @color:
<!-- ##### FUNCTION clutter_label_set_text_extents ##### -->
<para>
</para>
@label:
@width:
@height:
<!-- ##### FUNCTION clutter_label_get_text_extents ##### -->
<para>
</para>
@label:
@width:
@height:

View File

@ -31,6 +31,7 @@ clutter-main
@x: @x:
@a...: @a...:
@a...:
@a...: @a...: