[gtkada] Surprised by the changes to GTK 3.0

Emmanuel Briot briot at adacore.com
Mon Jul 1 16:05:49 CEST 2013


> 1. RC files are gone. CSS is the replacement which lacks a good deal of
> features RC files had. E.g. stock images. BTW, Gtk promptly crashes on an
> attempt to load a non-existent CSS file.

They have separated icon themes and color/font themes, which I think is a good
thing. CSS files are honestly easier to understand than the RC files I think.
To load custom CSS Files, I recommend Gtkada.Style.Load_Css_File, which
does not crash if you try to load an non-existing CSS file.

> 3. "size-request" signal is gone. If your custom widget needs resizing that
> has to be reworked completely. There is new "configure-event" for that.
> Unfortunately it is impossible to catch in some cases, even with
> Gtk_Event_Box added and various event masks set.

The new width-for-height sizing (as they call it) is in fact *much* nicer, although
the transition is indeed a bit of work.

If your custom widget requires its own size management, I recommend the
following approach:
    - create your own class record (Glib.Object.Initialize_Class_Record).
    - when the latter returns True, you can then override the default size handlers
      for your widget through Gtk.Widget.Set_Default_Size_Handler. That allows
      you to specify an ideal and a minimum size.

> 4. Gtk_Object is gone. All custom widgets derived from it must be
> redesigned.

Replace Gtk_Object with GObject, and done.

> 5. There is no more messages loop quit handler. You should move cleanup to
> the application window or a widget.

I have never used that in fact. I would be curious where you needed that ? The
only time where you create your own even loop, in my experience, is for modal
dialogs, and then Gtk.Dialog.Run does most of the work for you already.

> 6.a It made many things tagged, but for reasons I don't understand it does
> not use Ada 2005 interfaces. As the result in old code you will have to add
> a lot of explicit conversions which weren't needed before. E.g.

Reason is for backward compatibility and for those people who do not want to
move to Ada05 (and there are plenty of them). Also Ada interfaces are a
different beast from the Glib interfaces altogether.

There are indeed extra conversions needed in some cases for the tree models
(which, really, is the only interface that most users will ever explicitly manipulate).

Since all of GtkAda (almost) is now automatically generated, you can have a go
at the (complex) python files to generate something else, of course.

> 6.b. Initialization of widgets, their classes are slightly different, yet
> enough different to break all custom widgets which register their own
> classes and properties.

Yes, we took the opportunity of the major changes in gtk+ to also clean up
some of GtkAda. The new approach is more in line with the C version, since you
manipulate the class record to add properties to it, not one of its instances, which
had a number of drawbacks.

> 6.c. Signal handlers must be library level. Of course, this is not a
> problem for a real-life project. But if you are accustomed writing small
> single-file unit tests, you should either split them into multiple files or
> else do ugly Unchecked_Conversions to work around accessibility checks.

This has *always* been the case, since the first event handler I wrote back in 1998.
And this is unavoidable, since we need to go through one extra level of indirection
to convert the C types to the Ada types, so this extra subprogram must remain
valid while the signal is connected.

Emmanuel


More information about the gtkada mailing list