diff 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
line wrap: on
line diff
--- a/browser_side/dialog.py	Sat May 28 20:18:14 2011 +0200
+++ b/browser_side/dialog.py	Sun May 29 02:13:53 2011 +0200
@@ -87,9 +87,9 @@
     def onCancel(self):
         self.hide()
 
-class ConfirmDialog(DialogBox):
+class GenericConfirmDialog(DialogBox):
 
-    def __init__(self, callback, text='Are you sure ?'):
+    def __init__(self, widgets, callback, title='Confirmation'):
         """
         Dialog to confirm an action
         @param callback: method to call when contacts have been choosed
@@ -99,12 +99,14 @@
 
         content = VerticalPanel()
         content.setWidth('100%')
+        for wid in widgets:
+            content.add(wid)
         button_panel = HorizontalPanel()
         self.confirm_button = Button("OK", self.onConfirm)
         button_panel.add(self.confirm_button)
         button_panel.add(Button("Cancel", self.onCancel))
         content.add(button_panel)
-        self.setHTML(text)
+        self.setHTML(title)
         self.setWidget(content)	
     
     def onConfirm(self):
@@ -115,7 +117,12 @@
         self.hide()
         self.callback(False)
 
-class InfoDialog(DialogBox):
+class ConfirmDialog(GenericConfirmDialog):
+
+    def __init__(self, callback, text='Are you sure ?', title='Confirmation'):
+        GenericConfirmDialog.__init__(self,[HTML(text)], callback, title)
+
+class GenericDialog(DialogBox):
     """Dialog which just show a widget and a close button"""
 
     def __init__(self, title, widget, callback = None):
@@ -141,10 +148,10 @@
         if self.callback:
             self.callback()
 
-class SimpleDialog(InfoDialog):
+class InfoDialog(GenericDialog):
 
     def __init__(self, title, body, callback = None):
-        InfoDialog.__init__(self, title, HTML(body), callback)
+        GenericDialog.__init__(self, title, HTML(body), callback)
 
 class PopupPanelWrapper(PopupPanel):
     """This wrapper catch Escape event to avoid request cancellation by Firefox"""