1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()
|