diff browser_side/richtext.py @ 309:05e264e96a1c

browser_side: make unibox optional
author souliane <souliane@mailoo.org>
date Sun, 29 Dec 2013 23:07:28 +0100
parents ae3ec654836d
children 462a0a8894e3
line wrap: on
line diff
--- a/browser_side/richtext.py	Fri Dec 27 13:59:06 2013 +0100
+++ b/browser_side/richtext.py	Sun Dec 29 23:07:28 2013 +0100
@@ -71,6 +71,7 @@
 
         self._parent = parent
         self._on_close_callback = onCloseCallback
+        self.original_text = ''
 
         if not self.no_recipient:
             # recipient types sub-panels are automatically added by the manager
@@ -209,6 +210,8 @@
 
     def syncFromUniBox(self):
         """Synchronize from unibox."""
+        if not self.host.uni_box:
+            return
         data, target = self.host.uni_box.getTargetAndData()
         if hasattr(self, 'recipient'):
             self.recipient.setContacts({"To": [target]} if target else {})
@@ -220,6 +223,8 @@
         def setText():
             self.host.uni_box.setText("" if emptyText else self.textarea.getText())
 
+        if not self.host.uni_box:
+            return
         if not hasattr(self, 'recipient'):
             setText()
             return True
@@ -251,7 +256,7 @@
 
     def cancelWithoutSaving(self):
         """Ask for confirmation before closing the dialog."""
-        if self.update_msg and self.original_text and self.textarea.getText() == self.original_text:
+        if self.update_msg and self.textarea.getText() == self.original_text:
             self.__close(CANCEL)
             return