Mercurial > libervia-backend
annotate frontends/wix/gateways.py @ 29:df3b0b5ac49e
Wix: gateways manager => better presentation
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 08 Dec 2009 02:31:35 +0100 |
parents | c2b131e4e262 |
children | d6b613764dd7 |
rev | line source |
---|---|
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 | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
37 |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
38 #Fonts |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
39 self.normal_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
40 self.bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
41 self.italic_font = wx.Font(8, wx.DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
42 |
28 | 43 |
44 self.modified = {} # dict of modified data (i.e. what we have to save) | |
45 self.ctl_list = {} # usefull to access ctrl, key = (name, category) | |
46 | |
47 self.sizer = wx.BoxSizer(wx.VERTICAL) | |
48 self.panel = wx.Panel(self) | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
49 self.panel.sizer = wx.FlexGridSizer(cols=4) |
28 | 50 self.panel.SetSizer(self.panel.sizer) |
51 self.panel.SetAutoLayout(True) | |
52 self.sizer.Add(self.panel, 1, flag=wx.EXPAND) | |
53 self.SetSizer(self.sizer) | |
54 self.SetAutoLayout(True) | |
55 | |
56 #events | |
57 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
58 | |
59 self.MakeModal() | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
60 self.panel.sizer.Add(wx.Window(self.panel, -1)) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
61 title_name = wx.StaticText(self.panel, -1, "Name") |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
62 title_name.SetFont(self.bold_font) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
63 title_type = wx.StaticText(self.panel, -1, "Type") |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
64 title_type.SetFont(self.bold_font) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
65 self.panel.sizer.Add(title_name) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
66 self.panel.sizer.Add(title_type) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
67 self.panel.sizer.Add(wx.Window(self.panel, -1)) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
68 |
28 | 69 for gateway in gateways: |
70 self.addGateway(gateway, gateways[gateway]) | |
71 | |
72 | |
73 self.panel.sizer.Fit(self) | |
74 | |
75 self.Show() | |
76 | |
77 def addGateway(self, gateway, param): | |
78 | |
79 | |
80 | |
81 #First The icon | |
82 isz = (16,16) | |
83 im_icon = wx.StaticBitmap(self.panel, -1, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, isz)) | |
84 | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
85 #Then the name |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
86 |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
87 label=wx.StaticText(self.panel, -1, param['name']) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
88 label.SetFont(self.normal_font) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
89 |
28 | 90 #Then the transport type message |
91 | |
92 type_label_txt = 'Unknown IM' | |
93 | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
94 if param['type'] == 'irc': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
95 type_label_txt = "Internet Relay Chat" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
96 elif param['type'] == 'xmpp': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
97 type_label_txt = "XMPP" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
98 elif param['type'] == 'qq': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
99 type_label_txt = "Tencent QQ" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
100 elif param['type'] == 'simple': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
101 type_label_txt = "SIP/SIMPLE" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
102 elif param['type'] == 'icq': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
103 type_label_txt = "ICQ" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
104 elif param['type'] == 'yahoo': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
105 type_label_txt = "Yahoo! Messenger" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
106 elif param['type'] == 'gadu-gadu': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
107 type_label_txt = "Gadu-Gadu" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
108 elif param['type'] == 'aim': |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
109 type_label_txt = "AOL Instant Messenger" |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
110 elif param['type'] == 'msn': |
28 | 111 type_label_txt = 'Windows Live Messenger' |
112 | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
113 type_label_txt = type_label_txt |
28 | 114 |
115 type_label = wx.StaticText(self.panel, -1, type_label_txt) | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
116 type_label.SetFont(self.italic_font) |
28 | 117 |
118 #The buttons | |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
119 button_font = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD) |
28 | 120 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8)) |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
121 reg_button.SetFont(button_font) |
28 | 122 |
29
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
123 self.panel.sizer.Add(im_icon) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
124 self.panel.sizer.Add(label) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
125 self.panel.sizer.Add(type_label) |
df3b0b5ac49e
Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
126 self.panel.sizer.Add(reg_button, 1, wx.EXPAND) |
28 | 127 |
128 | |
129 def onClose(self, event): | |
130 """Close event""" | |
131 debug("close") | |
132 #now we save the modifier params | |
133 self.MakeModal(False) | |
134 event.Skip() | |
135 |