Use G_DEFINE_INTERFACE
GObject provides us with a nice, safe macro for defining interface types.
This commit is contained in:
parent
8f5d6cb790
commit
9caf11f2d8
@ -53,18 +53,12 @@
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
GType
|
||||
clutter_animatable_get_type (void)
|
||||
typedef ClutterAnimatableIface ClutterAnimatableInterface;
|
||||
G_DEFINE_INTERFACE (ClutterAnimatable, clutter_animatable, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
clutter_animatable_default_init (ClutterAnimatableInterface *iface)
|
||||
{
|
||||
static GType a_type = 0;
|
||||
|
||||
if (G_UNLIKELY (a_type == 0))
|
||||
a_type = g_type_register_static_simple (G_TYPE_INTERFACE,
|
||||
I_("ClutterAnimatable"),
|
||||
sizeof (ClutterAnimatableIface),
|
||||
NULL, 0, NULL, 0);
|
||||
|
||||
return a_type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,17 +96,14 @@ static void child_notify (ClutterContainer *container,
|
||||
ClutterActor *child,
|
||||
GParamSpec *pspec);
|
||||
|
||||
typedef ClutterContainerIface ClutterContainerInterface;
|
||||
|
||||
G_DEFINE_INTERFACE (ClutterContainer, clutter_container, CLUTTER_TYPE_ACTOR);
|
||||
|
||||
static void
|
||||
clutter_container_base_init (gpointer g_iface)
|
||||
clutter_container_default_init (ClutterContainerInterface *iface)
|
||||
{
|
||||
static gboolean initialised = FALSE;
|
||||
|
||||
if (!initialised)
|
||||
{
|
||||
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
|
||||
ClutterContainerIface *iface = g_iface;
|
||||
|
||||
initialised = TRUE;
|
||||
GType iface_type = G_TYPE_FROM_INTERFACE (iface);
|
||||
|
||||
quark_child_meta =
|
||||
g_quark_from_static_string ("clutter-container-child-data");
|
||||
@ -178,31 +175,6 @@ clutter_container_base_init (gpointer g_iface)
|
||||
iface->get_child_meta = get_child_meta;
|
||||
iface->child_notify = child_notify;
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
clutter_container_get_type (void)
|
||||
{
|
||||
static GType container_type = 0;
|
||||
|
||||
if (G_UNLIKELY (!container_type))
|
||||
{
|
||||
const GTypeInfo container_info =
|
||||
{
|
||||
sizeof (ClutterContainerIface),
|
||||
clutter_container_base_init,
|
||||
NULL, /* iface_base_finalize */
|
||||
};
|
||||
|
||||
container_type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
I_("ClutterContainer"),
|
||||
&container_info, 0);
|
||||
|
||||
g_type_interface_add_prerequisite (container_type, G_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
return container_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_container_add:
|
||||
|
@ -57,17 +57,15 @@ enum
|
||||
|
||||
static guint media_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
static void
|
||||
clutter_media_base_init (gpointer g_iface)
|
||||
{
|
||||
static gboolean was_initialized = FALSE;
|
||||
typedef ClutterMediaIface ClutterMediaInterface;
|
||||
|
||||
if (G_UNLIKELY (!was_initialized))
|
||||
G_DEFINE_INTERFACE (ClutterMedia, clutter_media, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
clutter_media_default_init (ClutterMediaInterface *iface)
|
||||
{
|
||||
GParamSpec *pspec = NULL;
|
||||
|
||||
was_initialized = TRUE;
|
||||
|
||||
/**
|
||||
* ClutterMedia:uri:
|
||||
*
|
||||
@ -80,7 +78,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("URI of a media file"),
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:playing:
|
||||
@ -94,7 +92,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("Wheter the actor is playing"),
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:progress:
|
||||
@ -109,7 +107,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("Current progress of the playback"),
|
||||
0.0, 1.0, 0.0,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:subtitle-uri:
|
||||
@ -123,7 +121,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("URI of a subtitle file"),
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:subtitle-font-name:
|
||||
@ -139,7 +137,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("The font used to display subtitles"),
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:audio-volume:
|
||||
@ -154,7 +152,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("The volume of the audio"),
|
||||
0.0, 1.0, 0.5,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:can-seek:
|
||||
@ -168,7 +166,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("Whether the current stream is seekable"),
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READABLE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:buffer-fill:
|
||||
@ -183,7 +181,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("The fill level of the buffer"),
|
||||
0.0, 1.0, 0.0,
|
||||
CLUTTER_PARAM_READABLE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia:duration:
|
||||
@ -197,7 +195,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
P_("The duration of the stream, in seconds"),
|
||||
0, G_MAXDOUBLE, 0,
|
||||
CLUTTER_PARAM_READABLE);
|
||||
g_object_interface_install_property (g_iface, pspec);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
|
||||
/**
|
||||
* ClutterMedia::eos:
|
||||
@ -208,7 +206,7 @@ clutter_media_base_init (gpointer g_iface)
|
||||
* Since: 0.2
|
||||
*/
|
||||
media_signals[EOS_SIGNAL] =
|
||||
g_signal_new ("eos",
|
||||
g_signal_new (I_("eos"),
|
||||
CLUTTER_TYPE_MEDIA,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (ClutterMediaIface, eos),
|
||||
@ -225,39 +223,17 @@ clutter_media_base_init (gpointer g_iface)
|
||||
* Since: 0.2
|
||||
*/
|
||||
media_signals[ERROR_SIGNAL] =
|
||||
g_signal_new ("error",
|
||||
g_signal_new (I_("error"),
|
||||
CLUTTER_TYPE_MEDIA,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (ClutterMediaIface, error),
|
||||
NULL, NULL,
|
||||
_clutter_marshal_VOID__POINTER,
|
||||
_clutter_marshal_VOID__BOXED,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
}
|
||||
G_TYPE_ERROR);
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
clutter_media_get_type (void)
|
||||
{
|
||||
static GType media_type = 0;
|
||||
|
||||
if (G_UNLIKELY (media_type == 0))
|
||||
{
|
||||
const GTypeInfo media_info = {
|
||||
sizeof (ClutterMediaIface), /* class size */
|
||||
clutter_media_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
};
|
||||
|
||||
media_type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
I_("ClutterMedia"),
|
||||
&media_info, 0);
|
||||
}
|
||||
|
||||
return media_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_media_set_uri:
|
||||
* @media: a #ClutterMedia
|
||||
|
@ -51,21 +51,13 @@
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-debug.h"
|
||||
|
||||
GType
|
||||
clutter_scriptable_get_type (void)
|
||||
{
|
||||
static GType scriptable_type = 0;
|
||||
typedef ClutterScriptableIface ClutterScriptableInterface;
|
||||
|
||||
if (G_UNLIKELY (scriptable_type == 0))
|
||||
{
|
||||
scriptable_type =
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE,
|
||||
I_("ClutterScriptable"),
|
||||
sizeof (ClutterScriptableIface),
|
||||
NULL, 0, NULL, 0);
|
||||
}
|
||||
G_DEFINE_INTERFACE (ClutterScriptable, clutter_scriptable, G_TYPE_OBJECT);
|
||||
|
||||
return scriptable_type;
|
||||
static void
|
||||
clutter_scriptable_default_init (ClutterScriptableInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,28 +8,13 @@
|
||||
#include "clutter-stage-window.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
GType
|
||||
clutter_stage_window_get_type (void)
|
||||
typedef ClutterStageWindowIface ClutterStageWindowInterface;
|
||||
|
||||
G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
clutter_stage_window_default_init (ClutterStageWindowInterface *iface)
|
||||
{
|
||||
static GType stage_window_type = 0;
|
||||
|
||||
if (G_UNLIKELY (stage_window_type == 0))
|
||||
{
|
||||
const GTypeInfo stage_window_info = {
|
||||
sizeof (ClutterStageWindowIface),
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
stage_window_type =
|
||||
g_type_register_static (G_TYPE_INTERFACE, I_("ClutterStageWindow"),
|
||||
&stage_window_info, 0);
|
||||
|
||||
g_type_interface_add_prerequisite (stage_window_type,
|
||||
G_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
return stage_window_type;
|
||||
}
|
||||
|
||||
ClutterActor *
|
||||
|
Loading…
x
Reference in New Issue
Block a user