[gtkada] Changing the graphics on buttons

Grein, Christoph christoph.grein at eurocopter.com
Wed Jan 22 09:37:06 CET 2003


Hello,

I'm using GtkAda 1.3.8 on Windows 98.

I can set a button graphic with the following code:

  procedure Set_Button_Pixmap (Button : in  Gtk.Button.Gtk_Button;
                               XPM    : in  GtkAda.Types.Chars_Ptr_Array;
                               Graphic: out Gtk.Pixmap.Gtk_Pixmap) is
    Pixmap: Gdk.Pixmap.Gdk_Pixmap;
    Mask  : Gdk.Bitmap.Gdk_Bitmap;
  begin
    Gdk.Pixmap.Create_From_XPM_D (Pixmap, Get_Window (Button), Mask,
                                  Transparent => Gdk.Color.Null_Color,
                                  Data        => XPM);
    Gtk.Pixmap.Gtk_New (Graphic, Pixmap, Mask);          <-- is this here a
                                                             storage leak?
                                                             Do I have to
                                                             deallocate Pixmap
                                                             before leaving its
                                                             scope?
    Add (Button, Graphic);
  end Set_Button_Pixmap;

  Set_Button_Pixmap (Actual_Button, Some_XPM, Current_Graphic);

Now I wnat to repeatedly change the graphic on a certain button depending on 
some condition.

  Remove (Actual_Button, Current_Graphic);
  Set_Button_Pixmap (Actual_Button, Another_XPM, Another_Graphic);

The old graphic is removed, but the new one does not appear. What is wrong?




More information about the gtkada mailing list