From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GtkAda's "On_Edited"
Date: Mon, 30 May 2022 20:57:23 +0200 [thread overview]
Message-ID: <t7342i$1set$1@gioia.aioe.org> (raw)
In-Reply-To: ea3ce162-277d-487a-af19-8126892d2ef9n@googlegroups.com
On 2022-05-30 09:46, John Perry wrote:
>> On_* procedures are useless most of the time.
>
> I guess you mean in GtkAda?
Yes.
> I've found them invaluable in other contexts. If so, that's disappointing. To be fair, in the hours of reading on this I did notice that Gtk+ itself makes this difficult; the On_* procedures seem to be a GtkAda enhancement.
Yes, GtkAda adds a typed layer on top of untyped GTK signals.
> In the end I made it work with an On_* design, but it was your suggestion that helped! I used the second form of On_Edited and passed a TreeView in the slot. To get the model:
>
> Tree_View: Gtk_Tree_View := Gtk_Tree_View(Self);
> Model: Gtk_Tree_Model := Get_Model( Tree_View );
> Iter : Gtk_Tree_Iter := Get_Iter_From_String(Model, Path);
> Store: Gtk_List_Store := Gtk_List_Store( To_Object(Model) );
>
> Getting the rest wasn't too hard after I had that. What I hadn't understood at first was that the Model had to be converted from the Interface via the To_Object function.
If that is OK to you, but in production code you need a lot of stuff to
do in a handler, most of it is unrelated to the tree view. This is why a
custom widget is always advisable. Using a slot is a matter of taste/ I
never use slots and avoid run-time type conversions.
BTW, derived widgets is also a GtkAda feature, in GTK a derived widget
require a lot of work. In GtkAda they are trivial.
Typically in a renderer edit commit you would maintain undo/redo
buffers, change the active cell for smooth navigation, [un]gray/hide a
couple of buttons (like Save). Same goes with the buttons and basically
with all signals.
The design pattern you need to keep in mind is that a signal sent to a
visual element like renderer or button, logically, is rather sent to
some container widget a couple layers above. If you do not follow this
logic, you will have a very complicated fragile code.
> PS If anyone knows how to make the first form of On_Edited work, I'd be delighted to know.
The first form can be used with a static layout and global variables. (:-))
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2022-05-30 18:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 5:28 GtkAda's "On_Edited" John Perry
2022-05-30 6:47 ` Dmitry A. Kazakov
2022-05-30 7:46 ` John Perry
2022-05-30 18:57 ` Dmitry A. Kazakov [this message]
2022-06-01 3:18 ` John Perry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox