77 lines
3.1 KiB
Java
77 lines
3.1 KiB
Java
package io.gitlab.jfronny.inceptum.gtk.control;
|
|
|
|
import ch.bailu.gtk.GTK;
|
|
import ch.bailu.gtk.bridge.ListIndex;
|
|
import ch.bailu.gtk.gtk.*;
|
|
import ch.bailu.gtk.pango.EllipsizeMode;
|
|
import ch.bailu.gtk.type.Str;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance;
|
|
|
|
import java.util.List;
|
|
|
|
public class InstanceGridEntryFactory extends SignalListItemFactory {
|
|
public InstanceGridEntryFactory(List<Instance> instanceList) {
|
|
super();
|
|
//TODO better design
|
|
onSetup(item -> {
|
|
var box = new Box(Orientation.VERTICAL, 5);
|
|
|
|
var thumbnail = new InstanceThumbnail();
|
|
box.append(thumbnail);
|
|
|
|
var label = new Label(Str.NULL);
|
|
label.setSizeRequest(192, -1);
|
|
label.setMaxWidthChars(20);
|
|
label.setJustify(Justification.CENTER);
|
|
label.setHalign(Align.START);
|
|
label.setHexpand(GTK.TRUE);
|
|
label.setValign(Align.CENTER);
|
|
label.setEllipsize(EllipsizeMode.MIDDLE);
|
|
label.setLines(3);
|
|
label.setWrap(GTK.TRUE);
|
|
label.setWrapMode(WrapMode.WORD_CHAR);
|
|
label.setMarginTop(10);
|
|
box.append(label);
|
|
// Label label = new Label(Str.NULL);
|
|
// label.setXalign(0);
|
|
// label.setWidthChars(20);
|
|
// label.setMarginEnd(10);
|
|
// box.append(label);
|
|
//
|
|
// Button launch = new Button();
|
|
// launch.setIconName(new Str("computer-symbolic"));
|
|
// launch.setTooltipText(I18n.str("instance.launch"));
|
|
// launch.setHasTooltip(GTK.TRUE);
|
|
// box.append(launch);
|
|
//
|
|
// Button openDir = new Button();
|
|
// openDir.setIconName(new Str("folder-symbolic"));
|
|
// openDir.setTooltipText(I18n.str("instance.directory"));
|
|
// openDir.setHasTooltip(GTK.TRUE);
|
|
// box.append(openDir);
|
|
|
|
item.setChild(box);
|
|
//TODO server launch with network-server-symbolic
|
|
//TODO kill current instance
|
|
});
|
|
onBind(item -> {
|
|
// Label label = new Label(item.getChild().getFirstChild().cast());
|
|
// Button launch = new Button(label.getNextSibling().cast());
|
|
// Button openDir = new Button(launch.getNextSibling().cast());
|
|
// InstanceList.Entry instance = instanceList.get(ListIndex.toIndex(item));
|
|
// label.setText(new Str(instance.toString()));
|
|
// launch.onClicked(() -> GtkMenubar.launch(instance));
|
|
// openDir.onClicked(() -> Utils.openFile(instance.path().toFile()));
|
|
Box box = new Box(item.getChild().cast());
|
|
InstanceThumbnail thumbnail = new InstanceThumbnail(box.getFirstChild().cast());
|
|
Label label = new Label(thumbnail.getNextSibling().cast());
|
|
|
|
Instance instance = instanceList.get(ListIndex.toIndex(item));
|
|
thumbnail.bind(instance);
|
|
label.setText(new Str(instance.toString()));
|
|
//TODO right click menu + double click action
|
|
//TODO edit button document-edit-symbolic -> edit-delete-symbolic, edit-copy-symbolic
|
|
});
|
|
}
|
|
}
|