2022-09-26 19:09:02 +02:00
|
|
|
package io.gitlab.jfronny.inceptum.gtk.menu;
|
|
|
|
|
2022-12-17 21:53:21 +01:00
|
|
|
import org.gtk.gio.SimpleAction;
|
|
|
|
import org.gtk.glib.Variant;
|
2022-09-26 19:09:02 +02:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2023-01-13 19:34:29 +01:00
|
|
|
public class BuiltRadioItem<T> extends BuiltMenuItem {
|
2022-09-26 19:09:02 +02:00
|
|
|
private final List<T> options;
|
|
|
|
|
2023-01-13 19:34:29 +01:00
|
|
|
public BuiltRadioItem(SimpleAction action, List<T> options) {
|
|
|
|
super(action, null);
|
2022-09-26 19:09:02 +02:00
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSelected(T selected) {
|
2022-12-17 21:53:21 +01:00
|
|
|
action.setState(Variant.newInt32(options.indexOf(selected)));
|
2022-09-26 19:09:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public T getSelected() {
|
|
|
|
return options.get(action.getState().getInt32());
|
|
|
|
}
|
|
|
|
}
|