mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
clutter/actor-meta: Use G_DECLARE_DERIVABLE_TYPE
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
This commit is contained in:
parent
c8e12ead08
commit
8c131b32b1
@ -81,38 +81,47 @@ static void
|
||||
on_actor_destroy (ClutterActor *actor,
|
||||
ClutterActorMeta *meta)
|
||||
{
|
||||
meta->priv->actor = NULL;
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
priv->actor = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_actor_meta_real_set_actor (ClutterActorMeta *meta,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
g_warn_if_fail (!meta->priv->actor ||
|
||||
!CLUTTER_ACTOR_IN_PAINT (meta->priv->actor));
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
g_warn_if_fail (!priv->actor ||
|
||||
!CLUTTER_ACTOR_IN_PAINT (priv->actor));
|
||||
g_warn_if_fail (!actor || !CLUTTER_ACTOR_IN_PAINT (actor));
|
||||
|
||||
if (meta->priv->actor == actor)
|
||||
if (priv->actor == actor)
|
||||
return;
|
||||
|
||||
g_clear_signal_handler (&meta->priv->destroy_id, meta->priv->actor);
|
||||
g_clear_signal_handler (&priv->destroy_id, priv->actor);
|
||||
|
||||
meta->priv->actor = actor;
|
||||
priv->actor = actor;
|
||||
|
||||
if (meta->priv->actor != NULL)
|
||||
meta->priv->destroy_id = g_signal_connect (meta->priv->actor, "destroy",
|
||||
G_CALLBACK (on_actor_destroy),
|
||||
meta);
|
||||
if (priv->actor != NULL)
|
||||
priv->destroy_id = g_signal_connect (priv->actor, "destroy",
|
||||
G_CALLBACK (on_actor_destroy),
|
||||
meta);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_actor_meta_real_set_enabled (ClutterActorMeta *meta,
|
||||
gboolean is_enabled)
|
||||
{
|
||||
g_warn_if_fail (!meta->priv->actor ||
|
||||
!CLUTTER_ACTOR_IN_PAINT (meta->priv->actor));
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
meta->priv->is_enabled = is_enabled;
|
||||
g_warn_if_fail (!priv->actor ||
|
||||
!CLUTTER_ACTOR_IN_PAINT (priv->actor));
|
||||
|
||||
priv->is_enabled = is_enabled;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ENABLED]);
|
||||
}
|
||||
@ -147,20 +156,21 @@ clutter_actor_meta_get_property (GObject *gobject,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterActorMeta *meta = CLUTTER_ACTOR_META (gobject);
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTOR:
|
||||
g_value_set_object (value, meta->priv->actor);
|
||||
g_value_set_object (value, priv->actor);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, meta->priv->name);
|
||||
g_value_set_string (value, priv->name);
|
||||
break;
|
||||
|
||||
case PROP_ENABLED:
|
||||
g_value_set_boolean (value, meta->priv->is_enabled);
|
||||
g_value_set_boolean (value, priv->is_enabled);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -172,7 +182,8 @@ clutter_actor_meta_get_property (GObject *gobject,
|
||||
static void
|
||||
clutter_actor_meta_finalize (GObject *gobject)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv = CLUTTER_ACTOR_META (gobject)->priv;
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject));
|
||||
|
||||
if (priv->actor != NULL)
|
||||
g_clear_signal_handler (&priv->destroy_id, priv->actor);
|
||||
@ -243,9 +254,11 @@ clutter_actor_meta_class_init (ClutterActorMetaClass *klass)
|
||||
void
|
||||
clutter_actor_meta_init (ClutterActorMeta *self)
|
||||
{
|
||||
self->priv = clutter_actor_meta_get_instance_private (self);
|
||||
self->priv->is_enabled = TRUE;
|
||||
self->priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT;
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (self);
|
||||
|
||||
priv->is_enabled = TRUE;
|
||||
priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,13 +276,17 @@ void
|
||||
clutter_actor_meta_set_name (ClutterActorMeta *meta,
|
||||
const gchar *name)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
|
||||
|
||||
if (g_strcmp0 (meta->priv->name, name) == 0)
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
if (g_strcmp0 (priv->name, name) == 0)
|
||||
return;
|
||||
|
||||
g_free (meta->priv->name);
|
||||
meta->priv->name = g_strdup (name);
|
||||
g_free (priv->name);
|
||||
priv->name = g_strdup (name);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_NAME]);
|
||||
}
|
||||
@ -290,9 +307,13 @@ clutter_actor_meta_set_name (ClutterActorMeta *meta,
|
||||
const gchar *
|
||||
clutter_actor_meta_get_name (ClutterActorMeta *meta)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL);
|
||||
|
||||
return meta->priv->name;
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
return priv->name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,11 +329,14 @@ void
|
||||
clutter_actor_meta_set_enabled (ClutterActorMeta *meta,
|
||||
gboolean is_enabled)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
|
||||
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
is_enabled = !!is_enabled;
|
||||
|
||||
if (meta->priv->is_enabled == is_enabled)
|
||||
if (priv->is_enabled == is_enabled)
|
||||
return;
|
||||
|
||||
CLUTTER_ACTOR_META_GET_CLASS (meta)->set_enabled (meta, is_enabled);
|
||||
@ -331,9 +355,13 @@ clutter_actor_meta_set_enabled (ClutterActorMeta *meta,
|
||||
gboolean
|
||||
clutter_actor_meta_get_enabled (ClutterActorMeta *meta)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), FALSE);
|
||||
|
||||
return meta->priv->is_enabled;
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
return priv->is_enabled;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -369,40 +397,54 @@ _clutter_actor_meta_set_actor (ClutterActorMeta *meta,
|
||||
ClutterActor *
|
||||
clutter_actor_meta_get_actor (ClutterActorMeta *meta)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL);
|
||||
|
||||
return meta->priv->actor;
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
return priv->actor;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_actor_meta_set_priority (ClutterActorMeta *meta,
|
||||
gint priority)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
|
||||
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
/* This property shouldn't be modified after the actor meta is in
|
||||
use because ClutterMetaGroup doesn't resort the list when it
|
||||
changes. If we made the priority public then we could either make
|
||||
the priority a construct-only property or listen for
|
||||
notifications on the property from the ClutterMetaGroup and
|
||||
resort. */
|
||||
g_return_if_fail (meta->priv->actor == NULL);
|
||||
g_return_if_fail (priv->actor == NULL);
|
||||
|
||||
meta->priv->priority = priority;
|
||||
priv->priority = priority;
|
||||
}
|
||||
|
||||
gint
|
||||
_clutter_actor_meta_get_priority (ClutterActorMeta *meta)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), 0);
|
||||
|
||||
return meta->priv->priority;
|
||||
priv = clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
return priv->priority;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_actor_meta_is_internal (ClutterActorMeta *meta)
|
||||
{
|
||||
gint priority = meta->priv->priority;
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
gint priority = priv->priority;
|
||||
|
||||
return (priority <= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_LOW ||
|
||||
priority >= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_HIGH);
|
||||
@ -449,19 +491,21 @@ void
|
||||
_clutter_meta_group_add_meta (ClutterMetaGroup *group,
|
||||
ClutterActorMeta *meta)
|
||||
{
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
GList *prev = NULL, *l;
|
||||
|
||||
if (meta->priv->actor != NULL)
|
||||
if (priv->actor != NULL)
|
||||
{
|
||||
g_warning ("The meta of type '%s' with name '%s' is "
|
||||
"already attached to actor '%s'",
|
||||
G_OBJECT_TYPE_NAME (meta),
|
||||
meta->priv->name != NULL
|
||||
? meta->priv->name
|
||||
priv->name != NULL
|
||||
? priv->name
|
||||
: "<unknown>",
|
||||
clutter_actor_get_name (meta->priv->actor) != NULL
|
||||
? clutter_actor_get_name (meta->priv->actor)
|
||||
: G_OBJECT_TYPE_NAME (meta->priv->actor));
|
||||
clutter_actor_get_name (priv->actor) != NULL
|
||||
? clutter_actor_get_name (priv->actor)
|
||||
: G_OBJECT_TYPE_NAME (priv->actor));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -497,13 +541,16 @@ void
|
||||
_clutter_meta_group_remove_meta (ClutterMetaGroup *group,
|
||||
ClutterActorMeta *meta)
|
||||
{
|
||||
if (meta->priv->actor != group->actor)
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
if (priv->actor != group->actor)
|
||||
{
|
||||
g_warning ("The meta of type '%s' with name '%s' is not "
|
||||
"attached to the actor '%s'",
|
||||
G_OBJECT_TYPE_NAME (meta),
|
||||
meta->priv->name != NULL
|
||||
? meta->priv->name
|
||||
priv->name != NULL
|
||||
? priv->name
|
||||
: "<unknown>",
|
||||
clutter_actor_get_name (group->actor) != NULL
|
||||
? clutter_actor_get_name (group->actor)
|
||||
@ -646,8 +693,10 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group,
|
||||
for (l = group->meta; l != NULL; l = l->next)
|
||||
{
|
||||
ClutterActorMeta *meta = l->data;
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
if (g_strcmp0 (meta->priv->name, name) == 0)
|
||||
if (g_strcmp0 (priv->name, name) == 0)
|
||||
return meta;
|
||||
}
|
||||
|
||||
@ -667,6 +716,8 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group,
|
||||
const gchar *
|
||||
_clutter_actor_meta_get_debug_name (ClutterActorMeta *meta)
|
||||
{
|
||||
return meta->priv->name != NULL ? meta->priv->name
|
||||
: G_OBJECT_TYPE_NAME (meta);
|
||||
ClutterActorMetaPrivate *priv =
|
||||
clutter_actor_meta_get_instance_private (meta);
|
||||
|
||||
return priv->name != NULL ? priv->name : G_OBJECT_TYPE_NAME (meta);
|
||||
}
|
||||
|
@ -33,31 +33,13 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_ACTOR_META (clutter_actor_meta_get_type ())
|
||||
#define CLUTTER_ACTOR_META(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMeta))
|
||||
#define CLUTTER_IS_ACTOR_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTOR_META))
|
||||
#define CLUTTER_ACTOR_META_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass))
|
||||
#define CLUTTER_IS_ACTOR_META_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTOR_META))
|
||||
#define CLUTTER_ACTOR_META_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass))
|
||||
#define CLUTTER_TYPE_ACTOR_META (clutter_actor_meta_get_type ())
|
||||
|
||||
typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate;
|
||||
typedef struct _ClutterActorMetaClass ClutterActorMetaClass;
|
||||
CLUTTER_EXPORT
|
||||
G_DECLARE_DERIVABLE_TYPE (ClutterActorMeta, clutter_actor_meta,
|
||||
CLUTTER, ACTOR_META, GInitiallyUnowned);
|
||||
|
||||
/**
|
||||
* ClutterActorMeta:
|
||||
*
|
||||
* The #ClutterActorMeta structure contains only
|
||||
* private data and should be accessed using the provided API
|
||||
*
|
||||
* Since: 1.4
|
||||
*/
|
||||
struct _ClutterActorMeta
|
||||
{
|
||||
/*< private >*/
|
||||
GInitiallyUnowned parent_instance;
|
||||
|
||||
ClutterActorMetaPrivate *priv;
|
||||
};
|
||||
typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate;
|
||||
|
||||
/**
|
||||
* ClutterActorMetaClass:
|
||||
@ -99,9 +81,6 @@ struct _ClutterActorMetaClass
|
||||
void (* _clutter_meta6) (void);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GType clutter_actor_meta_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_actor_meta_set_name (ClutterActorMeta *meta,
|
||||
const gchar *name);
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAction, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActor, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorMeta, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAlignConstraint, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref)
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBindConstraint, g_object_unref)
|
||||
|
Loading…
Reference in New Issue
Block a user