import hildon
import ConfigParser
import gobject
+import gconf
+import urllib2
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]}
subtitles = {"updateInterval":"Update every %s hours", "expiry":"Delete articles after %s hours", "fontSize":"%s pixels", "orientation":"%s", "artFontSize":"%s pixels"}
class Config():
- def __init__(self, parent, configFilename):
+ def __init__(self, parent, configFilename, has_webkit):
self.configFilename = configFilename
self.parent = parent
+ self.has_webkit = has_webkit
# Load config
self.loadConfig()
vbox = gtk.VBox(False, 10)
self.buttons = {}
- for setting in ["fontSize", "artFontSize", "expiry", "orientation", "updateInterval",]:
+ if self.has_webkit:
+ settings = ["fontSize", "artFontSize", "expiry", "orientation", "updateInterval",]
+ else:
+ settings = ["fontSize", "expiry", "orientation", "updateInterval",]
+ for setting in settings:
picker = hildon.PickerButton(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
selector = self.create_selector(ranges[setting], setting)
picker.set_selector(selector)
picker.set_name('HildonButton-finger')
picker.set_alignment(0,0,1,1)
self.buttons[setting] = picker
- vbox.pack_start(picker)
+ vbox.pack_start(picker, expand=False)
button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
button.set_label("Auto-update Enabled")
button.set_active(self.config["autoupdate"])
- button.connect("toggled", self.button_toggled)
+ button.connect("toggled", self.button_toggled, "autoupdate")
+ vbox.pack_start(button, expand=False)
+
+ if self.has_webkit:
+ button = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
+ button.set_label("Webkit Articles Enabled")
+ button.set_active(self.config["webkit"])
+ button.connect("toggled", self.button_toggled, "webkit")
+ vbox.pack_start(button, expand=False)
- vbox.pack_start(button)
panArea.add_with_viewport(vbox)
self.window.vbox.add(panArea)
self.saveConfig()
self.window.destroy()
- def button_toggled(self, widget):
+ def button_toggled(self, widget, configName):
#print "widget", widget.get_active()
if (widget.get_active()):
- self.config["autoupdate"] = True
+ self.config[configName] = True
else:
- self.config["autoupdate"] = False
+ self.config[configName] = False
#print "autoup", self.autoupdate
self.saveConfig()
self.config["autoupdate"] = configParser.getboolean(section, "autoupdate")
self.config["updateInterval"] = configParser.getfloat(section, "updateInterval")
self.config["orientation"] = configParser.get(section, "orientation")
+ self.config["webkit"] = configParser.getboolean(section, "webkit")
except:
- self.config["fontSize"] = 16
- self.config["artFontSize"] = 18
+ 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["webkit"] = self.has_webkit
def saveConfig(self):
configParser = ConfigParser.RawConfigParser()
configParser.set(section, 'autoupdate', str(self.config["autoupdate"]))
configParser.set(section, 'updateInterval', str(self.config["updateInterval"]))
configParser.set(section, 'orientation', str(self.config["orientation"]))
+ configParser.set(section, 'webkit', str(self.config["webkit"]))
# Writing our configuration file
file = open(self.configFilename, 'wb')
def getUnreadFont(self):
return "sans bold %s" % self.config["fontSize"]
def getOrientation(self):
- return ranges["orientation"].index(self.config["orientation"])
\ No newline at end of file
+ return ranges["orientation"].index(self.config["orientation"])
+ def getWebkitSupport(self):
+ if self.has_webkit:
+ return self.config["webkit"]
+ else:
+ return False
+ def getProxy(self):
+ if gconf.client_get_default().get_bool('/system/http_proxy/use_http_proxy'):
+ port = gconf.client_get_default().get_int('/system/http_proxy/port')
+ http = gconf.client_get_default().get_string('/system/http_proxy/host')
+ proxy = proxy = urllib2.ProxyHandler( {"http":"http://%s:%s/"% (http,port)} )
+ return (True, proxy)
+ return (False, None)
\ No newline at end of file