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