[gtkada] Help needed creating custom gtkada widget

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Mon Jan 11 18:45:30 CET 2016


On 2016-01-11 18:03, Brent Seidel wrote:
> Hello all,
>
> I may have bitten off more than I should chew at this point.  Most of my Ada experience was scattered through the 90s until I recently discovered the free GNAT and GPS tools.  I also haven’t used GTK before, but have done a bit of GUI programming on the Mac (classic and OS X).
>
> What I would like to do is to create a custom widget that displays a value using a dial.  I’ve been able to do the drawing on a Drawing_Area widget.  The problem comes when I try to bundle it up into its own widget.  I get the following results:
> **
> Gtk:ERROR:gtkwidget.c:12314:gtk_widget_real_realize: assertion failed: (!_gtk_widget_get_has_window (widget))
>
> Execution terminated by unhandled exception
> Exception name: PROGRAM_ERROR
> Message: unhandled signal
> Load address: 0x10148a000
> Call stack traceback locations:
> 0x1015529d5 0x7fff9251cf18
>
> This appears to happen when I make the call to    Gtk.Window.Show_All(temp);
>
> The spec for my widget is:
> with Ada.Text_IO;
> with Gtkada.Types;
> --use type Gtkada.Types.Chars_Ptr_Array;
> with Gtk.Main;
> with Gtkada.Builder;
> with Gtk.Widget;
> with Gtk.Misc;
> with Gtk.Level_Bar;
> with Gtk.Progress_Bar;
> with Gtk.Label;
> with Gdk.Window;
> with Glib;
> use type Glib.Gdouble;
> use type Glib.Gint;
> with Glib.Object;
> with Cairo;
> package bbs.widget.dial is
>
>     type bbs_dial_record is new Gtk.Misc.Gtk_Misc_Record with private;

There is Gtk_Drawing_Area_Record for that. Then you do widget and widget 
class initialization wrong.

The error reported tells that the widget does not have a window where 
you could draw. This is due to improper initialization.

>     
>
> I’m sure that there’s a bit of “cargo-cult” programming in there.  I’ve looked online to find tutorials and instructions, but they tend to be vague, incomplete, or incorrect.
>
> I would be really appreciative if someone could offer a bit of assistance (I expect that once I know the trick, it will seem obvious).
>
>
You can take a look how dial widgets are implemented in cairo here:

http://www.dmitry-kazakov.de/ada/aicwl.htm

Or you could simply assemble your dial from existing elements (layers) 
provided there.

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



More information about the gtkada mailing list