Model views after boxes again
This commit is contained in:
parent
ef986fab05
commit
390f6bc59b
|
@ -3,6 +3,8 @@ 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.Int;
|
||||
import ch.bailu.gtk.type.Str;
|
||||
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||
import io.gitlab.jfronny.inceptum.gtk.GtkMenubar;
|
||||
|
@ -16,38 +18,62 @@ public class InstanceGridEntryFactory extends SignalListItemFactory {
|
|||
super();
|
||||
//TODO better design
|
||||
onSetup(item -> {
|
||||
var box = new Box(Orientation.HORIZONTAL, 5);
|
||||
var box = new Box(Orientation.VERTICAL, 5);
|
||||
|
||||
Label label = new Label(Str.NULL);
|
||||
// label.setXalign(0);
|
||||
label.setWidthChars(20);
|
||||
label.setMarginEnd(10);
|
||||
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);
|
||||
|
||||
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);
|
||||
// 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());
|
||||
// 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());
|
||||
|
||||
InstanceList.Entry instance = instanceList.get(ListIndex.toIndex(item));
|
||||
thumbnail.bind(instance);
|
||||
label.setText(new Str(instance.toString()));
|
||||
launch.onClicked(() -> GtkMenubar.launch(instance));
|
||||
openDir.onClicked(() -> Utils.openFile(instance.path().toFile()));
|
||||
//TODO right click menu + double click action
|
||||
//TODO edit button document-edit-symbolic -> edit-delete-symbolic, edit-copy-symbolic
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
@ -16,25 +17,26 @@ public class InstanceListEntryFactory extends SignalListItemFactory {
|
|||
super();
|
||||
onSetup(item -> {
|
||||
var thumbnail = new InstanceThumbnail();
|
||||
|
||||
var label = new Label(Str.NULL);
|
||||
label.setHexpand(GTK.TRUE);
|
||||
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 Box(Orientation.HORIZONTAL, 8);
|
||||
row.append(thumbnail);
|
||||
row.append(label);
|
||||
row.append(launch);
|
||||
row.append(openDir);
|
||||
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);
|
||||
|
||||
|
@ -43,18 +45,27 @@ public class InstanceListEntryFactory extends SignalListItemFactory {
|
|||
});
|
||||
onBind(item -> {
|
||||
InstanceList.Entry instance = instanceList.get(ListIndex.toIndex(item));
|
||||
Box row = new Box(item.getChild().cast());
|
||||
InstanceThumbnail thumbnail = new InstanceThumbnail(row.getFirstChild().cast());
|
||||
Label label = new Label(thumbnail.getNextSibling().cast());
|
||||
Button launch = new Button(label.getNextSibling().cast());
|
||||
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()));
|
||||
// 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) {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package io.gitlab.jfronny.inceptum.gtk.control;
|
||||
|
||||
import ch.bailu.gtk.gtk.*;
|
||||
import ch.bailu.gtk.type.CPointer;
|
||||
import ch.bailu.gtk.type.Str;
|
||||
import ch.bailu.gtk.type.*;
|
||||
import io.gitlab.jfronny.inceptum.launcher.util.InstanceList;
|
||||
import io.gitlab.jfronny.inceptum.launcher.util.InstanceLock;
|
||||
|
||||
|
@ -20,6 +19,9 @@ public class InstanceThumbnail extends Stack {
|
|||
var spinner = new Spinner();
|
||||
var image = new Image();
|
||||
var generic = new Image();
|
||||
spinner.setName(SPINNER);
|
||||
image.setName(IMAGE);
|
||||
generic.setName(GENERIC);
|
||||
generic.setFromIconName(new Str("media-playback-start-symbolic")); //TODO better default icon
|
||||
addNamed(spinner, SPINNER);
|
||||
addNamed(image, IMAGE);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package io.gitlab.jfronny.inceptum.gtk.util;
|
||||
|
||||
import ch.bailu.gtk.gtk.Widget;
|
||||
import ch.bailu.gtk.type.Pointer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Dbg {
|
||||
public static String inspect(Widget ptr) {
|
||||
if (ptr.isNull()) return "<null>";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
inspect(ptr, sb, "");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void inspect(Widget ptr, StringBuilder bld, String indent) {
|
||||
bld.append(indent).append("<").append(ptr.getName().toString()).append("#").append(ptr.getCPointer()).append("> ")
|
||||
.append(Arrays.stream(Pointer.toJnaPointer(ptr.getCssClasses().getCPointer()).getPointerArray(0))
|
||||
.map(p -> p.getString(0))
|
||||
.collect(Collectors.joining(", ")));
|
||||
ptr = ptr.getFirstChild();
|
||||
if (ptr.isNotNull()) {
|
||||
while (ptr.isNotNull()) {
|
||||
bld.append("\n");
|
||||
inspect(ptr, bld, indent + " ");
|
||||
ptr = ptr.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.gitlab.jfronny.inceptum.gtk.window;
|
||||
|
||||
import ch.bailu.gtk.GTK;
|
||||
import ch.bailu.gtk.adw.Clamp;
|
||||
import ch.bailu.gtk.adw.StatusPage;
|
||||
import ch.bailu.gtk.bridge.ListIndex;
|
||||
import ch.bailu.gtk.gio.Menu;
|
||||
|
@ -27,8 +28,8 @@ public class MainWindow extends ApplicationWindow {
|
|||
private final Button listButton;
|
||||
private final Button gridButton;
|
||||
private final Stack stack;
|
||||
private final Box empty;
|
||||
private final ListView listView;
|
||||
private final StatusPage empty;
|
||||
private final Clamp listView;
|
||||
private final GridView gridView;
|
||||
private final List<InstanceList.Entry> instanceList;
|
||||
private final ListIndex instanceListIndex;
|
||||
|
@ -81,18 +82,13 @@ public class MainWindow extends ApplicationWindow {
|
|||
instanceList = new ArrayList<>();
|
||||
instanceListIndex = new ListIndex();
|
||||
|
||||
listView = new ListView(instanceListIndex.inSelectionModel(), new InstanceListEntryFactory(instanceList));
|
||||
listView = new Clamp();
|
||||
listView.setMaximumSize(900);
|
||||
listView.setChild(new ListView(instanceListIndex.inSelectionModel(), new InstanceListEntryFactory(instanceList)));
|
||||
gridView = new GridView(instanceListIndex.inSelectionModel(), new InstanceGridEntryFactory(instanceList));
|
||||
empty = new Box(Orientation.VERTICAL, 8);
|
||||
empty.setHalign(Align.CENTER);
|
||||
empty.setValign(Align.CENTER);
|
||||
var emptyTitle = new Label(Str.NULL);
|
||||
emptyTitle.setMarkup(I18n.str("main.empty.title"));
|
||||
emptyTitle.setHalign(Align.CENTER);
|
||||
var emptyDescription = new Label(I18n.str("main.empty.description"));
|
||||
emptyDescription.setHalign(Align.CENTER);
|
||||
empty.append(emptyTitle);
|
||||
empty.append(emptyDescription);
|
||||
empty = new StatusPage();
|
||||
empty.setTitle(I18n.str("main.empty.title"));
|
||||
empty.setDescription(I18n.str("main.empty.description"));
|
||||
//TODO empty.setIconName(new Str());
|
||||
stack = new Stack();
|
||||
stack.addChild(listView);
|
||||
|
|
Loading…
Reference in New Issue