- Added support for on-the-fly routerconsole.lang changes to desktopgui and routerconsole (routerconsole now commits changes to the I2PAppContext).
- Added desktopgui support for detecting if it's running in the same JVM as I2P (without commandline arguments).
This commit is contained in:
@ -6,7 +6,7 @@ Current setup:
|
||||
* Place desktopgui.jar in the $I2P/lib/ directory.
|
||||
* Add to .i2p/clients.config:
|
||||
#Desktopgui
|
||||
clientApp.6.args=--startWithI2P --I2PLocation=/SOME_LOCATION
|
||||
clientApp.6.args=
|
||||
clientApp.6.delay=5
|
||||
clientApp.6.main=net.i2p.desktopgui.Main
|
||||
clientApp.6.name=desktopgui
|
||||
|
@ -4,10 +4,13 @@ HIGH PRIORITY:
|
||||
- Internationalisation:
|
||||
* Add strings - DONE
|
||||
* Add Windows support - NEED TO CHECK
|
||||
* Might need some kind of trigger to reload the menu (for live language switching)
|
||||
* Might need some kind of trigger to reload the menu (for live language switching) - DONE
|
||||
* Language choice is not actually set as a parameter in I2P config?
|
||||
As a result, desktopgui always starts with the default, unless you manually set the language.
|
||||
- Modify installer to set I2P directory parameter; or use $I2P?
|
||||
DONE - uses routerconsole.lang -- this parameter is now updated in routerconsole as well
|
||||
- Check if we're inside I2P without using a command-line parameter - DONE
|
||||
- Modify installer to set I2P directory parameter; or use $I2P? - Is already there
|
||||
- Include in installer - TODO
|
||||
- Fix tabs versus spaces ;-)
|
||||
UNKNOWN:
|
||||
- API to allow applications to add themselves to the menu?
|
||||
|
@ -7,8 +7,12 @@ package net.i2p.desktopgui;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.desktopgui.util.*;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.Translate;
|
||||
import net.i2p.util.I2PProperties.I2PPropertyCallback;
|
||||
|
||||
/**
|
||||
* The main class of the application.
|
||||
@ -25,6 +29,19 @@ public class Main {
|
||||
private void startUp() {
|
||||
trayManager = TrayManager.getInstance();
|
||||
trayManager.startManager();
|
||||
I2PAppContext.getCurrentContext().addPropertyCallback(new I2PPropertyCallback() {
|
||||
|
||||
@Override
|
||||
public String getPropertyKey() {
|
||||
return Translate.PROP_LANG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void propertyChanged(String arg0, String arg1) {
|
||||
trayManager.languageChanged();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,9 +42,9 @@ public abstract class TrayManager {
|
||||
*/
|
||||
protected TrayManager() {}
|
||||
|
||||
public static TrayManager getInstance() {
|
||||
protected static TrayManager getInstance() {
|
||||
if(instance == null) {
|
||||
boolean inI2P = ConfigurationManager.getInstance().getBooleanConfiguration("startWithI2P", false);
|
||||
boolean inI2P = RouterManager.inI2P();
|
||||
if(inI2P) {
|
||||
instance = new InternalTrayManager();
|
||||
}
|
||||
@ -58,7 +58,7 @@ public abstract class TrayManager {
|
||||
/**
|
||||
* Add the tray icon to the system tray and start everything up.
|
||||
*/
|
||||
public void startManager() {
|
||||
protected void startManager() {
|
||||
if(SystemTray.isSupported()) {
|
||||
tray = SystemTray.getSystemTray();
|
||||
trayIcon = new TrayIcon(getTrayImage(), "I2P", getMainMenu());
|
||||
@ -70,17 +70,21 @@ public abstract class TrayManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected void languageChanged() {
|
||||
trayIcon.setPopupMenu(getMainMenu());
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a popup menu, adding callbacks to the different items.
|
||||
* @return popup menu
|
||||
*/
|
||||
public abstract PopupMenu getMainMenu();
|
||||
protected abstract PopupMenu getMainMenu();
|
||||
|
||||
/**
|
||||
* Get tray icon image from the desktopgui resources in the jar file.
|
||||
* @return image used for the tray icon
|
||||
*/
|
||||
public Image getTrayImage() {
|
||||
private Image getTrayImage() {
|
||||
URL url = getClass().getResource("/desktopgui/resources/images/logo.jpg");
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
return image;
|
||||
|
@ -55,6 +55,13 @@ public class RouterManager {
|
||||
public static void shutDown() {
|
||||
getRouter().shutdownGracefully();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we are running inside I2P.
|
||||
*/
|
||||
public static boolean inI2P() {
|
||||
return (RouterContext.listContexts().size() > 0);
|
||||
}
|
||||
|
||||
private static String _(String s) {
|
||||
return DesktopguiTranslator._(s);
|
||||
|
@ -18,7 +18,21 @@ public class ContentHelper extends HelperBase {
|
||||
public void setStartAtBeginning(String moo) {
|
||||
_startAtBeginning = Boolean.valueOf(""+moo).booleanValue();
|
||||
}
|
||||
public void setLang(String l) { _lang = l; }
|
||||
public void setLang(String l) {
|
||||
if(_lang == null || !_lang.equals(l)) {
|
||||
//Set language for router console
|
||||
_lang = l;
|
||||
|
||||
if(_context == null) {
|
||||
setContextId(null);
|
||||
}
|
||||
|
||||
//Set language persistently throughout I2P
|
||||
_context.router().setConfigSetting(Messages.PROP_LANG, _lang);
|
||||
_context.router().saveConfig();
|
||||
_context.setProperty(Messages.PROP_LANG, _lang);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxLines(String lines) {
|
||||
if (lines != null) {
|
||||
|
Reference in New Issue
Block a user