Re: custom widget



On Tue, 2006-09-26 at 19:08 -0700, Mark Richardson wrote:
> Sorry about posting in the gtk dev area, but this is borderline app
> dev/gtk dev.
>  
> Anyway, I'm making a custom widget, and when I try to create a
> signal...
> signals[MOVE_CURSOR]=g_signal_new("move_cursor",
> G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_LAS |
> G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkLabel2Class, move_cursor), NULL,
> NULL, _gtk_marshal_VOID__ENUM_INT_BOOLEAN, G_TYPE_NONE, 3,
> GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN)
>  
> I get the message..
> (CustomWidget:3960): Glib-GObject-WARNING **: cannot register existing
> type 'GtkMovementStep'
>  
> so digging into the source, I find out that if I make a call to
> gtk_movement_step_get_type(), I will get this warning every time.
>  
> I found the code in gtktypebuiltins.c for
> gtk_movement_step_get_type(), and it seems that the etype is always 0.
> So it keeps trying 
> g_enum_register_static (g_intern_static_string("GtkMovementStep"),
> values)
>
> Which generates the message.

Likely cause is linking to multiple copies of GLib or GTK+.
 
> I'm having lots of problems porting my old custom widgets (from gtk
> 2.8 - maybe 2.4 - don't really remember) to gtk 2.10 because of all of
> the private functions (performing an nm on the library shows that the
> function is local and not global).  I also can't find any good custom
> widget examples that are friendly with 2.10 (except for the gtkdial in
> the examples).  If anyone can help me with this, I would gladly post
> my 4 custom widgets up for examples for others (once I get them
> working).  I tried taking the gtklabel widget and renaming it and all
> the functions to gtklabel2 - so as to simulate a correctly written
> widget for 2.10.  I get so many errors with this, so I must not be
> doing something right.

Most of the more complicated widgets inside of GTK+ are not compilable
outside of GTK+, because they use internal GTK+ only API. That doesn't
mean that you can't write sophisticated, full-featured custom widgets
using the public API of GTK+. But we don't want to make eternal
compatibility guarantees for every convenience function, or experimental
API.

And certainly not generated marshalers like 
_gtk_marshal_VOID__ENUM_INT_BOOLEAN - you are supposed to run 
glib-genmarshal yourself with you own namespace prefix.

We haven't removed anything from the public GTK+ since at least 2.0.0.
With early versions of GTK+-2.x you may have been able to access
symbols starting with _gtk_ when linking against GTK+, but it was
made clear that those functions were not part of the GTK+ API.

						- Owen





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]