Inceptum/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/GtkTest.java

70 lines
2.5 KiB
Java

package io.gitlab.jfronny.inceptum.gtk;
import io.gitlab.jfronny.inceptum.gtk.control.Dropdown;
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv;
import org.gtk.gio.ListStore;
import org.gtk.gobject.GObject;
import org.gtk.gtk.*;
import java.io.IOException;
import java.util.function.Function;
public class GtkTest extends ApplicationWindow {
private final String searchTextWidget;
private final String searchTextMethod;
private final ListStore modelWidget;
private final SortListModel sortModelWidget;
private final FilterListModel filterModelWidget;
private final CustomFilter filterWidget;
public GtkTest(Application application) {
super(application);
this.searchTextWidget = "";
this.searchTextMethod = "";
this.modelWidget = new ListStore(Widget.type);
this.sortModelWidget = new SortListModel(modelWidget, null);
this.filterModelWidget = new FilterListModel(sortModelWidget, null);
this.filterWidget = new CustomFilter(this::doFilterWidgetView, null);
this.filterModelWidget.setFilter(this.filterWidget);
// modelWidget.append();
}
private boolean doFilterWidgetView(GObject item) {
var arg = filterModelWidget;
return false;
}
public static void main(String[] args) throws IOException {
LauncherEnv.initialize(GtkEnvBackend.INSTANCE);
int statusCode = -1;
try {
statusCode = GtkMain.setupApplication(args, app -> {
// var wnd = new GtkTest(app);
var wnd = new ApplicationWindow(app);
var row = new Box(Orientation.VERTICAL, 0);
var btn = DropDown.newFromStrings(new String[]{"Ae", "Io", "U"});
var innerBox = (Box) btn.lastChild.firstChild.firstChild;
var chkbx = CheckButton.newWithLabel("Joe Biden");
chkbx.insertBefore(innerBox, innerBox.firstChild);
btn.enableSearch = true;
btn.selected = 1;
btn.onNotify("selected", pspec -> System.out.println(btn.selected));
row.append(btn);
wnd.child = row;
wnd.show();
GtkEnvBackend.INSTANCE.dialogParent = wnd;
wnd.onCloseRequest(() -> {
GtkEnvBackend.INSTANCE.dialogParent = null;
app.quit();
return false;
});
});
} finally {
LauncherEnv.terminate();
System.exit(statusCode);
}
}
}