Skip to content

keyboard: Correctly update labels for IBus engines

Simon McVittie requested to merge wip/smcv/issue180 into master
  • keyboard: Correctly update labels for IBus engines

    After the port from GTK 3 to 4, in general there's an additional level of indirection: the children of priv->input_list are GtkListBoxRow objects containing the widget whose user-data is the InputWidget. This means we didn't find the InputWidget and therefore couldn't update its display name.

    Unfortunately, there is one exception to the rule that every child of a GtkListBox is a GtkListBoxRow: the placeholder object, in our case priv->no_results, is not wrapped in a GtkListBoxRow (see also gtk#4523). This means that walking the GtkWidget tree seems rather fragile: it's difficult to tell whether each child of the GtkListBox is a GtkListBoxRow, or the placeholder object priv->no_results, or some third type of object that could be added by a future GTK version (particularly since there is no particular type-safety here).

    Instead of walking the widget tree, maintain our own parallel list of known keyboard layouts and other input methods. For this list, we can safely assert that every item is something that we put there, with the invariant that it's a GtkBox with an InputWidget attached.

    This means that we can reliably find the InputWidget, and update its associated display name.

    Fixes: ad500afc "keyboard: Port to GTK4" Resolves: #180 (closed)

  • keyboard: Update filter and sort when the display name changes

    The display name in InputWidget.name can affect sort_inputs() and input_visible(), so we should update it when we replace the placeholder display name with the real one, and tell GTK to update its state accordingly.

Edited by Simon McVittie

Merge request reports