+2005-04-23 Stefan Kost <ensonic@users.sf.net>
+
+ * gobject/tut_gtype.xml:
+ * gobject/tut_howto.xml:
+ all interface examples use 'interface' instead of 'class'
+
2005-04-22 Stefan Kost <ensonic@users.sf.net>
* gobject/Makefile.am:
2005-01-04 Matthias Clasen <mclasen@redhat.com>
* gobject/tmpl/signals.sgml: Small addition. (#145158,
- Mariano Suárez-Alvarez)
+ Mariano Su??rez-Alvarez)
2004-12-20 Matthias Clasen <mclasen@redhat.com>
Thu Jan 22 14:51:19 2004 Owen Taylor <otaylor@redhat.com>
* glib/glib-sections.txt glib/tmpl/timers.sgml: Document
- g_timer_continue. (Tim-Philipp Müller)
+ g_timer_continue. (Tim-Philipp M??ller)
Sun Jan 11 01:25:44 2004 Matthias Clasen <maclas@gmx.de>
Sun Oct 19 22:18:28 2003 Matthias Clasen <maclas@gmx.de>
* gobject/Makefile.am (INCLUDES): Add $(top_builddir)/glib
- as an include dir. (#124934, Mariano Suárez-Alvarez)
+ as an include dir. (#124934, Mariano Su??rez-Alvarez)
Sun Oct 19 00:33:28 2003 Matthias Clasen <maclas@gmx.de>
you have to register a non-instantiable classed type which derives from
<type><link linkend="GTypeInterface">GTypeInterface</link></type>. The following piece of code declares such an interface.
<programlisting>
-#define MAMAN_IBAZ_TYPE (maman_ibaz_get_type ())
-#define MAMAN_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_IBAZ_TYPE, MamanIbaz))
-#define MAMAN_IBAZ_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), MAMAN_IBAZ_TYPE, MamanIbazClass))
-#define MAMAN_IS_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_IBAZ_TYPE))
-#define MAMAN_IS_IBAZ_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MAMAN_IBAZ_TYPE))
-#define MAMAN_IBAZ_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MAMAN_IBAZ_TYPE, MamanIbazClass))
+#define MAMAN_IBAZ_TYPE (maman_ibaz_get_type ())
+#define MAMAN_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_IBAZ_TYPE, MamanIbaz))
+#define MAMAN_IS_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_IBAZ_TYPE))
+#define MAMAN_IBAZ_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MAMAN_IBAZ_TYPE, MamanIbazInterface))
typedef struct _MamanIbaz MamanIbaz; /* dummy object */
-typedef struct _MamanIbazClass MamanIbazClass;
+typedef struct _MamanIbazInterface MamanIbazInterface;
-struct _MamanIbazClass {
+struct _MamanIbazInterface {
GTypeInterface parent;
void (*do_action) (MamanIbaz *self);
<programlisting>
void maman_ibaz_do_action (MamanIbaz *self)
{
- MAMAN_IBAZ_GET_CLASS (self)->do_action (self);
+ MAMAN_IBAZ_GET_INTERFACE (self)->do_action (self);
}
</programlisting>
<function>maman_ibaz_get_gtype</function> registers a type named <emphasis>MamanIBaz</emphasis>
baz_interface_init (gpointer g_iface,
gpointer iface_data)
{
- MamanIbazClass *klass = (MamanIbazClass *)g_iface;
- klass->do_action = maman_baz_do_action;
+ MamanIbazInterface *iface = (MamanIbazInterface *)g_iface;
+ iface->do_action = maman_baz_do_action;
}
GType
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
- sizeof (MamanBazClass),
+ sizeof (MamanBazInterface),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_init */
multiple implementations of the interface:
<programlisting>
static void
-maman_ibaz_base_init (gpointer g_class)
+maman_ibaz_base_init (gpointer g_iface)
{
static gboolean initialized = FALSE;
#include <glib-object.h>
-#define MAMAN_TYPE_IBAZ (maman_ibaz_get_type ())
-#define MAMAN_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_IBAZ, MamanIbaz))
-#define MAMAN_IBAZ_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), MAMAN_TYPE_IBAZ, MamanIbazClass))
-#define MAMAN_IS_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_IBAZ))
-#define MAMAN_IS_IBAZ_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MAMAN_TYPE_IBAZ))
-#define MAMAN_IBAZ_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MAMAN_TYPE_IBAZ, MamanIbazClass))
+#define MAMAN_TYPE_IBAZ (maman_ibaz_get_type ())
+#define MAMAN_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_IBAZ, MamanIbaz))
+#define MAMAN_IS_IBAZ(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_IBAZ))
+#define MAMAN_IBAZ_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), MAMAN_TYPE_IBAZ, MamanIbazInterface))
typedef struct _MamanIbaz MamanIbaz; /* dummy object */
-typedef struct _MamanIbazClass MamanIbazClass;
+typedef struct _MamanIbazInterface MamanIbazInterface;
-struct _MamanIbazClass {
+struct _MamanIbazInterface {
GTypeInterface parent;
void (*do_action) (MamanIbaz *self);
which derives from a <type><link linkend="GObject">GObject</link></type> except for a few details:
<itemizedlist>
<listitem><para>
- The <function>_GET_CLASS</function> macro is not implemented with
- <function>G_TYPE_INSTANCE_GET_CLASS</function> but with <function>G_TYPE_INSTANCE_GET_INTERFACE</function>.
+ The <function>_GET_CLASS</function> macro is called <function>_GET_INTERFACE</function>
+ and not implemented with <function><link linkend="G_TYPE_INSTANCE_GET_CLASS">G_TYPE_INSTANCE_GET_CLASS</link></function>
+ but with <function><link linkend="G_TYPE_INSTANCE_GET_INTERFACE">G_TYPE_INSTANCE_GET_INTERFACE</link></function>.
</para></listitem>
<listitem><para>
The instance type, <type>MamanIbaz</type> is not fully defined: it is used merely as an abstract
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
- sizeof (MamanIbazClass),
+ sizeof (MamanIbazInterface),
maman_ibaz_base_init, /* base_init */
NULL, /* base_finalize */
NULL, /* class_init */
void maman_ibaz_do_action (MamanIbaz *self)
{
- MAMAN_IBAZ_GET_CLASS (self)->do_action (self);
+ MAMAN_IBAZ_GET_INTERFACE (self)->do_action (self);
}
</programlisting>
</para>
baz_interface_init (gpointer g_iface,
gpointer iface_data)
{
- MamanIbazClass *klass = (MamanIbazClass *)g_iface;
- klass->do_action = (void (*) (MamanIbaz *self))baz_do_action;
+ MamanIbazInteface *iface = (MamanIbazInteface *)g_iface;
+ iface->do_action = (void (*) (MamanIbaz *self))baz_do_action;
}
static void
baz_instance_init (GTypeInstance *instance,
gpointer g_class)
{
- MamanBaz *self = (MamanBaz *)instance;
+ MamanBaz *self = MAMAN_BAZ(instance);
self->instance_member = 0xdeadbeaf;
}
</programlisting>
ibar_interface_init (gpointer g_iface,
gpointer iface_data)
{
- MamanIbarClass *klass = (MamanIbarClass *)g_iface;
- klass->do_another_action = (void (*) (MamanIbar *self))ibar_do_another_action;
+ MamanIbarInterface *iface = (MamanIbarInterface *)g_iface;
+ iface->do_another_action = (void (*) (MamanIbar *self))ibar_do_another_action;
}
ibaz_interface_init (gpointer g_iface,
gpointer iface_data)
{
- MamanIbazClass *klass = (MamanIbazClass *)g_iface;
- klass->do_action = (void (*) (MamanIbaz *self))ibaz_do_action;
+ MamanIbazInterface *iface = (MamanIbazInterface *)g_iface;
+ iface->do_action = (void (*) (MamanIbaz *self))ibaz_do_action;
}
static const GInterfaceInfo ibar_info = {
(GInterfaceInitFunc) ibar_interface_init, /* interface_init */
NULL, /* interface_finalize */
- NULL /* interface_data */
+ NULL /* interface_data */
};
static const GInterfaceInfo ibaz_info = {
(GInterfaceInitFunc) ibaz_interface_init, /* interface_init */
no prerequisites and then on the others.
</para>
- <para>
- Complete source code showing how to define the MamanIbar interface which requires MamanIbaz and how to
- implement the MamanIbar interface is located in <filename>sample/interface/maman-ibar.{h|c}</filename>
- and <filename>sample/interface/maman-bar.{h|c}</filename>.
- </para>
+ <para>
+ Complete source code showing how to define the MamanIbar interface which requires MamanIbaz and how to
+ implement the MamanIbar interface is located in <filename>sample/interface/maman-ibar.{h|c}</filename>
+ and <filename>sample/interface/maman-bar.{h|c}</filename>.
+ </para>
</sect1>
<para>To include a property named 'name' of type <type>string</type> in the
<type>maman_ibaz</type> interface example code above, we only need to add one
<footnote>
- <para>That really is one line extended to six for the sake of clarity
- </para>
+ <para>
+ That really is one line extended to six for the sake of clarity
+ </para>
</footnote>
line in the <function>maman_ibaz_base_init</function>
<footnote>
- <para>The gobject_install_property can also be called from <function>class_init</function> but it must not be called after that point.
- </para>
+ <para>
+ The <function><link linkend="g-object-interface-install-property">g_object_interface_install_property</link></function> can also be called from
+ <function>class_init</function> but it must not be called after that point.
+ </para>
</footnote>
as shown below:
<programlisting>
static void
-maman_ibaz_base_init (gpointer g_class)
+maman_ibaz_base_init (gpointer g_iface)
{
static gboolean initialized = FALSE;
if (!initialized) {
/* create interface signals here. */
- g_object_interface_install_property (g_class,
+ g_object_interface_install_property (g_iface,
g_param_spec_string ("name",
"maman_ibaz_name",
"Name of the MamanIbaz",