[gtkada] GtkBuilder in GtkAda?

ter Vehn Robert robert.tervehn at saabgroup.com
Thu Jun 25 08:34:52 CEST 2009


Hi,

Thanks for the response. I've started experiencing some but have a question on what the "preferred GtkAda way" is.

I'm binding the C function which is declared as:
guint gtk_builder_add_from_file (GtkBuilder *builder, const gchar *filename, GError **error);

The function returns a 'guint' which is 0 on error, otherwise a positive 'guint', although having two "error flags" seems unnecessary (return value and error pointer).

How would the corresponding GtkAda procedure/function declaration look? 
A straightforward translation could be (package Gtk.Builder):
function Add_From_File (Builder : Gtk_Builder; Filename : String; Error : Glib.GError.GError_Access) return Glib.Guint;

Should I use exceptions in case of an error? Another option is to return null on a successful call, i.e.:
function Add_From_File (Builder : Gtk_Builder; Filename : String) return Glib.Error.GError;

What way corresponds best with the ideas behind GtkAda?

For clarification, the Gtk_Builder type is:
type Gtk_Builder_Record is new Glib.Object.GObject_Record with private;
type Gtk_Builder is access all Gtk_Builder_Record'Class;
private:
  type Gtk_Builder_Record is new Glib.GObject.GObject_Record with null record;

Kind Regards
Robert ter Vehn

-----Original Message-----
From: Arnaud Charlet [mailto:charlet at adacore.com] 
Sent: den 24 juni 2009 09:50
To: ter Vehn Robert
Cc: gtkada at lists.adacore.com
Subject: Re: [gtkada] GtkBuilder in GtkAda?

> Do You think it would require lots of work creating such a binding?

I haven't looked at the GtkBuilder API, so can't really comment.
I'd guess it's not a trivial binding, but creating bindings in general is
not rocket science.

> Do You have any advice documentation describing how to create GTK bindings?

I'd suggest looking at how other APIs have been bound by looking at existing
gtk-*.ad{s,b} files.

Arno



More information about the gtkada mailing list