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-debug.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
|
|
||||||
GType
|
typedef ClutterAnimatableIface ClutterAnimatableInterface;
|
||||||
clutter_animatable_get_type (void)
|
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,
|
ClutterActor *child,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
typedef ClutterContainerIface ClutterContainerInterface;
|
||||||
|
|
||||||
|
G_DEFINE_INTERFACE (ClutterContainer, clutter_container, CLUTTER_TYPE_ACTOR);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_container_base_init (gpointer g_iface)
|
clutter_container_default_init (ClutterContainerInterface *iface)
|
||||||
{
|
{
|
||||||
static gboolean initialised = FALSE;
|
GType iface_type = G_TYPE_FROM_INTERFACE (iface);
|
||||||
|
|
||||||
if (!initialised)
|
|
||||||
{
|
|
||||||
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
|
|
||||||
ClutterContainerIface *iface = g_iface;
|
|
||||||
|
|
||||||
initialised = TRUE;
|
|
||||||
|
|
||||||
quark_child_meta =
|
quark_child_meta =
|
||||||
g_quark_from_static_string ("clutter-container-child-data");
|
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->get_child_meta = get_child_meta;
|
||||||
iface->child_notify = child_notify;
|
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:
|
* clutter_container_add:
|
||||||
|
@ -57,17 +57,15 @@ enum
|
|||||||
|
|
||||||
static guint media_signals[LAST_SIGNAL] = { 0, };
|
static guint media_signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
static void
|
typedef ClutterMediaIface ClutterMediaInterface;
|
||||||
clutter_media_base_init (gpointer g_iface)
|
|
||||||
{
|
|
||||||
static gboolean was_initialized = FALSE;
|
|
||||||
|
|
||||||
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;
|
GParamSpec *pspec = NULL;
|
||||||
|
|
||||||
was_initialized = TRUE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:uri:
|
* ClutterMedia:uri:
|
||||||
*
|
*
|
||||||
@ -80,7 +78,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("URI of a media file"),
|
P_("URI of a media file"),
|
||||||
NULL,
|
NULL,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:playing:
|
* ClutterMedia:playing:
|
||||||
@ -94,7 +92,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("Wheter the actor is playing"),
|
P_("Wheter the actor is playing"),
|
||||||
FALSE,
|
FALSE,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:progress:
|
* ClutterMedia:progress:
|
||||||
@ -109,7 +107,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("Current progress of the playback"),
|
P_("Current progress of the playback"),
|
||||||
0.0, 1.0, 0.0,
|
0.0, 1.0, 0.0,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:subtitle-uri:
|
* ClutterMedia:subtitle-uri:
|
||||||
@ -123,7 +121,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("URI of a subtitle file"),
|
P_("URI of a subtitle file"),
|
||||||
NULL,
|
NULL,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:subtitle-font-name:
|
* ClutterMedia:subtitle-font-name:
|
||||||
@ -139,7 +137,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("The font used to display subtitles"),
|
P_("The font used to display subtitles"),
|
||||||
NULL,
|
NULL,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:audio-volume:
|
* ClutterMedia:audio-volume:
|
||||||
@ -154,7 +152,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("The volume of the audio"),
|
P_("The volume of the audio"),
|
||||||
0.0, 1.0, 0.5,
|
0.0, 1.0, 0.5,
|
||||||
CLUTTER_PARAM_READWRITE);
|
CLUTTER_PARAM_READWRITE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:can-seek:
|
* ClutterMedia:can-seek:
|
||||||
@ -168,7 +166,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("Whether the current stream is seekable"),
|
P_("Whether the current stream is seekable"),
|
||||||
FALSE,
|
FALSE,
|
||||||
CLUTTER_PARAM_READABLE);
|
CLUTTER_PARAM_READABLE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:buffer-fill:
|
* ClutterMedia:buffer-fill:
|
||||||
@ -183,7 +181,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("The fill level of the buffer"),
|
P_("The fill level of the buffer"),
|
||||||
0.0, 1.0, 0.0,
|
0.0, 1.0, 0.0,
|
||||||
CLUTTER_PARAM_READABLE);
|
CLUTTER_PARAM_READABLE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia:duration:
|
* ClutterMedia:duration:
|
||||||
@ -197,7 +195,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
P_("The duration of the stream, in seconds"),
|
P_("The duration of the stream, in seconds"),
|
||||||
0, G_MAXDOUBLE, 0,
|
0, G_MAXDOUBLE, 0,
|
||||||
CLUTTER_PARAM_READABLE);
|
CLUTTER_PARAM_READABLE);
|
||||||
g_object_interface_install_property (g_iface, pspec);
|
g_object_interface_install_property (iface, pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterMedia::eos:
|
* ClutterMedia::eos:
|
||||||
@ -208,7 +206,7 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
* Since: 0.2
|
* Since: 0.2
|
||||||
*/
|
*/
|
||||||
media_signals[EOS_SIGNAL] =
|
media_signals[EOS_SIGNAL] =
|
||||||
g_signal_new ("eos",
|
g_signal_new (I_("eos"),
|
||||||
CLUTTER_TYPE_MEDIA,
|
CLUTTER_TYPE_MEDIA,
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (ClutterMediaIface, eos),
|
G_STRUCT_OFFSET (ClutterMediaIface, eos),
|
||||||
@ -225,39 +223,17 @@ clutter_media_base_init (gpointer g_iface)
|
|||||||
* Since: 0.2
|
* Since: 0.2
|
||||||
*/
|
*/
|
||||||
media_signals[ERROR_SIGNAL] =
|
media_signals[ERROR_SIGNAL] =
|
||||||
g_signal_new ("error",
|
g_signal_new (I_("error"),
|
||||||
CLUTTER_TYPE_MEDIA,
|
CLUTTER_TYPE_MEDIA,
|
||||||
G_SIGNAL_RUN_LAST,
|
G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET (ClutterMediaIface, error),
|
G_STRUCT_OFFSET (ClutterMediaIface, error),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
_clutter_marshal_VOID__POINTER,
|
_clutter_marshal_VOID__BOXED,
|
||||||
G_TYPE_NONE, 1,
|
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:
|
* clutter_media_set_uri:
|
||||||
* @media: a #ClutterMedia
|
* @media: a #ClutterMedia
|
||||||
|
@ -51,21 +51,13 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-debug.h"
|
#include "clutter-debug.h"
|
||||||
|
|
||||||
GType
|
typedef ClutterScriptableIface ClutterScriptableInterface;
|
||||||
clutter_scriptable_get_type (void)
|
|
||||||
{
|
|
||||||
static GType scriptable_type = 0;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (scriptable_type == 0))
|
G_DEFINE_INTERFACE (ClutterScriptable, clutter_scriptable, G_TYPE_OBJECT);
|
||||||
{
|
|
||||||
scriptable_type =
|
|
||||||
g_type_register_static_simple (G_TYPE_INTERFACE,
|
|
||||||
I_("ClutterScriptable"),
|
|
||||||
sizeof (ClutterScriptableIface),
|
|
||||||
NULL, 0, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return scriptable_type;
|
static void
|
||||||
|
clutter_scriptable_default_init (ClutterScriptableInterface *iface)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,28 +8,13 @@
|
|||||||
#include "clutter-stage-window.h"
|
#include "clutter-stage-window.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
|
|
||||||
GType
|
typedef ClutterStageWindowIface ClutterStageWindowInterface;
|
||||||
clutter_stage_window_get_type (void)
|
|
||||||
|
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 *
|
ClutterActor *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user