[billreminder] Verify if the payee and amount fields are filled when adding new bill.



commit 33c4ad9355bb1f7bcfe07ed12ddadf36b7f5c743
Author: Luiz Armesto <luiz armesto gmail com>
Date:   Wed Dec 2 22:10:12 2009 -0200

    Verify if the payee and amount fields are filled when adding new bill.

 data/add_bill.ui     |    1 -
 src/gui/adddialog.py |   12 ++++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/data/add_bill.ui b/data/add_bill.ui
index 600cee1..704304e 100644
--- a/data/add_bill.ui
+++ b/data/add_bill.ui
@@ -338,7 +338,6 @@
     </child>
     <action-widgets>
       <action-widget response="0">cancel</action-widget>
-      <action-widget response="0">save</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/src/gui/adddialog.py b/src/gui/adddialog.py
index c0bdbd1..cda0592 100644
--- a/src/gui/adddialog.py
+++ b/src/gui/adddialog.py
@@ -394,16 +394,20 @@ class AddDialog(object):
                 return
 
     def on_save_clicked(self, widget):
+        message = utils.Message()
         if not self._get_payee().strip() and \
             not self.amount.get_text().strip():
             message.ShowError(_("\"%s\" and \"%s\" are required fields.") \
-                % (_("Payee"), _("Amount")), self)
+                % (_("Payee"), _("Amount")), self.window)
             self.payee.grab_focus()
         elif not self._get_payee().strip():
-            message.ShowError(_("\"%s\" is required field.") % _("Payee"), self)
+            message.ShowError(_("\"%s\" is required field.") % _("Payee"), self.window)
             self.payee.grab_focus()
-        
-        self.window.response(gtk.RESPONSE_ACCEPT)
+        elif not self.amount.get_text().strip():
+            message.ShowError(_("\"%s\" is required field.") % _("Amount"), self.window)
+            self.amount.grab_focus()
+        else:
+            self.window.response(gtk.RESPONSE_ACCEPT)
 
     def _on_datepicker_date_changed(self, widget, args):
         # Only reprogram alarm if it is not None



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]