How to bind enum to Gtk.DropDown


I have the following GSettings schema:

  <enum id="">
    <value nick="one" value="1"/>
    <value nick="two" value="2"/>
    <value nick="three" value="3"/>
  <schema id="">
    <key name='some-value' enum=''>

There is also a Gtk.DropDown in the UI:

const dropDown = new Gtk.DropDown();

How can I bind some-value to dropDown? Is there any proxy or model for this?

One approach could be to make a Gio.SettingsAction for that setting, and bind (with Glib.Binding or Gtk.Expression) its :state to the DropDown:selected property, probably via a transformation from enum value to item index.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.