From 2c2e835ab20033436597a40205575328d0251d5e Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 25 Jun 2017 22:56:40 +0200 Subject: [PATCH] Swing tray (on linux/unix) will now initialize GTK (there are GTK methods needed, so it makes sense to start GTK) --- src/dorkbox/systemTray/swingUI/_SwingTray.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dorkbox/systemTray/swingUI/_SwingTray.java b/src/dorkbox/systemTray/swingUI/_SwingTray.java index dce73dc..8c52a9f 100644 --- a/src/dorkbox/systemTray/swingUI/_SwingTray.java +++ b/src/dorkbox/systemTray/swingUI/_SwingTray.java @@ -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); }