Author: jerome
Date: 2008-08-26 19:17:14 +0200 (Tue, 26 Aug 2008)
New Revision: 1599
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxLanguagesMenu.java
Log:
* Speakers and pitch menu are now only displayed when radio connection is
detected.
* Automatic voices updates when plug, unplug the dongle.
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
===================================================================
---
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
2008-08-26 16:00:41 UTC (rev 1598)
+++
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
2008-08-26 17:17:14 UTC (rev 1599)
@@ -407,8 +407,9 @@
public void onRadioConnected(String value, Double delay){
setOnlineStatus(true);
tray.setIcon(this.tray_online);
- this.interfaceMenusLang.setTux(tux);
- this.initializeLocutors();
+ //this.interfaceMenusLang.setTux(tux);
+ this.popupFileMenu = null;
+ this.constructFileMenu();
jFrame.pack();
}
@@ -418,7 +419,9 @@
*/
public void onRadioDisconnected(String value, Double delay){
this.setOnlineStatus(false);
- this.tray.setIcon(this.tray_offline);
+ this.tray.setIcon(this.tray_offline);
+ popupFileMenu.remove(1);
+ popupFileMenu.remove(1);
}
/**
@@ -760,22 +763,27 @@
this.jListPlaylists.setFocusable(false);
}
return jContentPane;
- }
-
- /**
- * This function initializes "file" menu.
- * @return fileMenu.
- */
- private JButton getFileMenu() {
- if (fileMenu == null) {
- fileMenu = new JButton();
- //Set preferencies.
-
- final String path = language.getMenuSubDirectory();
- Point p = language.getMenuFileLocation();
- functions.mask(fileMenu, new Rectangle(p.x, p.y, 50,
24),
-
getClass().getResource(path+"file.png"));
- popupFileMenu = new JPopupMenu();
+ }
+
+
+ public void initializeLocutors(){
+
+ //Set speaker selection menu
+ JMenu speaker = new JMenu();
+ if(!tux.radio.getConnected()) return;
+ speaker = new JMenu(language.getMenuViewSpeaker());
+ this.interfaceMenusLang.updateLocutors();
+ for(JMenuItem items :
this.interfaceMenusLang.getTuxLocutorsMenus())
+ speaker.add(items);
+
+ popupFileMenu.add(speaker);
+
+ }
+
+
+ public void constructFileMenu(){
+ if(popupFileMenu == null){
+ popupFileMenu = new JPopupMenu();
//Create sub menus languages.
@@ -786,11 +794,11 @@
popupFileMenu.add(languages);
- if(!this.interfaceMenusLang.areLocutorsInitialized()){
- this.initializeLocutors();
-
this.interfaceMenusLang.setLocutorsInitialized(true);
- }
+ this.initializeLocutors();
+ this.interfaceMenusLang.setLocutorsInitialized(true);
+
+
//Create pitch menu.
final int pitchValue = settings.getPitch();
final JMenu pitch = new
JMenu(language.getPitchMenuCaption());
@@ -825,29 +833,49 @@
}
});
+ if(tux.radio.getConnected())
+ popupFileMenu.add(pitch);
- popupFileMenu.add(pitch);
+ popupFileMenu.addSeparator();
+ final String path = language.getMenuSubDirectory();
+ //Add exit menu item that allow to exit application.
+ exit = new JMenuItem(language.getMenuFileExit());
+ exit.addMouseListener(new ExitSubMenuListener(path));
+ popupFileMenu.add(exit);
+ //Create a menu listener com.tuxdroid.cc.Listener.
- popupFileMenu.addSeparator();
- //Add exit menu item that allow to exit application.
- exit = new JMenuItem(language.getMenuFileExit());
- exit.addMouseListener(new ExitSubMenuListener(path));
- popupFileMenu.add(exit);
- //Create a menu listener com.tuxdroid.cc.Listener.
- URL one = getClass().getResource(path+"file.png");
- URL two = getClass().getResource(path+"file_over.png");
- URL three = getClass().getResource(path+"file.png");
+ URL one = getClass().getResource(path+"file.png");
+ URL two = getClass().getResource(path+"file_over.png");
+ URL three = getClass().getResource(path+"file.png");
popupFileMenu.addPopupMenuListener(new
MenuListener(one, two, three,
-
fileMenu));
+
fileMenu));
+
+ //Change image clicking on File item.
+ fileMenu.addMouseListener(new
java.awt.event.MouseAdapter() {
+ public void
mousePressed(java.awt.event.MouseEvent e) {
+ popupFileMenu.show(jFrame,
fileMenu.getX() , fileMenu
+ .getY() +
fileMenu.getHeight() + 4);
+ }
+ });
+ fileMenu.addMouseMotionListener(new
HandCursorChanger(jContentPane));
+ }
+ else System.out.println("menu is not null");
+ }
+
+ /**
+ * This function initializes "file" menu.
+ * @return fileMenu.
+ */
+ private JButton getFileMenu() {
+ if (fileMenu == null) {
+ fileMenu = new JButton();
+ //Set preferencies.
- //Change image clicking on File item.
- fileMenu.addMouseListener(new
java.awt.event.MouseAdapter() {
- public void
mousePressed(java.awt.event.MouseEvent e) {
- popupFileMenu.show(jFrame,
fileMenu.getX() , fileMenu
- .getY() +
fileMenu.getHeight() + 4);
- }
- });
- fileMenu.addMouseMotionListener(new
HandCursorChanger(jContentPane));
+ final String path = language.getMenuSubDirectory();
+ Point p = language.getMenuFileLocation();
+ functions.mask(fileMenu, new Rectangle(p.x, p.y, 50,
24),
+
getClass().getResource(path+"file.png"));
+ this.constructFileMenu();
}
return fileMenu;
}
@@ -955,29 +983,6 @@
popupmenu1.add(advancedMenu);
}
return toolsMenu;
- }
-
-
- public void initializeLocutors(){
-
- //Set speaker selection menu. TODO
- JMenu speaker = new JMenu();
- for(Component compo : popupFileMenu.getComponents()){
- if(compo instanceof JMenu){
-
if(((JMenu)compo).getText().equalsIgnoreCase(language.getMenuViewSpeaker())){
- speaker = (JMenu)compo;
- popupFileMenu.remove(speaker);
- }
- }
- }
-
- speaker = new JMenu(language.getMenuViewSpeaker());
- this.interfaceMenusLang.updateLocutors();
- for(JMenuItem items :
this.interfaceMenusLang.getTuxLocutorsMenus())
- speaker.add(items);
-
- popupFileMenu.add(speaker);
-
}
/**
@@ -2261,7 +2266,7 @@
jFrame.repaint();
jFrame.pack();
}
- else if(kind.equalsIgnoreCase("gadget")){ //FIXME
+ else if(kind.equalsIgnoreCase("gadget")){
this.maskAllTabs();
//Time config panel.
final SimpleAlertSettings alertSimpleSetting =
new SimpleAlertSettings(language);
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxLanguagesMenu.java
===================================================================
---
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxLanguagesMenu.java
2008-08-26 16:00:41 UTC (rev 1598)
+++
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxLanguagesMenu.java
2008-08-26 17:17:14 UTC (rev 1599)
@@ -135,6 +135,8 @@
}
public void updateLocutors(){
+ this.locutorsMenus.clear();
+
this.getLocutorsMenus();
}
@@ -151,13 +153,16 @@
if(item.getText().equalsIgnoreCase(settings.getLanguage())){
item.setIcon(new
ImageIcon(TuxLanguagesMenu.icon));
}
+ currentLocutor = settings.getSpeaker();
item.addMouseListener(new java.awt.event.MouseAdapter(){
+
public void
mousePressed(java.awt.event.MouseEvent event){
removeMenuIcons(interfaceLangMenus);
setLanguageMenuIcon((JMenuItem)
event.getComponent());
//Register new language.
String lang =
((JMenuItem)event.getComponent()).getText();
String country = lang.toUpperCase();
+ System.out.println(lang);
if(lang.equalsIgnoreCase("en")){
country = "US";
if(!isValidLocutor(currentLocutor, lang))
@@ -193,6 +198,7 @@
private boolean isValidLocutor(String locutor, String language){
+ this.prepareLocutors();
String male;
String female;
if(language.equalsIgnoreCase("en")){
@@ -213,6 +219,7 @@
female = locutors.get("en").get("female");
}
+ System.out.println(locutor);
if(!((locutor.equalsIgnoreCase(male)) ||
(locutor.equalsIgnoreCase(female)))){
return false;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn