Hi all. I have some questions how to properly design the flow of an GTK application. To describe my question a little bit better i try to show off my current design:
The arrows are basically references. An Application knows about a Window and vice verse. The Window has a ref to all childs.
My question is how to properly design a click on a row of that listbox (which triggers the activate signal) which should magically trigger some machinery which does the following:
- activate the stack and bring the ArticlePage in front
- show some buttons in the headerbar and hide some buttons there
- load the article with the data item as parameter
In an ideal world i would use the GAction machinery in GTK because this would allow me to decouple the logic of specific flows in my application. The activated row echoes into the application show_page and bubbles the widget hierarchy upwards till some widget has registered this action. The problem: i cannot have GObject parameters for that. My data item is therefore useless.
On the other hand it would be possible if i have backward references to the Window and have the functionality called directly. My problem with that approach is that i have cyclic references in my code which could be a problem during disposing these objects. Another idea would be a weak reference then but this feels wrong from an architecture point of view.
Third idea which came into my mind was to have some sort of controller object which has references to all involved GUI elements like that:
I often think about this specific problem in general. What i really want is some sort of loose coupling of all involved elements to be able to rearrange everything when i want to do that. The ListBox should emit a signal/action/whatever, the page has a function to load a page when i give him an data item and a mediator should connect these for now. If i want to rearrange this later i just have to change the mediator, not the involved GUI elements. Maybe some of you have more experience how to proper model a situation like that. I would be glad to hear about you.
Thanks in advance!