81 lines
3.4 KiB
Java
81 lines
3.4 KiB
Java
package io.gitlab.jfronny.inceptum.gtk.control;
|
|
|
|
import ch.bailu.gtk.GTK;
|
|
import ch.bailu.gtk.adw.ActionRow;
|
|
import ch.bailu.gtk.bridge.ListIndex;
|
|
import ch.bailu.gtk.gtk.*;
|
|
import ch.bailu.gtk.type.Str;
|
|
import io.gitlab.jfronny.inceptum.common.Utils;
|
|
import io.gitlab.jfronny.inceptum.gtk.GtkMenubar;
|
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance;
|
|
|
|
import java.util.List;
|
|
|
|
public class InstanceListEntryFactory extends SignalListItemFactory {
|
|
public InstanceListEntryFactory(List<Instance> instanceList) {
|
|
super();
|
|
onSetup(item -> {
|
|
var thumbnail = new InstanceThumbnail();
|
|
thumbnail.setName(new Str("inceptum-thumbnail"));
|
|
|
|
var launch = new Button();
|
|
launch.setName(new Str("inceptum-launch"));
|
|
launch.setIconName(new Str("computer-symbolic"));
|
|
launch.setTooltipText(I18n.str("instance.launch"));
|
|
launch.setHasTooltip(GTK.TRUE);
|
|
|
|
var openDir = new Button();
|
|
openDir.setName(new Str("inceptum-open-dir"));
|
|
openDir.setIconName(new Str("folder-symbolic"));
|
|
openDir.setTooltipText(I18n.str("instance.directory"));
|
|
openDir.setHasTooltip(GTK.TRUE);
|
|
|
|
var row = new ActionRow();
|
|
row.setName(new Str("inceptum-row"));
|
|
row.setActivatableWidget(launch);
|
|
row.addPrefix(thumbnail);
|
|
row.addSuffix(launch);
|
|
row.addSuffix(openDir);
|
|
|
|
item.setChild(row);
|
|
|
|
//TODO server launch with network-server-symbolic
|
|
//TODO kill current instance
|
|
});
|
|
onBind(item -> {
|
|
Instance instance = instanceList.get(ListIndex.toIndex(item));
|
|
ActionRow row = new ActionRow(item.getChild().cast());
|
|
Box prefixes = new Box(row.getFirstChild().getFirstChild().cast());
|
|
Box suffixes = new Box(row.getFirstChild().getLastChild().cast());
|
|
|
|
InstanceThumbnail thumbnail = new InstanceThumbnail(prefixes.getFirstChild().cast());
|
|
Button launch = new Button(suffixes.getFirstChild().cast());
|
|
Button openDir = new Button(launch.getNextSibling().cast());
|
|
row.setTitle(new Str(instance.toString()));
|
|
|
|
// InstanceThumbnail thumbnail = new InstanceThumbnail(row.getFirstChild().cast());
|
|
// Label label = new Label(thumbnail.getNextSibling().cast());
|
|
// Button launch = new Button(label.getNextSibling().cast());
|
|
// Button openDir = new Button(launch.getNextSibling().cast());
|
|
|
|
thumbnail.bind(instance);
|
|
// label.setText(new Str(instance.toString()));
|
|
launch.onClicked(() -> GtkMenubar.launch(instance));
|
|
openDir.onClicked(() -> Utils.openFile(instance.path().toFile()));
|
|
|
|
//TODO why the hell does this crash the VM?
|
|
//TODO GestureClick.setButton(GDK_BUTTON_SECONDARY)
|
|
// var controller = new EventControllerLegacy();
|
|
// controller.onEvent(event -> {
|
|
// if (event.getEventType() == EventType.BUTTON_RELEASE) {
|
|
// Utils.LOGGER.info("Button " + new ButtonEvent(event.cast()).getButton());
|
|
// }
|
|
// return GTK.FALSE;
|
|
// });
|
|
// row.addController(controller);
|
|
//TODO edit button document-edit-symbolic -> edit-delete-symbolic, edit-copy-symbolic
|
|
});
|
|
}
|
|
}
|