comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: help building ada with glade
Date: Sat, 25 Feb 2012 10:06:40 +0100
Date: 2012-02-25T10:06:40+01:00	[thread overview]
Message-ID: <1rlxflx3vn7d2$.gwfur2yxe3we.dlg@40tude.net> (raw)
In-Reply-To: ji95g5$g2n$1@dont-email.me

On Sat, 25 Feb 2012 00:12:06 +0100, J-P. Rosen wrote:

> Le 24/02/2012 09:39, Dmitry A. Kazakov a �crit :
>> I doubt that code generated by GLADE illustrates issues essential for
>> dealing with GTK: objects (GObject), values (GValue), signals, containers
>> (packing), MVC (in trees, combos, text buffers).
> Exactly. Glade protects me from all that complicated mess. If I want an
> action on button pressed, I select the action in Glade, and I just have
> to fill the body of a subprogram named On_Key_Pressed. 

Do you really mean the "key-press-event"? [*] I presume you rather did
"clicked" event from a button widget. If GUI consisted of only buttons,
then you would need no GLADE to design such simple thing.

> You may argue
> that I don't learn the intrinsics of Gtk this way, fine, but I prefer
> not to have to.

I would argue that this nasty stuff need to be learnt in order to design
GTK applications.

>> I don't believe that a GUI project can be assisted with GLADE, which
>> presumes its ability to incorporate user made modifications of the
>> generated code. GTK is simply unsuitable for this. It is too low level, too
>> messy. It lacks any means to separate the UI from the semantics. Ergo, no
>> need to look into any generator (I admit, I don't know GLADE well), none
>> can be good for GTK.
>> 
> Please use it first.

Not much different from MS GUI builder, which I long ago ceased to use for
same reasons I never used GLADE. One lesson was enough.

> A nice thing with Glade is precisely that the
> semantics is well separated from all the glue, and (on Linux at least)
> it is able to make round-trip engineering (i.e. : if you add stuff to
> what has been generated, it is not lost the next time you regenerate
> your interface).

But it is impossible to do due to GTK design [**]. The most typical and
safe pattern for handling signals is that a composite widget connects to a
signal of its child and passes itself as a parameter to the signal handler,
because you need to know it in the handler. For this
Gtk.Handlers.User_Callback must be instantiated. I have no idea how a code
generator could deal with this in the round-trip manner.

I presume that GLADE rather uses strictly static forms when each composite
widget has just one instance and all callbacks are statically bound to just
one instance of the emitter and one recipient.

I never use such design, even if it appears sufficient at first glance,
e.g., as you said, for a casual GUI.

My advice for the beginners is to learn to use GtkAda in a different way
and as early as possible. That is when any widget is designed to have
multiple instances and be usable as a child of any container. For each
widget a corresponding Ada type is derived from some base GTK container
(like Gtk_Table_Record). The children are kept hidden as well as handlers
of their signals. I.e. widgets are kept opaque.

--------
* Handing "key-press-event" is far from trivial in GTK. They are not
emitted at all, by default, as well as the "key-release-event" signal. To
handle these signals the application must modify the Gdk_Event_Mask of the
widget using Set_Events, with far reaching consequences for some widgets.

** Though handling signals is important one needs much more to know how to
use GTK.

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



  reply	other threads:[~2012-02-25  9:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 23:43 help building ada with glade Patrick
2012-02-23  8:44 ` Dmitry A. Kazakov
2012-02-23  9:58   ` Patrick
2012-02-24  5:53   ` J-P. Rosen
2012-02-24  8:39     ` Dmitry A. Kazakov
2012-02-24 23:12       ` J-P. Rosen
2012-02-25  9:06         ` Dmitry A. Kazakov [this message]
2012-02-26  6:55           ` J-P. Rosen
2012-02-26  8:36             ` Dmitry A. Kazakov
2013-09-07 20:37               ` Patrick
2013-09-10  6:40           ` briot.emmanuel
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox