comparison browser_side/dialog.py @ 55:d5266c41ca24

Roster list update, contact deletion + some refactoring
author Goffi <goffi@goffi.org>
date Sun, 29 May 2011 02:13:53 +0200
parents f25c4077f6b9
children e552a67b933d
comparison
equal deleted inserted replaced
54:f25c4077f6b9 55:d5266c41ca24
85 self.callback(self.contacts_list.getSelectedValues()) 85 self.callback(self.contacts_list.getSelectedValues())
86 86
87 def onCancel(self): 87 def onCancel(self):
88 self.hide() 88 self.hide()
89 89
90 class ConfirmDialog(DialogBox): 90 class GenericConfirmDialog(DialogBox):
91 91
92 def __init__(self, callback, text='Are you sure ?'): 92 def __init__(self, widgets, callback, title='Confirmation'):
93 """ 93 """
94 Dialog to confirm an action 94 Dialog to confirm an action
95 @param callback: method to call when contacts have been choosed 95 @param callback: method to call when contacts have been choosed
96 """ 96 """
97 self.callback = callback 97 self.callback = callback
98 DialogBox.__init__(self, centered=True) 98 DialogBox.__init__(self, centered=True)
99 99
100 content = VerticalPanel() 100 content = VerticalPanel()
101 content.setWidth('100%') 101 content.setWidth('100%')
102 for wid in widgets:
103 content.add(wid)
102 button_panel = HorizontalPanel() 104 button_panel = HorizontalPanel()
103 self.confirm_button = Button("OK", self.onConfirm) 105 self.confirm_button = Button("OK", self.onConfirm)
104 button_panel.add(self.confirm_button) 106 button_panel.add(self.confirm_button)
105 button_panel.add(Button("Cancel", self.onCancel)) 107 button_panel.add(Button("Cancel", self.onCancel))
106 content.add(button_panel) 108 content.add(button_panel)
107 self.setHTML(text) 109 self.setHTML(title)
108 self.setWidget(content) 110 self.setWidget(content)
109 111
110 def onConfirm(self): 112 def onConfirm(self):
111 self.hide() 113 self.hide()
112 self.callback(True) 114 self.callback(True)
113 115
114 def onCancel(self): 116 def onCancel(self):
115 self.hide() 117 self.hide()
116 self.callback(False) 118 self.callback(False)
117 119
118 class InfoDialog(DialogBox): 120 class ConfirmDialog(GenericConfirmDialog):
121
122 def __init__(self, callback, text='Are you sure ?', title='Confirmation'):
123 GenericConfirmDialog.__init__(self,[HTML(text)], callback, title)
124
125 class GenericDialog(DialogBox):
119 """Dialog which just show a widget and a close button""" 126 """Dialog which just show a widget and a close button"""
120 127
121 def __init__(self, title, widget, callback = None): 128 def __init__(self, title, widget, callback = None):
122 """Simple notice dialog box 129 """Simple notice dialog box
123 @param title: HTML put in the header 130 @param title: HTML put in the header
139 def onClose(self): 146 def onClose(self):
140 self.hide() 147 self.hide()
141 if self.callback: 148 if self.callback:
142 self.callback() 149 self.callback()
143 150
144 class SimpleDialog(InfoDialog): 151 class InfoDialog(GenericDialog):
145 152
146 def __init__(self, title, body, callback = None): 153 def __init__(self, title, body, callback = None):
147 InfoDialog.__init__(self, title, HTML(body), callback) 154 GenericDialog.__init__(self, title, HTML(body), callback)
148 155
149 class PopupPanelWrapper(PopupPanel): 156 class PopupPanelWrapper(PopupPanel):
150 """This wrapper catch Escape event to avoid request cancellation by Firefox""" 157 """This wrapper catch Escape event to avoid request cancellation by Firefox"""
151 158
152 def onEventPreview(self, event): 159 def onEventPreview(self, event):