Re: Segfault with GnomeCanvasWidget, test case
- From: Aaron Lehmann <aaronl vitelus com>
- To: Damon Chaplin <damon helixcode com>
- cc: Detlef Reichl <detlef reichl arcormail de>, gnome-devel-list gnome org
- Subject: Re: Segfault with GnomeCanvasWidget, test case
- Date: Sun, 23 Jan 2000 20:34:41 +0000 (GMT)
Thank you very much for pointing this out! I had done a little more
playing with the canvas and came up with a theory that a widget without
its own X window would not draw in a canvas. It's nice to have that thory
verified. I don't know why I didn't think of using an event box for my
widgets that don't have X windows, but that idea makes a lot of sense.
Are there any plans to fix the canvas to accomadate widgets that draw onto
their parents? IMHO this irregularity should at least be documented (my
source for documentation was Havoc's book, my appologies if this is
already pointed out in the libgnomeui reference).
Thanks,
Aaron Lehmann
On Sat, 22 Jan 2000, Damon Chaplin wrote:
> Aaron Lehmann wrote:
> >
> > On Sat, 22 Jan 2000, Detlef Reichl wrote:
> >
> > > Am Sat, 22 Jan 2000 schrieb Aaron Lehmann:
> > > >>Hi,
> > > >
> > > >GnomeCanvasWidget has not been working for be at all. I have tried many
> > > >things but it always either segfaults or doesn't display anything. I have
> > > >attatched a simple program (compilation instructions in header) that
> > > >produces a segfault when run on my machine. Can anyone fix it or
> > > >gnome-libs so it doesn't segfault?
> > > >
> > > >Bonus: If you can get it to stop segfaulting, can you get it to actually
> > > >display the label?
> > > >
> > > >
> > > >Thanks,
> > > >Aaron Lehmann
> > > >
> > >
> > > item = gnome_canvas_item_new (group,
> > > gnome_canvas_widget_get_type(),
> > > "widget", widget,
> > > "x", 0.0, /*double*/
> > > "y", 40.0, /*double*/
> > > "anchor", GTK_ANCHOR_NORTH_WEST,
> > > "width", 500.0, /*double*/
> > > "height", 500.0, /*double*/
> > > "size_pixels", TRUE,
> > > NULL);
> > >
> > > position and width are double format so they need the '.0'
> > > on end.
> >
> > Thanks, that fixes the segfault. But the label still does not appear.
>
>
> You have 2 problems here:
>
> 1) Widgets without windows (i.e. GtkLabel) will not work in a
> GnomeCanvasWidget, since they draw onto their parent window (the canvas),
> and will be painted over when the canvas does all its normal
> buffered drawing. You can use a GtkEventBox and place the label in that.
>
> 2) There is a bug in GnomeCanvas which affects GnomeCanvasWidget items
> (in 1.0.53 at least). When the canvas gets a "draw" signal it should
> pass it on to the GnomeCanvasWidget widgets, but it doesn't, which
> means that sometimes the widgets don't appear.
> (I think all GnomeCanvas needs to do to fix this is call the parent
> GtkLayout class draw function within its own draw function. I hope
> Federico is reading this!)
>
> You can work around the problem with code like this:
>
>
> gtk_signal_connect (GTK_OBJECT (day_view->top_canvas), "draw",
> GTK_SIGNAL_FUNC (e_day_view_on_canvas_draw),
> day_view);
>
>
> /* This is a workaround for a bug in GnomeCanvas. It does not pass on draw
> events to widgets in GnomeCanvasWidget items, so we do it here. */
> static void
> e_day_view_on_canvas_draw (GtkWidget *widget,
> GdkRectangle *area,
> EDayView *day_view)
> {
> gtk_container_foreach (GTK_CONTAINER (widget),
> e_day_view_draw_child_widget, area);
> }
>
>
> static void
> e_day_view_draw_child_widget (GtkWidget *child_widget,
> gpointer data)
> {
> GdkRectangle *area = data;
> GdkRectangle child_area;
>
> if (gtk_widget_intersect (child_widget, area, &child_area))
> gtk_widget_draw (child_widget, &child_area);
> }
>
>
> Damon
>
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]