How do I make scrollable combo boxes scrollable using GTK4?

Viewed 246

I am trying to make a combo box which contains a lot of items. Due to its length it hits the bottom of the screen. Here is an example of what happens when it hits the bottom of the screen:

combo box in GTK4, it doesn't allow scrolling

There are 80 items in the combo box, but it can only display those five items, with the fifth being slightly cut off, as there's no vertical scroll bar which can allow for scrolling through the options.

In the UI file I have:

<child>
  <object class="GtkComboBoxText" id="acc1_combo_box">
    <property name="visible">True</property>
    <property name="sensitive">False</property>
    <property name="can-focus">False</property>
  </object>
  <packing>
    <property name="expand">False</property>
    <property name="fill">True</property>
    <property name="position">1</property>
  </packing>
</child>

After doing some tests using Glade, I found out that GTK3's combo boxes will allow for scrolling when the combo box hits the bottom of the screen (indicated here by the downwards arrow):

combo box in gtk3 using glade

How do I make the combo boxes scrollable? Is there an alternative, or should I just convert my code to use GTK3, as it does have scrollable combo boxes?

1 Answers

GtkComboBox uses GtkTreeview-based technology which is quite deprecated in GTK4 and there are various regressions from GTK3 that no body cared enough to fix.

Do you really need to use GtkCombobox instead of GtkDropDown which uses the actively developed GtkListView-based technology (and supports scrolling)?

The only legitimate reason to use GtkComboBox would be because it doesn't support tree-like navigation, (which you don't seem to need based on your examples), you can see examples of people's problems with GtkComboBox in GTK4 mentioned here and here

Related