Added checkbox to console to set theme universally across all apps

This commit is contained in:
str4d
2012-07-22 06:53:43 +00:00
parent 3c4f1b7814
commit 8e6bade42b
2 changed files with 20 additions and 7 deletions

View File

@ -1,10 +1,12 @@
package net.i2p.router.web;
import java.util.Iterator;
import java.util.Properties;
/** set the theme */
public class ConfigUIHandler extends FormHandler {
private boolean _shouldSave;
private boolean _universalTheming;
private String _config;
@Override
@ -15,6 +17,8 @@ public class ConfigUIHandler extends FormHandler {
public void setShouldsave(String moo) { _shouldSave = true; }
public void setUniversalTheming(String baa) { _universalTheming = true; }
public void setTheme(String val) {
_config = val;
}
@ -25,12 +29,18 @@ public class ConfigUIHandler extends FormHandler {
return;
Properties props = _context.readConfigFile(CSSHelper.THEME_CONFIG_FILE);
String oldTheme = props.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
boolean ok;
if (_config.equals("default")) // obsolete
props.put(CSSHelper.PROP_THEME_NAME, null);
else
props.put(CSSHelper.PROP_THEME_NAME, _config);
ok = _context.writeConfigFile(CSSHelper.THEME_CONFIG_FILE, props);
if (_universalTheming) {
for (Iterator it = props.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
props.put(key, _config);
}
} else {
if (_config.equals("default")) // obsolete
props.put(CSSHelper.PROP_THEME_NAME, null);
else
props.put(CSSHelper.PROP_THEME_NAME, _config);
}
boolean ok = _context.writeConfigFile(CSSHelper.THEME_CONFIG_FILE, props);
if (ok) {
if (!oldTheme.equals(_config))
addFormNotice(_("Theme change saved.") +

View File

@ -17,6 +17,9 @@ public class ConfigUIHelper extends HelperBase {
buf.append("checked=\"checked\" ");
buf.append("value=\"").append(theme).append("\">").append(_(theme)).append("<br>\n");
}
buf.append("<input type=\"checkbox\" name=\"universalTheming\" value=\"1\">")
.append(_("Set theme universally across all apps"))
.append("<br>\n");
return buf.toString();
}