Swing tray (on linux/unix) will now initialize GTK (there are GTK

methods needed, so it makes sense to start GTK)
This commit is contained in:
nathan 2017-06-25 22:56:40 +02:00
parent 09564855a7
commit 2c2e835ab2

View File

@ -28,6 +28,8 @@ import javax.swing.JPopupMenu;
import dorkbox.systemTray.MenuItem;
import dorkbox.systemTray.Tray;
import dorkbox.systemTray.jna.linux.Gtk;
import dorkbox.util.OS;
import dorkbox.util.SwingUtil;
/**
@ -59,6 +61,11 @@ class _SwingTray extends Tray implements SwingUI {
"type and configuration");
}
if (OS.isLinux() || OS.isUnix()) {
// linux/unix need access to GTK, so load it up!
Gtk.startGui();
}
// we override various methods, because each tray implementation is SLIGHTLY different. This allows us customization.
final SwingMenu swingMenu = new SwingMenu(null, null) {
@Override
@ -184,9 +191,20 @@ class _SwingTray extends Tray implements SwingUI {
});
super.remove();
if (OS.isLinux() || OS.isUnix()) {
// does not need to be called on the dispatch (it does that)
Gtk.shutdownGui();
}
}
};
if (OS.isLinux() || OS.isUnix()) {
// linux/unix need access to GTK, so load it up!
Gtk.waitForStartup();
}
bind(swingMenu, null, systemTray);
}