summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Keck <thomas@macbook.macbook>2010-03-13 16:19:20 +0100
committerThomas Keck <thomas@macbook.macbook>2010-03-13 16:19:20 +0100
commit94e33924fad7b7a38d6d1e848d01b5e830a45360 (patch)
treeb08a8651d4ef44c4b39193b54ab5683bef453658
parenta0297c212e5a9a4c2c478e538c23ddd0e96ac56e (diff)
downloadmagicproxy-94e33924fad7b7a38d6d1e848d01b5e830a45360.tar.gz
magicproxy-94e33924fad7b7a38d6d1e848d01b5e830a45360.zip
First setting implemented
-rw-r--r--gui.py35
-rwxr-xr-xproxy.py2
2 files changed, 34 insertions, 3 deletions
diff --git a/gui.py b/gui.py
index 8c82434..423d1e3 100644
--- a/gui.py
+++ b/gui.py
@@ -4,6 +4,36 @@ import gtk, sys, proxy, time
gtk.gdk.threads_init()
+class Settings(gtk.Window):
+ def __init__(self):
+ super(Settings, self).__init__(gtk.WINDOW_TOPLEVEL)
+
+ self.set_border_width(8)
+ self.set_title("Magicproxy GUI client settings")
+ self.set_resizable(False)
+
+ table = gtk.Table(rows=3, columns=3, homogeneous=True);
+
+ b_quit = gtk.Button("Quit")
+ b_quit.connect("clicked", self.on_quit)
+ label = gtk.Label("Time Slice")
+ self.time_slice = gtk.HScale()
+ self.time_slice.set_range(1,100)
+ self.time_slice.set_increments(1,1)
+ self.time_slice.set_value(proxy.TIME_SLICE)
+
+ table.attach(label,0,1,0,1)
+ table.attach(self.time_slice,2,3,0,1,xoptions=gtk.FILL)
+ table.attach(b_quit,0,3,2,3)
+
+ self.add(table)
+ self.show_all()
+
+ def on_quit(self, widget):
+ proxy.TIME_SLICE = self.time_slice.get_value()
+ self.destroy()
+
+
class ProxyGUI(gtk.Window):
def __init__(self):
super(ProxyGUI, self).__init__(gtk.WINDOW_TOPLEVEL)
@@ -31,7 +61,6 @@ class ProxyGUI(gtk.Window):
table.attach(b_settings, 0, 1, 1, 2)
table.attach(b_quit, 1, 2, 1, 2)
-
self.add(table)
self.show_all()
@@ -39,13 +68,15 @@ class ProxyGUI(gtk.Window):
def on_endpoints(self, widget):
pass
+
def on_start(self, widget):
if not self.proxy:
self.proxy = proxy.HTTPProxyServer()
Thread(target=proxy.asyncore.loop).start()
def on_settings(self, widget):
- pass
+ Settings()
+
def on_quit(self, widget):
if self.proxy:
self.proxy.shutdown()
diff --git a/proxy.py b/proxy.py
index da30636..0b63c52 100755
--- a/proxy.py
+++ b/proxy.py
@@ -122,7 +122,7 @@ class MultipleProxyReader(object):
and self.fetch_pos + 1 < self.content_length and not self.channel.is_closed \
and len( filter( (lambda f: f.proxy == fetcher.proxy), self.fetchers) ) < 2:
#Start a new fetcher on this line if this fetchers is X-Bytes before finishing his jobs
- blocksize = min(TIME_SLICE * int(fetcher.speed()), MIN_BLOCKSIZE)
+ blocksize = min(int(TIME_SLICE * fetcher.speed()), MIN_BLOCKSIZE)
fetch_range = self.next_range(blocksize)
print "Start new Fetcher, bs=%s range=%s" % (blocksize,fetch_range)
self.fetchers.append( Fetcher(self, fetcher.proxy, self.url, self.header, fetch_range) )