[gtkada] adding and removing widgets in a container

Preben Randhol randhol at pvv.org
Thu Nov 29 14:00:14 CET 2001


Emmanuel Briot <briot at ACT-Europe.FR> wrote on 29/11/2001 (12:33) :
> Preben Randhol <randhol at pvv.org> writes:
> 
> > I did this too with frames that had a content in them, but I got a
> > problem. If I pressed a button in the frame and this resulted in the
> > frame being removed, I noticed that when I later Added the frame the
> > button was still highlighted. It doesn't seem to be a solution to this
> > as I didn't get any answers even on the Gtk+ mailinglist on how to solve
> > this problem. So I went back to simply destroying the widget and creating
> > a new every time I need it.
> 
> 
> Just thinking of it now: have you tried to just destroy the button instead of
> the whole frame ?

It is easier to destroy the whole frame because I have defined it like
this:

   package Setup is

      type Gui_Setup_Record is new Gtk_Frame_Record with record
      --- ...

   private
      Gui_Setup            : Gui_Setup_Access;
   end Setup;

and I had a function like this:

   function Get_Gui return Gtk_Widget is
   begin
      if Gui_Setup = null then
         Gtk_New (Gui_Setup);
         Ref (Gui_Setup);  -- Ref so the widget will not be destroyed
                           -- by Remove
      end if;
      return Gtk_Widget (Gui_Setup);
   end Get_Gui;

I do this for all the different pacakges, Welcome, Setup, Examine,
Results etc... and then I just pack the whole frame in the Window.

> You could also try to send a "leave_notify" event to the button, to change its
> state. I guess it would work, but I am not sure why this event wasn't sent
> automatically by the Xserver.

but I can try the leave_notify, just have to read up on how one send a
signal to a button first :-). Perhaps the button didn't get the signal
because of the Remove?

Preben
-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list