79 lines
3.1 KiB
Java
79 lines
3.1 KiB
Java
package io.gitlab.jfronny.inceptum.gtk.control;
|
|
|
|
import io.gitlab.jfronny.inceptum.gtk.util.ListIndexItem;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance;
|
|
import org.gtk.gtk.*;
|
|
import org.pango.EllipsizeMode;
|
|
import org.pango.WrapMode;
|
|
|
|
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(null);
|
|
label.setSizeRequest(192, -1);
|
|
label.maxWidthChars = 20;
|
|
label.justify = Justification.CENTER;
|
|
label.halign = Align.START;
|
|
label.hexpand = true;
|
|
label.valign = Align.CENTER;
|
|
label.ellipsize = EllipsizeMode.MIDDLE;
|
|
label.lines = 3;
|
|
label.wrap = true;
|
|
label.wrapMode = WrapMode.WORD_CHAR;
|
|
label.marginTop = 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);
|
|
|
|
((ListItem) 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()));
|
|
|
|
ListItem li = (ListItem) item;
|
|
|
|
Box box = (Box) li.getChild();
|
|
InstanceThumbnail thumbnail = (InstanceThumbnail) box.firstChild;
|
|
Label label = (Label) thumbnail.nextSibling;
|
|
|
|
Instance instance = instanceList.get(((ListIndexItem) li.getItem()).getIntValue());
|
|
thumbnail.bind(instance);
|
|
label.text = instance.toString();
|
|
//TODO right click menu + double click action
|
|
//TODO edit button document-edit-symbolic -> edit-delete-symbolic, edit-copy-symbolic
|
|
});
|
|
}
|
|
}
|