Re: Interfaces and properties, signals
- From: jrb redhat com
- To: Tim Janik <timj gtk org>
- Cc: Bill Haneman <bill haneman ireland sun com>, Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: Interfaces and properties, signals
- Date: 22 Mar 2001 11:52:04 -0500
Tim Janik <timj gtk org> writes:
> On Mon, 12 Mar 2001, Bill Haneman wrote:
>
> > Hi Tim:
>
> > I've come across a use case with GTypeInterface that I can't seem to
> > find an example of, and wonder if you could answer a couple of
> > questions.
> >
> > We have two properties ("accessible_text" and "caret") and a signal
> > ("caret_moved") that we'd like to associate with implementors of a
> > particular interface (AtkTextIface).
> >
> > Two questions come to mind:
> >
> > 1) Is it possible to register properties and signals on interface
> > classes?
> > 2) Is there a clean way of doing it ;-)
>
> yes and no ;)
> as owen already outlined, we decided against per-interface properties,
> at least for 2.0, because it isn't at all obvious how to do that.
> for signals, yes, they should run fine on interfaces, you basically
> do the the same way you do them on a normal class (i believe jonathan
> even uses interface signals already in his tree backends).
I do. One of the peculiarities of interface signals is that there is no
really good place to set the signals up. I've been using the base_init
slot to do so, which is called multiple times, so I have the following
code:
static void
gtk_tree_model_base_init (gpointer g_class)
{
static gboolean initialized = FALSE;
if (! initialized)
{
/* set up signals... */
initialized = TRUE;
}
}
GtkType
gtk_tree_model_get_type (void)
{
static GtkType tree_model_type = 0;
if (! tree_model_type)
{
static const GTypeInfo tree_model_info =
{
sizeof (GtkTreeModelIface), /* class_size */
gtk_tree_model_base_init, /* base_init */
NULL, /* base_finalize */
};
tree_model_type = g_type_register_static (G_TYPE_INTERFACE, "GtkTreeModel", &tree_model_info, 0);
g_type_interface_add_prerequisite (tree_model_type, G_TYPE_OBJECT);
}
return tree_model_type;
}
Hope this helps,
-Jonathan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]