summaryrefslogtreecommitdiff
path: root/magicproxy/gui.py
diff options
context:
space:
mode:
authorYves <yvesf-git@xapek.org>2010-04-02 20:48:13 +0200
committerYves <yvesf-git@xapek.org>2010-04-02 20:48:13 +0200
commitc18e0ab17a23ddef42768151c6905818ad1d40d3 (patch)
tree7a0916edd1cfb8d6dd9512c30f0ba4cf313ce2a9 /magicproxy/gui.py
parentfe7a395f73bd2fbb9e01d24910722cc13c0ee649 (diff)
downloadmagicproxy-c18e0ab17a23ddef42768151c6905818ad1d40d3.tar.gz
magicproxy-c18e0ab17a23ddef42768151c6905818ad1d40d3.zip
lays a egg
Diffstat (limited to 'magicproxy/gui.py')
-rw-r--r--magicproxy/gui.py88
1 files changed, 88 insertions, 0 deletions
diff --git a/magicproxy/gui.py b/magicproxy/gui.py
new file mode 100644
index 0000000..441a1f2
--- /dev/null
+++ b/magicproxy/gui.py
@@ -0,0 +1,88 @@
+#!/usr/bin/python -t
+from threading import Thread
+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):
+ print self.time_slice.get_value()
+ proxy.TIME_SLICE = self.time_slice.get_value()
+ self.destroy()
+
+
+class ProxyGUI(gtk.Window):
+ def __init__(self):
+ super(ProxyGUI, self).__init__(gtk.WINDOW_TOPLEVEL)
+
+ self.set_border_width(8)
+ self.set_title("Magicproxy GUI client")
+ self.set_resizable(False)
+
+ table = gtk.Table(rows=2, columns=2, homogeneous=False);
+
+ b_endpoints = gtk.Button("Configure Endpoints")
+ b_start = gtk.Button("Start")
+ b_stop = gtk.Button("Stop")
+ b_settings = gtk.Button("Configure Settings")
+ b_quit = gtk.Button("Quit")
+
+ b_endpoints.connect("clicked", self.on_endpoints)
+ b_start.connect("clicked", self.on_start)
+ b_settings.connect("clicked", self.on_settings)
+ b_quit.connect("clicked", self.on_quit)
+ self.connect("destroy", self.on_quit)
+
+ table.attach(b_endpoints, 0, 1, 0, 1)
+ table.attach(b_start, 1, 2, 0, 1)
+ table.attach(b_settings, 0, 1, 1, 2)
+ table.attach(b_quit, 1, 2, 1, 2)
+
+ self.add(table)
+ self.show_all()
+
+ self.proxy = None
+
+ 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):
+ Settings()
+
+ def on_quit(self, widget):
+ if self.proxy:
+ self.proxy.shutdown()
+ gtk.main_quit(widget)
+
+ProxyGUI()
+gtk.main()
+