forked from dorkbox/SystemTray
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:
parent
09564855a7
commit
2c2e835ab2
@ -28,6 +28,8 @@ import javax.swing.JPopupMenu;
|
|||||||
|
|
||||||
import dorkbox.systemTray.MenuItem;
|
import dorkbox.systemTray.MenuItem;
|
||||||
import dorkbox.systemTray.Tray;
|
import dorkbox.systemTray.Tray;
|
||||||
|
import dorkbox.systemTray.jna.linux.Gtk;
|
||||||
|
import dorkbox.util.OS;
|
||||||
import dorkbox.util.SwingUtil;
|
import dorkbox.util.SwingUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +61,11 @@ class _SwingTray extends Tray implements SwingUI {
|
|||||||
"type and configuration");
|
"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.
|
// we override various methods, because each tray implementation is SLIGHTLY different. This allows us customization.
|
||||||
final SwingMenu swingMenu = new SwingMenu(null, null) {
|
final SwingMenu swingMenu = new SwingMenu(null, null) {
|
||||||
@Override
|
@Override
|
||||||
@ -184,9 +191,20 @@ class _SwingTray extends Tray implements SwingUI {
|
|||||||
});
|
});
|
||||||
|
|
||||||
super.remove();
|
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);
|
bind(swingMenu, null, systemTray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user