Re: bug in gtk-- ?



Havoc Pennington wrote:

> On Tue, 29 Sep 1998, Andrew V. Shuvalov wrote:
> > Hi!  I have a problem with recent cvs Gtk-- and gtk+-1.1.2-1:
> > This bug was not here before, i mean i did not changed my code.
> > I have a subclass from Gtk_Button. And when i am in constructor,
> > GTK_WIDGET( gtkobject )->window is still NULL. My code:
> >
>
> window isn't guaranteed to exist until the object is realized. It may
> exist, but there is no guarantee.

Thanks. In fact, window is not needed. My final code is:

Gtk_ImageTextButton::Gtk_ImageTextButton( const char *xpmpath,
       const char *label )
{
  Gtk_VBox *vbox_layout = new Gtk_VBox();
  vbox_layout->show();
  add( vbox_layout );

  Gtk_Pixmap *pixmapwid = new Gtk_Pixmap( vbox_layout, xpmpath );
  pixmapwid->show();
  vbox_layout->pack_start( pixmapwid, FALSE, FALSE, 0 );

  Gtk_Label *labelwid;
  if( strlen( label ) )
    {
      labelwid = new Gtk_Label( label );
      labelwid->show();
      vbox_layout->pack_start( labelwid, FALSE, FALSE, 0 );
    }
}



>
>
> You can either force realize, or do your drawing at a later time, after
> realization. For drawing areas the easiest thing is to override
> configure_event_impl. For buttons you aren't really meant to be accessing
> the window, I don't think.
>
> Why not just add a child to the button, such as a drawing area or pixmap
> or label or whatever you want?
>
> Havoc
>
> --
>          To unsubscribe: mail gnome-list-request@gnome.org with
>                        "unsubscribe" as the Subject.

--
          Andrew





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