forked from I2P_Developers/i2p.i2p
Store snark theme setting in themes.config
This commit is contained in:
@ -53,6 +53,7 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
private final Object _addSnarkLock;
|
||||
private /* FIXME final FIXME */ File _configFile;
|
||||
private Properties _config;
|
||||
private String _theme;
|
||||
private final I2PAppContext _context;
|
||||
private final Log _log;
|
||||
private final Queue<String> _messages;
|
||||
@ -85,6 +86,7 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
//public static final String DEFAULT_LINK_PREFIX = "file:///";
|
||||
public static final String PROP_STARTUP_DELAY = "i2psnark.startupDelay";
|
||||
public static final String PROP_REFRESH_DELAY = "i2psnark.refreshSeconds";
|
||||
public static final String THEME_CONFIG_FILE = "themes.config";
|
||||
public static final String PROP_THEME = "i2psnark.theme";
|
||||
public static final String DEFAULT_THEME = "ubergine";
|
||||
private static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers";
|
||||
@ -286,8 +288,8 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
_config.setProperty(PROP_REFRESH_DELAY, Integer.toString(DEFAULT_REFRESH_DELAY_SECS));
|
||||
if (!_config.containsKey(PROP_STARTUP_DELAY))
|
||||
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(DEFAULT_STARTUP_DELAY));
|
||||
if (!_config.containsKey(PROP_THEME))
|
||||
_config.setProperty(PROP_THEME, DEFAULT_THEME);
|
||||
// Fetch theme
|
||||
_theme = _context.readConfigFile(THEME_CONFIG_FILE).getProperty(PROP_THEME, DEFAULT_THEME);
|
||||
updateConfig();
|
||||
}
|
||||
/**
|
||||
@ -295,8 +297,7 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
* @return String -- the current theme
|
||||
*/
|
||||
public String getTheme() {
|
||||
String theme = _config.getProperty(PROP_THEME);
|
||||
return theme;
|
||||
return _theme;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,8 +566,8 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
changed = true;
|
||||
}
|
||||
if (theme != null) {
|
||||
if(!theme.equals(_config.getProperty(PROP_THEME))) {
|
||||
_config.setProperty(PROP_THEME, theme);
|
||||
if(!theme.equals(_theme)) {
|
||||
_theme = theme;
|
||||
addMessage(_("{0} theme loaded, return to main i2psnark page to view.", theme));
|
||||
changed = true;
|
||||
}
|
||||
@ -661,6 +662,9 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
synchronized (_configFile) {
|
||||
DataHelper.storeProps(_config, _configFile);
|
||||
}
|
||||
Properties props = _context.readConfigFile(THEME_CONFIG_FILE);
|
||||
props.put(PROP_THEME, _theme);
|
||||
_context.writeConfigFile(THEME_CONFIG_FILE, props);
|
||||
} catch (IOException ioe) {
|
||||
addMessage(_("Unable to save the config to {0}", _configFile.getAbsolutePath()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user