76 lines
2.6 KiB
Java
76 lines
2.6 KiB
Java
|
package io.gitlab.jfronny.inceptum.gtk.window;
|
||
|
|
||
|
import ch.bailu.gtk.GTK;
|
||
|
import ch.bailu.gtk.gio.Menu;
|
||
|
import ch.bailu.gtk.gtk.*;
|
||
|
import ch.bailu.gtk.type.Str;
|
||
|
import io.gitlab.jfronny.inceptum.common.InceptumConfig;
|
||
|
import io.gitlab.jfronny.inceptum.common.Utils;
|
||
|
import io.gitlab.jfronny.inceptum.gtk.GtkMenubar;
|
||
|
import io.gitlab.jfronny.inceptum.gtk.menu.MenuBuilder;
|
||
|
|
||
|
import java.net.URI;
|
||
|
|
||
|
public class MainWindow extends ApplicationWindow {
|
||
|
private final Button listButton;
|
||
|
private final Button gridButton;
|
||
|
|
||
|
public MainWindow(Application app) {
|
||
|
super(app);
|
||
|
|
||
|
var header = new HeaderBar();
|
||
|
var newButton = new Button();
|
||
|
newButton.setIconName(new Str("list-add-symbolic"));
|
||
|
newButton.onClicked(NewInstanceWindow::createAndShow);
|
||
|
|
||
|
var accountsButton = new MenuButton();
|
||
|
accountsButton.setIconName(new Str("avatar-default-symbolic"));
|
||
|
accountsButton.setPopover(GtkMenubar.accountsMenu.asPopover());
|
||
|
|
||
|
listButton = new Button();
|
||
|
listButton.setIconName(new Str("view-list-symbolic"));
|
||
|
listButton.onClicked(() -> {
|
||
|
InceptumConfig.listView = true;
|
||
|
InceptumConfig.saveConfig();
|
||
|
generateWindowBody();
|
||
|
});
|
||
|
|
||
|
gridButton = new Button();
|
||
|
gridButton.setIconName(new Str("view-grid-symbolic"));
|
||
|
gridButton.onClicked(() -> {
|
||
|
InceptumConfig.listView = false;
|
||
|
InceptumConfig.saveConfig();
|
||
|
generateWindowBody();
|
||
|
});
|
||
|
|
||
|
var uiMenu = new MenuBuilder(app, new Menu(), "hamburger");
|
||
|
uiMenu.button("support", () -> Utils.openWebBrowser(new URI("https://gitlab.com/jfmods/inceptum/-/issues")));
|
||
|
uiMenu.button("preferences", () -> {}); //TODO preferences UI inspired by boxes
|
||
|
uiMenu.button("about", AboutWindow::createAndShow);
|
||
|
var menuButton = new MenuButton();
|
||
|
menuButton.setIconName(new Str("open-menu-symbolic"));
|
||
|
menuButton.setPopover(uiMenu.asPopover());
|
||
|
|
||
|
header.packStart(newButton);
|
||
|
|
||
|
header.packEnd(menuButton);
|
||
|
header.packEnd(gridButton);
|
||
|
header.packEnd(listButton);
|
||
|
header.packEnd(accountsButton);
|
||
|
|
||
|
setDefaultSize(360, 720);
|
||
|
setTitle(new Str("Inceptum"));
|
||
|
setTitlebar(header);
|
||
|
setShowMenubar(GTK.FALSE);
|
||
|
setChild(new TextView());
|
||
|
|
||
|
generateWindowBody();
|
||
|
}
|
||
|
|
||
|
private void generateWindowBody() {
|
||
|
if (listButton != null) listButton.setVisible(GTK.is(!InceptumConfig.listView));
|
||
|
if (gridButton != null) gridButton.setVisible(GTK.is(InceptumConfig.listView));
|
||
|
//TODO create list/grid view
|
||
|
}
|
||
|
}
|