Inceptum/launcher-gtk/src/main/java/io/gitlab/jfronny/inceptum/gtk/control/settings/SettingsWindow.java

51 lines
1.6 KiB
Java

package io.gitlab.jfronny.inceptum.gtk.control.settings;
import io.gitlab.jfronny.inceptum.gtk.util.I18n;
import org.gnome.adw.*;
import org.gnome.adw.HeaderBar;
import org.gnome.gobject.BindingFlags;
import org.gnome.gtk.*;
import org.gnome.gtk.Application;
import org.gnome.gtk.Window;
import org.jetbrains.annotations.PropertyKey;
public class SettingsWindow extends Window {
protected final ViewStack stack;
public SettingsWindow(Application app) {
this.application = app;
this.stack = new ViewStack();
HeaderBar header = new HeaderBar();
ViewSwitcherTitle viewSwitcher = new ViewSwitcherTitle();
viewSwitcher.stack = stack;
header.titleWidget = viewSwitcher;
titlebar = header;
ScrolledWindow scroll = new ScrolledWindow();
scroll.setPolicy(PolicyType.NEVER, PolicyType.AUTOMATIC);
scroll.child = stack;
scroll.vexpand = true;
ViewSwitcherBar bottomBar = new ViewSwitcherBar();
bottomBar.stack = stack;
viewSwitcher.bindProperty("title-visible", bottomBar, "reveal", BindingFlags.DEFAULT);
Box view = new Box(Orientation.VERTICAL, 0);
view.append(scroll);
view.append(bottomBar);
child = view;
setDefaultSize(720, 360);
}
public void addTab(SettingsTab tab, @PropertyKey(resourceBundle = I18n.BUNDLE) String title, String iconName) {
stack.addTitledWithIcon(tab, title, I18n.get(title), iconName);
}
public void setActivePage(@PropertyKey(resourceBundle = I18n.BUNDLE) String title) {
stack.visibleChildName = title;
}
}