[gtkada] Help needed creating custom gtkada widget

Brent Seidel brentseidel at mac.com
Mon Jan 11 19:15:39 CET 2016


I have tried basing my widget on Gtk_Widget_Record and Gtk_Drawing_Area_Record and got the same results.

> On Jan 11, 2016, at 10:45 AM, Dmitry A. Kazakov <mailbox at dmitry-kazakov.de> wrote:
> 
> 
> 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’ve guessed that there was a problem with my initialization.  Unfortunately, I haven’t been able to find anything that says what needs to be done.  I’ve tried to combine some hints that I’ve found here and there.
> 
>>    
>> 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.

That is quite an impressive set of dials that you have there.  However using them won’t help me learn how to do it myself.  I’ve done the basic “Hello World” type stuff and am trying to move from complete novice to amateur.  It’ll be a while (if ever) before I make it to expert.

thanks,
brent



More information about the gtkada mailing list