Re: how are interfaces created? (talking about the Java-like "interface")
- From: Ben Johnson <ben blarg net>
- To: Jean Br?fort <jean brefort normalesup org>
- Cc: gtk-list gnome org
- Subject: Re: how are interfaces created? (talking about the Java-like "interface")
- Date: Sat, 29 Jan 2005 10:10:17 -0800
On Sat, Jan 29, 2005 at 08:27:55AM +0100, Jean Br?fort wrote:
> Le vendredi 28 janvier 2005 ?? 15:22 -0800, Ben Johnson a ??crit :
> > I want to understand how interfaces are defined and used/implemented.
...
>
> It's a GInterface object. When creating a new class of object, you
> derive it from an existing class and you can add one or several
> interfaces to enrich your class.
> Here is a sample code I used to add printing support to the gnome canvas
> (this code is used by GChemPaint).
>
> GType
> gnome_canvas_group_ext_get_type (void)
> {
> static GType group_ext_type;
>
> if (!group_ext_type) {
> static const GTypeInfo object_info = {
> sizeof (GnomeCanvasGroupExtClass),
> (GBaseInitFunc) NULL,
> (GBaseFinalizeFunc) NULL,
> (GClassInitFunc) gnome_canvas_group_ext_class_init,
> (GClassFinalizeFunc) NULL,
> NULL, /* class_data */
> sizeof (GnomeCanvasGroupExt),
> 0, /* n_preallocs */
> (GInstanceInitFunc) gnome_canvas_group_ext_init,
> NULL /* value_table */
> };
>
> static const GInterfaceInfo print_info = {
> (GInterfaceInitFunc) gnome_canvas_group_print_init,
> NULL, NULL
> };
>
> group_ext_type = g_type_register_static (GNOME_TYPE_CANVAS_GROUP_EXT,
> "GnomeCanvasGroupExt",
> &object_info, 0);
>
> g_type_add_interface_static (group_ext_type, G_TYPE_PRINTABLE,
> &print_info);
> }
>
> return group_ext_type;
> }
>
> Hope this helps,
It does help *very* much. Thank you. I hope you don't answering a
couple questions.
Once an object of GnomeCanvasGroupExtClass is instantiated, can it be
cast as something else having to do with the print_info (Printable?)?
How is that done? And, when the cast is performed, what functionality
is exposed?
Thanks a lot!
- Ben
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]