Re: [gtk-list] Re: Interpreter requests
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- cc: Kenneth Albanowski <kjahds kjahds com>, Vollmer Marius <mvo zagadka ping de>
- Subject: Re: [gtk-list] Re: Interpreter requests
- Date: Tue, 9 Jun 1998 10:00:02 +0200 (CEST)
On Tue, 9 Jun 1998, Kenneth Albanowski wrote:
> On Tue, 9 Jun 1998, Tim Janik wrote:
>
> > > Looks good to me. The only thing I'd want to add would be a hook to type
> > > creation, so that I can be notified whenever a new enum is added to the
> > > system, giving me a chance to read its values and add it to my management
> > > system.
> >
> > all enums are created with gtk_type_init () which is called from gtk_init();
>
> Are you sure enums cannot be created at run-time? I assure you that I'll
> try, regardless of your intentions. :-) (Come to that, authors of external
> widgets will be doing this, regardless.)
yep, sure you can, but i guess nobody does yet. out of my mind the code should
look like:
typedef enum
{
FOO_ENUM_ONE,
FOO_ENUM_TWO
} FooEnum;
static GtkEnumValue foo_enum_values[] =
{
{ FOO_ENUM_ONE, "FOO_ENUM_ONE", "one" },
{ FOO_ENUM_TWO, "FOO_ENUM_TWO", "two" },
{ 0, NULL, NULL },
};
#define TYPE_FOO_ENUM (foo_enum_get_type ())
GtkType
foo_enum_get_type (void)
{
static GtkType foo_enum_type = 0;
if (!foo_enum_type)
{
GtkTypeInfo foo_enum_info =
{
"FooEnum",
0,
0,
(GtkClassInitFunc) NULL,
(GtkObjectInitFunc) NULL,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
};
foo_enum_type = gtk_type_unique (GTK_TYPE_ENUM_TYPE, &foo_enum_info);
gtk_type_enum_set_values (foo_enum_type, foo_enum_values);
}
return foo_enum_type;
}
>
> I'm thinking of something like this:
>
> typedef void (*GtkTypeCreationHook)(GtkType new_type);
>
> gtk_type_add_creation_hook(GtkTypeCreationHook * hook);
>
> When this function is invoked, it'll immediately call the hook function
> with all present types (including these ever-so-interesting enums), and
> then also invoke it when new types are added with gtk_type_unique().
well as you can see from the above, the enum values are set *after*
gtk_type_unique() has been set (that is because i didn't want to further extend
the GtkTypeInfo structure). so you will actually need two hooks.
but i'd like to see someone sum up what kind off hooks are needed and for
what reason, before jumping into the code and adding plain callback functions
all over the place.
>
> --
> Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]