From a0297c212e5a9a4c2c478e538c23ddd0e96ac56e Mon Sep 17 00:00:00 2001 From: Thomas Keck Date: Sat, 13 Mar 2010 14:00:42 +0100 Subject: First mockup of an gui --- gui.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ proxy.py | 5 +++++ 2 files changed, 61 insertions(+) create mode 100644 gui.py diff --git a/gui.py b/gui.py new file mode 100644 index 0000000..8c82434 --- /dev/null +++ b/gui.py @@ -0,0 +1,56 @@ +#!/usr/bin/python -t +from threading import Thread +import gtk, sys, proxy, time + +gtk.gdk.threads_init() + +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): + pass + def on_quit(self, widget): + if self.proxy: + self.proxy.shutdown() + gtk.main_quit(widget) + +ProxyGUI() +gtk.main() + diff --git a/proxy.py b/proxy.py index 44c7365..da30636 100755 --- a/proxy.py +++ b/proxy.py @@ -217,6 +217,11 @@ class HTTPProxyServer(asyncore.dispatcher): self.bind(("", 8080)) self.listen(5) + def shutdown(self): + #TODO Hier Proxy sauber beenden + #self.channel.close_when_done() + sys.exit() + def handle_accept(self): conn, addr = self.accept() HTTPChannel(self, conn, addr) -- cgit v1.2.1