heading('Updating')
button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
- button.set_label("Automatically update feeds")
+ button.set_label("Time-Based Automatic Update\n"
+ + "(requires use of FeedingIt widget)")
button.set_active(self.config["autoupdate"])
button.connect("toggled", self.button_toggled, "autoupdate")
vbox.pack_start(button, expand=False)
+ button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ button.set_label("Woodchuck-Based Automatic Update")
+ button.set_active(self.config["woodchuck"])
+ button.connect("toggled", self.button_toggled, "woodchuck")
+ vbox.pack_start(button, expand=False)
+
+ try:
+ import woodchuck
+ woodchuck_installed = True
+ except ImportError:
+ woodchuck_installed = False
+
+ if not woodchuck_installed:
+ def install_woodchuck_clicked(button):
+ from FeedingIt import open_in_browser
+ open_in_browser("http://maemo.org/downloads/product/raw/Maemo5/murmeltier?get_installfile")
+
+ button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ button.set_label("Install Woodchuck")
+ button.connect("clicked", install_woodchuck_clicked)
+ button.set_alignment(0,0,1,1)
+ vbox.pack_start(button, expand=False)
+
add_setting('updateInterval')
add_setting('expiry')
else:
self.config[configName] = False
#print "autoup", self.autoupdate
+
+ if configName == 'woodchuck':
+ try:
+ from wc import wc_disable_set
+ wc_disable_set(not self.config['woodchuck'])
+ except Exception:
+ logger.exception("Disabling Woodchuck")
+
self.saveConfig()
def selection_changed(self, selector, button, setting):
(configParser.getint, "artFontSize", 14),
(configParser.getint, "expiry", 24),
(configParser.getboolean, "autoupdate", False),
+ (configParser.getboolean, "woodchuck", True),
(configParser.getint, "updateInterval", 4),
(configParser.get, "orientation", "Automatic"),
(configParser.getboolean, "imageCache", False),
configParser.set(section, 'expiry', str(self.config["expiry"]))
configParser.set(section, 'autoupdate', str(self.config["autoupdate"]))
configParser.set(section, 'updateInterval', str(self.config["updateInterval"]))
+ configParser.set(section, 'woodchuck', str(self.config["woodchuck"]))
configParser.set(section, 'orientation', str(self.config["orientation"]))
configParser.set(section, 'imageCache', str(self.config["imageCache"]))
configParser.set(section, 'proxy', str(self.config["proxy"]))
return self.config["expiry"]
def isAutoUpdateEnabled(self):
return self.config["autoupdate"]
+ def getWoodchuckEnabled(self):
+ return self.config["woodchuck"]
def getUpdateInterval(self):
return float(self.config["updateInterval"])
def getReadFont(self):
% traceback.format_exc ())
woodchuck_imported = False
class PyWoodchuck (object):
- def available(self):
+ def available(self, *args, **kwargs):
return False
woodchuck = None
refresh_interval = 6 * 60 * 60
class mywoodchuck (PyWoodchuck):
- def __init__(self, listing, human_readable_name, identifier,
+ def __init__(self, config, listing, human_readable_name, identifier,
request_feedback):
try:
PyWoodchuck.__init__ (self, human_readable_name, identifier,
self.available = self.not_available
return
+ self.config = config
self.listing = listing
- def not_available(self):
+ try:
+ self.enabled = config.getWoodchuckEnabled()
+ except Exception:
+ logging.exception("Setting enabled")
+
+ def available(self, check_config=True):
+ if not PyWoodchuck.available(self):
+ return False
+ if check_config:
+ return self.config.getWoodchuckEnabled()
+ return True
+
+ def not_available(self, *args, **kwargs):
return False
# Woodchuck upcalls.
str(e)))
_w = None
-def wc_init(listing, request_feedback=False):
+def wc_init(config, listing, request_feedback=False):
"""Connect to the woodchuck server and initialize any state."""
global _w
assert _w is None
- _w = mywoodchuck (listing, "FeedingIt", "org.marcoz.feedingit",
+ _w = mywoodchuck (config, listing, "FeedingIt", "org.marcoz.feedingit",
request_feedback)
if not woodchuck_imported or not _w.available ():
else:
logger.debug("Woodchuck appears to be available.")
+def wc_disable_set(disable=True):
+ """Disable Woodchuck."""
+ if disable:
+ logger.info("Disabling Woodchuck")
+ else:
+ logger.info("Enabling Woodchuck")
+
+ global _w
+ if _w is None:
+ logging.info("Woodchuck not loaded. Not doing anything.")
+ return
+
+ if not _w.available(check_config=False):
+ logging.info("Woodchuck not available. Not doing anything.")
+ return
+
+ try:
+ _w.enabled = not disable
+ except Exception:
+ logger.exception("Disabling Woodchuck")
+
def wc():
"""Return the Woodchuck singleton."""
global _w