[gtkada] Images do not move with widget

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Sun Jul 12 13:15:48 CEST 2009


On Sun, 12 Jul 2009 18:32:58 +0800, you wrote:

> Thanks Dmitry.  I found that my application would have the arrow images in
> the buttons _if_ I copied the image folder from the Keypad development
> folder into the Application development folder.  That meant that the image
> was not embedded in the button so back to the brewing board.
> 
> I now have  Key_Button defined as the private type:
[...]
> By my reckoning, line 62 allocates memory to Image_Access.  Line 63 copies
> the data from the memory addressed by the parameter Image to the memory
> addressed by Image_Access. 

No it does not. Image data can be allocated on the server or client side of
the rendering system. Independently on that your code merely copies Ada
proxy object. For further information see GDK pixbuf:

   http://library.gnome.org/devel/gdk-pixbuf/2.16

Images shall be created using Gtk_New and never copied.

> Still at square one.  Why does my image not travel with the button?  The
> label allocated to the button in the same box travels okay.

You should first answer the question where comes the image from. Is it a
file, an icon factory, or an embedded image. If it is a file, the file path
used in Gtk_New should be valid to the time of call. If it is an icon
factory the factory should be available for the program. For embedded
images see:

   http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#3

You create an XPM image file using GIMP, for example. Once you have it
(x.xpm), you can convert it into Ada code using the xpm2ada utility. That
will give you three files x.ads, x-image.ads, x-image.adb. You bind them to
your project and use the function X.Image in your program, each time you
need a Gtk_Image object.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list