Re: [gtk-list] Re: Datalists in GtkTypes
- From: Dominic Ludlam <dom recoil org>
- To: <gtk-list redhat com>
- Subject: Re: [gtk-list] Re: Datalists in GtkTypes
- Date: Tue, 02 May 2000 23:48:03 +0100
Quoting Jon Trowbridge <trow@emccta.com>:
> On Tue, May 02, 2000 at 10:22:49PM +0100, Dominic Ludlam wrote:
> > I would like to be able to associate arbitrary data
> > with GtkTypes for the equivalent of static data members
> > in C++ classes.
>
> It depends on what you are trying to do, I guess.
>
> If you want specific "static data" to be associated with classes that
> you are defining, you'd add it to the class struct. i.e.
>
> struct GtkFoo {
> GtkBase base;
> };
>
> struct GtkFooClass {
> GtkBaseClass base_class;
> gchar* my_static;
> gint more_static;
> gpointer even_more_static;
> };
>
> If you want to attach arbitrary data to arbitrary types (including
> existing types), why not make a GHash of GHashed, keyed on GtkTypes
> and identifying strings.
>
> If you explain exactly what you are trying to do, we may be able to
> offer better advice...
>
I want to add data to existing types. I don't really want the overhead
of calling gtk_object_set_data_by_id for every object I create because
the data only needs to be associated on a type level instead of an
object level. Something like a gtk_object_class_set_data or a
gtk_type_set_data_by_id would be ideal.
This is for a cross platform user interface library I'm writing for the
OpenFX project. The library has a slightly different way of specifying
event callbacks to GTK and I need to put a pointer to a function which
translates the OpenFX event enumeration and the GTK signal names. This
needs to be done on a per type level because each widget will trigger
different events.
I had a look at the gtk_object_class_user_signal_new function. This
*almost* does what I want, except I still have to connect to the signal
on a per object level, which I shouldn't have to.
I will make a GHash on the types it there is no existing way of doing
this. In this case, I don't need the strings because I only need to
associate one pointer with each existing type.
Dom.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]