Add shared interfaces for widget containers
With GTK4 the common container interface was removed and there were good reasons for that. Yet, it turned out to be useful for libraries that build upon GTK4 (in particular Relm4) to have a common interface for widgets that act as containers for other widgets. As a temporary solution, Relm4 has implemented these interfaces itself but this limits the use of these interfaces to only a fraction of the GTK user. In an effort to make these features available inside gtk-rs it was agreed that it makes more sense to upstream them than to implement such interfaces for each language binding individually.
The interfaces that Relm4 implements distinguish between containers that have only one child (SetChildExt, e.g. Window) and those that can have many (ContainerExt, e.g. Box). It also has a category for containers that have simple methods to remove one of their children (RemoveExt, e.g. Grid).
With these three interfaces, all different types of containers should be covered. Of course, this is just a suggestion that can be discussed and adjusted as needed.
Interface (trait) | Docs | Code | Implementors | Description |
---|---|---|---|---|
IterChildrenExt | Link | Link | Box, ListBox, FlowBox, Grid, Stack, adw::TabView | Iterate over the children of widgets. |
SetChildExt | Link | Link | Button, LinkButton, ToggleButton, FlowBoxChild, Frame, ListBoxRow, Popover, Window, ScrolledWindow, ApplicationWindow, Dialog, Overlay, Revealer, adw::Application, adw::Bin, adw::Clamp, adw::ClampScrollable, adw::SplitButton, adw::StatusPage | Has a container_set_child method that sets a widget as the only child of the container or removes it. |
ContainerExt | Link | Link | Box, ListBox, InfoBar, Stack, all SetChild implementors | Has a container_add method to add a child to the container (the new child might replace previously added children). |
RemoveExt | Link | Link | ListBox, FlowBox, Box, Fixed, Grid, ActionBar, Stack, HeaderBar, InfoBar, all SetChildExt implementors | Has a container_remove method to remove previously added widgets. |