#
# Copyright (c) 2007-2008 INdT.
+# Copyright (c) 2011 Neal H. Walfield.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# Version : 0.6.1
# Description : Simple RSS Reader
# ============================================================================
+#try:
+# import gtk
+# import hildon
+# from gobject import idle_add
+#except:
+# pass
-import gtk
-import hildon
from ConfigParser import RawConfigParser
-from gobject import idle_add
from gconf import client_get_default
from urllib2 import ProxyHandler
+from mainthread import mainthread
+import logging
+logger = logging.getLogger(__name__)
-VERSION = "48"
+VERSION = "120"
section = "FeedingIt"
-ranges = { "updateInterval":[0.5, 1, 2, 4, 12, 24], "expiry":[24, 48, 72], "fontSize":range(12,24), "orientation":["Automatic", "Landscape", "Portrait"], "artFontSize":[10, 12, 14, 16, 18, 20]}
-titles = {"updateInterval":"Auto-update interval", "expiry":"Delete articles", "fontSize":"List font size", "orientation":"Display orientation", "artFontSize":"Article font size"}
-subtitles = {"updateInterval":"Every %s hours", "expiry":"After %s hours", "fontSize":"%s pixels", "orientation":"%s", "artFontSize":"%s pixels"}
+ranges = { "updateInterval":[0.5, 1, 2, 4, 8, 12, 24], "expiry":[24, 48, 72, 144, 288], "fontSize":range(12,24), "orientation":["Automatic", "Landscape", "Portrait"], "artFontSize":[10, 12, 14, 16, 18, 20], "feedsort":["Manual", "Most unread", "Least unread", "Most recent", "Least recent"] }
+titles = {"updateInterval":"Auto-update interval", "expiry":"Delete articles", "fontSize":"List font size", "orientation":"Display orientation", "artFontSize":"Article font size","feedsort":"Feed sort order"}
+subtitles = {"updateInterval":"Every %s hours", "expiry":"After %s hours", "fontSize":"%s pixels", "orientation":"%s", "artFontSize":"%s pixels", "feedsort":"%s"}
class Config():
def __init__(self, parent, configFilename):
self.window.destroy()
def createDialog(self):
-
+ import gtk
+ import hildon
+ from gobject import idle_add
self.window = gtk.Dialog("Settings", self.parent)
+ self.window.set_geometry_hints(min_height=600)
+
save_button = self.window.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_OK)
save_button.connect('clicked', self.on_save_button_clicked)
#self.window.set_default_size(-1, 600)
add_setting('fontSize')
add_setting('artFontSize')
add_setting('orientation')
+ add_setting('feedsort')
button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
button.set_label("Hide read feeds")
button.set_active(self.config["hidereadfeeds"])
heading('Updating')
- button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
- button.set_label("Automatically update feeds")
- button.set_active(self.config["autoupdate"])
- button.connect("toggled", self.button_toggled, "autoupdate")
- vbox.pack_start(button, expand=False)
- add_setting('updateInterval')
- add_setting('expiry')
+ label = gtk.Label(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ label.set_label("Use Woodchuck network daemon, or the home-screen widget for automatic updates.")
+ label.set_line_wrap(True)
+ vbox.pack_start(label, 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)
+ else:
+ 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)
+ add_setting('updateInterval')
+ add_setting('expiry')
heading('Network')
button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
button.set_label('Cache images')
button.set_active(self.config["imageCache"])
button.connect("toggled", self.button_toggled, "imageCache")
- vbox.pack_start(button, expand=False)
+ vbox.pack_start(button, expand=False)
button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
button.set_label("Use HTTP proxy")
button.connect("toggled", self.button_toggled, "proxy")
vbox.pack_start(button, expand=False)
+ button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ button.set_label('Open links in external browser')
+ button.set_active(self.config["extBrowser"])
+ button.connect("toggled", self.button_toggled, "extBrowser")
+ vbox.pack_start(button, expand=False)
+
panArea.add_with_viewport(vbox)
- self.window.vbox.add(panArea)
+ self.window.vbox.add(panArea)
self.window.connect("destroy", self.onExit)
#self.window.add(self.vbox)
self.window.set_default_size(-1, 600)
# When the dialog is closed without hitting
# the "Save" button, restore the configuration
if self.do_restore_backup:
- print 'Restoring configuration'
+ logger.debug('Restoring configuration')
self.config = self.config_backup
self.saveConfig()
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):
+ from gobject import idle_add
current_selection = selector.get_current_text()
if current_selection:
self.config[setting] = current_selection
def loadConfig(self):
self.config = {}
+
+ configParser = RawConfigParser()
try:
- configParser = RawConfigParser()
configParser.read(self.configFilename)
- self.config["fontSize"] = configParser.getint(section, "fontSize")
- self.config["artFontSize"] = configParser.getint(section, "artFontSize")
- self.config["expiry"] = configParser.getint(section, "expiry")
- self.config["autoupdate"] = configParser.getboolean(section, "autoupdate")
- self.config["updateInterval"] = configParser.getfloat(section, "updateInterval")
- self.config["orientation"] = configParser.get(section, "orientation")
- self.config["imageCache"] = configParser.getboolean(section, "imageCache")
- except:
- self.config["fontSize"] = 17
- self.config["artFontSize"] = 14
- self.config["expiry"] = 24
- self.config["autoupdate"] = False
- self.config["updateInterval"] = 4
- self.config["orientation"] = "Automatic"
- self.config["imageCache"] = False
- try:
- self.config["proxy"] = configParser.getboolean(section, "proxy")
- except:
- self.config["proxy"] = True
- try:
- self.config["hidereadfeeds"] = configParser.getboolean(section, "hidereadfeeds")
- self.config["hidereadarticles"] = configParser.getboolean(section, "hidereadarticles")
- except:
- self.config["hidereadfeeds"] = False
- self.config["hidereadarticles"] = False
-
+ except Exception:
+ logger.exception("Reading %s", self.configFilename)
+
+ # The function to use to fetch the parameter, the parameter's
+ # name and the default value.
+ values = ((configParser.getint, "fontSize", 17),
+ (configParser.getint, "artFontSize", 14),
+ (configParser.getint, "expiry", 24),
+ (configParser.getboolean, "autoupdate", False),
+ (configParser.getboolean, "woodchuck", True),
+ (configParser.getboolean, "askedAboutWoodchuck", False),
+ (configParser.getfloat, "updateInterval", 4),
+ (configParser.get, "orientation", "Automatic"),
+ (configParser.getboolean, "imageCache", False),
+ (configParser.getboolean, "proxy", True),
+ (configParser.getboolean, "hidereadfeeds", False),
+ (configParser.getboolean, "hidereadarticles", False),
+ (configParser.getboolean, "extBrowser", False),
+ (configParser.getboolean, "theme", True),
+ (configParser.get, "feedsort", "Manual"))
+
+ for fetcher, name, default in values:
+ try:
+ v = fetcher(section, name)
+ except Exception:
+ logger.exception("Reading config variable %s", name)
+ v = default
+ self.config[name] = v
+
def saveConfig(self):
configParser = RawConfigParser()
configParser.add_section(section)
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, 'askedAboutWoodchuck', str(self.config["askedAboutWoodchuck"]))
configParser.set(section, 'orientation', str(self.config["orientation"]))
configParser.set(section, 'imageCache', str(self.config["imageCache"]))
configParser.set(section, 'proxy', str(self.config["proxy"]))
configParser.set(section, 'hidereadfeeds', str(self.config["hidereadfeeds"]))
configParser.set(section, 'hidereadarticles', str(self.config["hidereadarticles"]))
+ configParser.set(section, 'extBrowser', str(self.config["extBrowser"]))
+ configParser.set(section, 'feedsort', str(self.config["feedsort"]))
+ configParser.set(section, 'theme', str(self.config["theme"]))
# Writing our configuration file
file = open(self.configFilename, 'wb')
file.close()
def create_selector(self, choices, setting):
+ import gtk
+ import hildon
+ from gobject import idle_add
#self.pickerDialog = hildon.PickerDialog(self.parent)
selector = hildon.TouchSelector(text=True)
index = 0
return self.config["artFontSize"]
def getExpiry(self):
return self.config["expiry"]
+ def setExpiry(self, expiry):
+ self.config["expiry"] = expiry
def isAutoUpdateEnabled(self):
return self.config["autoupdate"]
+ def setAutoUpdateEnabled(self, value):
+ self.config["autoupdate"] = value
+ def getWoodchuckEnabled(self):
+ return self.config["woodchuck"]
+ def getAskedAboutWoodchuck(self):
+ return self.config["askedAboutWoodchuck"]
+ def setAskedAboutWoodchuck(self, value):
+ self.config["askedAboutWoodchuck"] = value
+ self.saveConfig()
def getUpdateInterval(self):
return float(self.config["updateInterval"])
def getReadFont(self):
return "sans %s" % self.config["fontSize"]
def getOrientation(self):
return ranges["orientation"].index(self.config["orientation"])
+ def getOrientationChoices(self):
+ return ranges["orientation"]
+ def setOrientation(self, choice):
+ self.config["orientation"] = index
def getImageCache(self):
return self.config["imageCache"]
+ def setImageCache(self, cache):
+ self.config["imageCache"] = bool(cache)
+ @mainthread
def getProxy(self):
if self.config["proxy"] == False:
return (False, None)
return (False, None)
def getHideReadFeeds(self):
return self.config["hidereadfeeds"]
+ def setHideReadFeeds(self, setting):
+ self.config["hidereadfeeds"] = bool(setting)
def getHideReadArticles(self):
return self.config["hidereadarticles"]
+ def setHideReadArticles(self, setting):
+ self.config["hidereadarticles"] = bool(setting)
+ def getOpenInExternalBrowser(self):
+ return self.config["extBrowser"]
+ def getFeedSortOrder(self):
+ return self.config["feedsort"]
+ def getFeedSortOrderChoices(self):
+ return ranges["feedsort"]
+ def setFeedSortOrder(self, setting):
+ self.config["feedsort"] = setting
+ def getTheme(self):
+ return self.config["theme"]
+ def setTheme(self, theme):
+ self.config["theme"] = bool(theme)