How to bind enum to Gtk.DropDown

,

I have the following GSettings schema:

<schemalist>
  <enum id="org.gnome.shell.extensions.Test.SomeEnum">
    <value nick="one" value="1"/>
    <value nick="two" value="2"/>
    <value nick="three" value="3"/>
  </enum>
  <schema id="org.gnome.shell.Test">
    <key name='some-value' enum='org.gnome.shell.extensions.Test.SomeEnum'>
      <default>"one"</default>
    </key>
  </schema>
</schemalist>

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.