[billreminder/fresh] Added initial code to handle adding and editing bills.



commit 7593a3cd2a7c838fbce05509e1b422ec6bdd88bf
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Thu Jan 21 13:36:19 2010 -0500

    Added initial code to handle adding and editing bills.

 src/gui/new.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/gui/new.py b/src/gui/new.py
index b75d8f8..22c0b7b 100755
--- a/src/gui/new.py
+++ b/src/gui/new.py
@@ -3,6 +3,7 @@
 
 import gtk
 from db import entities
+from lib import dialogs
 from lib import utils
 import widgets
 
@@ -146,6 +147,35 @@ class MainWindow:
 
         self.load_bills()
 
+    def on_add_clicked(self, button):
+        today = dt.date.today()
+        records = dialogs.add_dialog(parent=self.window, selectedDate=today)
+
+        # Checks if the user did not cancel the action
+        if records:
+            # Add new bill to database
+            for rec in records:
+                bill = self.actions.add(rec)
+                if bill:
+                    self.upcoming.add_bill(bill)
+            #self.update_statusbar()
+            # Reload records tree (something changed)
+            #self.reloadTreeView()
+            #self.reloadTimeline()
+
+    def on_edit_clicked(self, button):
+        current = self.upcoming.get_selected_bill()
+        if not current:
+            return
+
+        records = dialogs.edit_dialog(parent=self.window, record=current)
+
+        # Checks if the user did not cancel the action
+        if records:
+            for rec in records:
+                # Edit bill to database
+                rec = self.actions.edit(rec)
+
     def get_widget(self, name):
         """ skip one variable (huh) """
         return self.ui.get_object(name)



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