1
package org.herac.tuxguitar.tray;
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.widgets.Display;
5
import org.eclipse.swt.widgets.Event;
6
import org.eclipse.swt.widgets.Listener;
7
import org.eclipse.swt.widgets.Shell;
8
import org.eclipse.swt.widgets.Tray;
9
import org.eclipse.swt.widgets.TrayItem;
10
import org.herac.tuxguitar.gui.TuxGuitar;
11
import org.herac.tuxguitar.gui.system.icons.IconLoader;
12
import org.herac.tuxguitar.gui.system.language.LanguageLoader;
14
public class TGTray implements IconLoader,LanguageLoader{
16
private boolean visible;
17
private Display display;
19
private TGTrayIcon icon;
20
private TGTrayMenu menu;
23
this.display = TuxGuitar.instance().getDisplay();
24
this.tray = this.display.getSystemTray();
25
this.icon = new TGTrayIcon();
26
this.menu = new TGTrayMenu();
27
TuxGuitar.instance().getIconManager().addLoader(this);
28
TuxGuitar.instance().getLanguageManager().addLoader(this);
31
public void removeTray(){
32
if (this.tray != null) {
34
TrayItem items[] = this.tray.getItems();
35
for(int i = 0; i < items.length; i ++){
43
public void addTray() {
44
if (this.tray != null) {
47
TrayItem item = new TrayItem (this.tray, SWT.NONE);
48
item.setToolTipText(TuxGuitar.APPLICATION_NAME);
49
item.addListener (SWT.Selection, new Listener () {
50
public void handleEvent (Event event) {
54
item.addListener (SWT.MenuDetect, new Listener () {
55
public void handleEvent (Event event) {
59
this.icon.setItem(item);
64
public void loadIcons() {
65
this.icon.loadImage();
66
this.menu.loadIcons();
69
public void loadProperties(){
70
this.menu.loadProperties();
73
protected void setVisible(){
74
this.setVisible(!this.visible);
77
protected void setVisible(boolean visible){
78
if (this.tray != null) {
79
Shell shells[] = this.display.getShells();
80
for(int i = 0; i < shells.length; i ++){
81
shells[i].setVisible( visible );
83
this.visible = visible;
87
protected void showMenu(){