~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar-tray/src/org/herac/tuxguitar/tray/TGTrayMenu.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.tray;
 
2
 
 
3
import org.eclipse.swt.SWT;
 
4
import org.eclipse.swt.events.SelectionAdapter;
 
5
import org.eclipse.swt.events.SelectionEvent;
 
6
import org.eclipse.swt.widgets.Menu;
 
7
import org.eclipse.swt.widgets.MenuItem;
 
8
import org.herac.tuxguitar.gui.TuxGuitar;
 
9
 
 
10
public class TGTrayMenu {
 
11
        
 
12
        private Menu menu;
 
13
        private MenuItem play;
 
14
        private MenuItem stop;
 
15
        private MenuItem exit;
 
16
        
 
17
        public void make(){
 
18
                this.menu = new Menu (TuxGuitar.instance().getShell(), SWT.POP_UP);
 
19
                
 
20
                this.play = new MenuItem(this.menu,SWT.PUSH);
 
21
                this.play.addSelectionListener(new SelectionAdapter() {
 
22
                        public void widgetSelected(SelectionEvent e) {
 
23
                                TuxGuitar.instance().getTransport().play(e);
 
24
                        }
 
25
                });
 
26
                
 
27
                this.stop = new MenuItem(this.menu, SWT.PUSH);
 
28
                this.stop.addSelectionListener(new SelectionAdapter() {
 
29
                        public void widgetSelected(SelectionEvent e) {
 
30
                                TuxGuitar.instance().getTransport().stop(e);
 
31
                        }
 
32
                });
 
33
                
 
34
                //--SEPARATOR--
 
35
                new MenuItem(this.menu, SWT.SEPARATOR);
 
36
                
 
37
                this.exit = new MenuItem(this.menu, SWT.PUSH);
 
38
                this.exit.addSelectionListener(new SelectionAdapter() {
 
39
                        public void widgetSelected(SelectionEvent arg0) {
 
40
                                TuxGuitar.instance().getShell().close();
 
41
                        }
 
42
                });
 
43
                
 
44
                this.loadProperties();
 
45
                this.loadIcons();
 
46
        }
 
47
        
 
48
        public void loadProperties(){
 
49
                if(this.menu != null && !this.menu.isDisposed()){
 
50
                        this.play.setText(TuxGuitar.getProperty("transport.start"));
 
51
                        this.stop.setText(TuxGuitar.getProperty("transport.stop"));
 
52
                        this.exit.setText(TuxGuitar.getProperty("file.exit"));
 
53
                }
 
54
        }
 
55
        
 
56
        public void loadIcons(){
 
57
                if(this.menu != null && !this.menu.isDisposed()){
 
58
                        this.stop.setImage(TuxGuitar.instance().getIconManager().getTransportIconStop1());
 
59
                        this.play.setImage(TuxGuitar.instance().getIconManager().getTransportIconPlay1());
 
60
                }
 
61
        }
 
62
        
 
63
        public void show(){
 
64
                if(this.menu != null && !this.menu.isDisposed()){
 
65
                        this.menu.setVisible(true);
 
66
                }
 
67
        }
 
68
        
 
69
        public void dispose(){
 
70
                if(this.menu != null && !this.menu.isDisposed()){
 
71
                        this.menu.dispose();
 
72
                }
 
73
        }
 
74
        
 
75
}