81 lines
3.3 KiB
Java
81 lines
3.3 KiB
Java
package io.gitlab.jfronny.inceptum.gtk.control;
|
|
|
|
import io.gitlab.jfronny.inceptum.gtk.util.ListIndex;
|
|
import org.gnome.adw.ActionRow;
|
|
import org.gtk.gtk.*;
|
|
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.name = "inceptum-thumbnail";
|
|
|
|
var launch = new Button();
|
|
launch.name = "inceptum-launch";
|
|
launch.iconName = "computer-symbolic";
|
|
launch.tooltipText = I18n.get("instance.launch");
|
|
launch.hasTooltip = true;
|
|
|
|
var openDir = new Button();
|
|
openDir.name = "inceptum-open-dir";
|
|
openDir.iconName = "folder-symbolic";
|
|
openDir.tooltipText = I18n.get("instance.directory");
|
|
openDir.hasTooltip = true;
|
|
|
|
var row = new ActionRow();
|
|
row.name = "inceptum-row";
|
|
row.activatableWidget = launch;
|
|
row.addPrefix(thumbnail);
|
|
row.addSuffix(launch);
|
|
row.addSuffix(openDir);
|
|
|
|
ListItem.castFrom(item).setChild(row);
|
|
|
|
//TODO server launch with network-server-symbolic
|
|
//TODO kill current instance
|
|
});
|
|
onBind(($, item) -> {
|
|
ListItem li = ListItem.castFrom(item);
|
|
|
|
Instance instance = instanceList.get(ListIndex.toIndex(li));
|
|
ActionRow row = ActionRow.castFrom(li.child);
|
|
Box prefixes = Box.castFrom(row.firstChild.firstChild);
|
|
Box suffixes = Box.castFrom(row.firstChild.lastChild);
|
|
|
|
InstanceThumbnail thumbnail = InstanceThumbnail.castFrom(prefixes.firstChild);
|
|
Button launch = Button.castFrom(suffixes.firstChild);
|
|
Button openDir = Button.castFrom(launch.nextSibling);
|
|
row.title = 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($1 -> GtkMenubar.launch(instance));
|
|
openDir.onClicked($1 -> 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
|
|
});
|
|
}
|
|
}
|