comparison frontends/primitivus/gateways.py @ 222:3198bfd66daa

primitivus: refactoring to use urwid-satext which is now a separate project
author Goffi <goffi@goffi.org>
date Tue, 28 Dec 2010 23:10:13 +0100
parents 8537df794f74
children
comparison
equal deleted inserted replaced
221:96186f36d8cb 222:3198bfd66daa
18 You should have received a copy of the GNU General Public License 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/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 import urwid 22 import urwid
23 import custom_widgets 23 from urwid_satext import sat_widgets
24 from tools.jid import JID 24 from tools.jid import JID
25 from quick_frontend.quick_gateways import QuickGatewaysManager 25 from quick_frontend.quick_gateways import QuickGatewaysManager
26 26
27 27
28 class GatewaysManager(urwid.WidgetWrap, QuickGatewaysManager): 28 class GatewaysManager(urwid.WidgetWrap, QuickGatewaysManager):
35 widget_list.append(urwid.Text(self.WARNING_MSG)) 35 widget_list.append(urwid.Text(self.WARNING_MSG))
36 widget_list.append(urwid.Divider('-')) 36 widget_list.append(urwid.Divider('-'))
37 for gateway in gateways: 37 for gateway in gateways:
38 self.addGateway(widget_list,gateway, gateways[gateway]) 38 self.addGateway(widget_list,gateway, gateways[gateway])
39 widget_list.append(urwid.Divider()) 39 widget_list.append(urwid.Divider())
40 self.ext_serv = custom_widgets.AdvancedEdit(_("Use external XMPP server: ")) 40 self.ext_serv = sat_widgets.AdvancedEdit(_("Use external XMPP server: "))
41 go_button = custom_widgets.CustomButton( _("GO !"),self.browseExternalServer) 41 go_button = sat_widgets.CustomButton( _("GO !"),self.browseExternalServer)
42 ext_serv_col = urwid.Columns([self.ext_serv,('fixed',go_button.getSize(),go_button)]) 42 ext_serv_col = urwid.Columns([self.ext_serv,('fixed',go_button.getSize(),go_button)])
43 widget_list.append(ext_serv_col) 43 widget_list.append(ext_serv_col)
44 list_wid = urwid.ListBox(widget_list) 44 list_wid = urwid.ListBox(widget_list)
45 decorated = custom_widgets.LabelLine(list_wid, custom_widgets.SurroundedText(title)) 45 decorated = sat_widgets.LabelLine(list_wid, sat_widgets.SurroundedText(title))
46 urwid.WidgetWrap.__init__(self, decorated) 46 urwid.WidgetWrap.__init__(self, decorated)
47 47
48 def browseExternalServer(self, button): 48 def browseExternalServer(self, button):
49 """Open the gateway manager on given server""" 49 """Open the gateway manager on given server"""
50 server = self.ext_serv.get_edit_text() 50 server = self.ext_serv.get_edit_text()
51 if not server: 51 if not server:
52 popup = custom_widgets.Alert(_("Error"), _("You must enter an external server JID"), ok_cb=self.host.removePopUp) 52 popup = sat_widgets.Alert(_("Error"), _("You must enter an external server JID"), ok_cb=self.host.removePopUp)
53 self.host.showPopUp(popup) 53 self.host.showPopUp(popup)
54 return 54 return
55 id = self.host.bridge.findGateways(server, self.host.profile) 55 id = self.host.bridge.findGateways(server, self.host.profile)
56 self.host.current_action_ids.add(id) 56 self.host.current_action_ids.add(id)
57 self.host.current_action_ids_cb[id] = self.host.onGatewaysFound 57 self.host.current_action_ids_cb[id] = self.host.onGatewaysFound
65 #Then the transport type message 65 #Then the transport type message
66 widget_col.append(('weight',6,urwid.Text(self.getGatewayDesc(param['type'])))) 66 widget_col.append(('weight',6,urwid.Text(self.getGatewayDesc(param['type']))))
67 67
68 #The buttons 68 #The buttons
69 69
70 reg_button = custom_widgets.CustomButton( _("Register"), self.onRegister) 70 reg_button = sat_widgets.CustomButton( _("Register"), self.onRegister)
71 reg_button.gateway_jid = JID(gateway) 71 reg_button.gateway_jid = JID(gateway)
72 widget_col.append(('fixed',reg_button.getSize(),reg_button)) 72 widget_col.append(('fixed',reg_button.getSize(),reg_button))
73 unreg_button = custom_widgets.CustomButton( _("Unregister"), self.onUnregister) 73 unreg_button = sat_widgets.CustomButton( _("Unregister"), self.onUnregister)
74 unreg_button.gateway_jid = JID(gateway) 74 unreg_button.gateway_jid = JID(gateway)
75 widget_col.append(('fixed',unreg_button.getSize(),unreg_button)) 75 widget_col.append(('fixed',unreg_button.getSize(),unreg_button))
76 widget_list.append(urwid.Columns(widget_col,1)) 76 widget_list.append(urwid.Columns(widget_col,1))
77 77
78 def onRegister(self, button): 78 def onRegister(self, button):