28
|
1 #!/usr/bin/python |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 """ |
|
5 wix: a SAT frontend |
|
6 Copyright (C) 2009 Jérôme Poisson (goffi@goffi.org) |
|
7 |
|
8 This program is free software: you can redistribute it and/or modify |
|
9 it under the terms of the GNU General Public License as published by |
|
10 the Free Software Foundation, either version 3 of the License, or |
|
11 (at your option) any later version. |
|
12 |
|
13 This program is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 """ |
|
21 |
|
22 |
|
23 |
|
24 import wx |
|
25 import pdb |
|
26 from xml.dom import minidom |
|
27 from logging import debug, info, error |
|
28 from tools.jid import JID |
|
29 |
|
30 |
|
31 class GatewaysManager(wx.Frame): |
|
32 def __init__(self, host, gateways, title="Gateways manager"): |
|
33 super(GatewaysManager, self).__init__(None, title=title) |
|
34 |
|
35 self.host = host |
|
36 #self.gateways = gateways |
|
37 |
|
38 self.modified = {} # dict of modified data (i.e. what we have to save) |
|
39 self.ctl_list = {} # usefull to access ctrl, key = (name, category) |
|
40 |
|
41 self.sizer = wx.BoxSizer(wx.VERTICAL) |
|
42 self.panel = wx.Panel(self) |
|
43 self.panel.sizer = wx.BoxSizer(wx.VERTICAL) |
|
44 self.panel.SetSizer(self.panel.sizer) |
|
45 self.panel.SetAutoLayout(True) |
|
46 self.sizer.Add(self.panel, 1, flag=wx.EXPAND) |
|
47 self.SetSizer(self.sizer) |
|
48 self.SetAutoLayout(True) |
|
49 |
|
50 #events |
|
51 self.Bind(wx.EVT_CLOSE, self.onClose, self) |
|
52 |
|
53 self.MakeModal() |
|
54 |
|
55 for gateway in gateways: |
|
56 self.addGateway(gateway, gateways[gateway]) |
|
57 |
|
58 |
|
59 self.panel.sizer.Fit(self) |
|
60 |
|
61 self.Show() |
|
62 |
|
63 def addGateway(self, gateway, param): |
|
64 sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
65 |
|
66 bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD) |
|
67 italic_font = wx.Font(8, wx.DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL) |
|
68 |
|
69 |
|
70 #First The icon |
|
71 isz = (16,16) |
|
72 im_icon = wx.StaticBitmap(self.panel, -1, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, isz)) |
|
73 |
|
74 #Then the transport type message |
|
75 |
|
76 type_label_txt = 'Unknown IM' |
|
77 |
|
78 if param['type'] == 'msn': |
|
79 type_label_txt = 'Windows Live Messenger' |
|
80 |
|
81 type_label_txt = " " + type_label_txt + " " |
|
82 |
|
83 type_label = wx.StaticText(self.panel, -1, type_label_txt) |
|
84 type_label.SetFont(bold_font) |
|
85 |
|
86 #Then the name |
|
87 |
|
88 label=wx.StaticText(self.panel, -1, '('+param['name']+')') |
|
89 label.SetFont(italic_font) |
|
90 |
|
91 #The buttons |
|
92 bold_font2 = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD) |
|
93 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8)) |
|
94 reg_button.SetFont(bold_font2) |
|
95 |
|
96 sizer.Add(im_icon) |
|
97 sizer.Add(type_label) |
|
98 sizer.Add(label, 1, wx.EXPAND) |
|
99 sizer.Add(reg_button, 1, wx.EXPAND) |
|
100 self.panel.sizer.Add(sizer, flag=wx.EXPAND) |
|
101 |
|
102 |
|
103 def onClose(self, event): |
|
104 """Close event""" |
|
105 debug("close") |
|
106 #now we save the modifier params |
|
107 self.MakeModal(False) |
|
108 event.Skip() |
|
109 |