[hamster-applet] small bug with the deletion selection



commit a97b068b9e3daac558dcc5b216b3e9e07aa90bd5
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Jan 18 09:05:43 2010 +0000

    small bug with the deletion selection

 hamster/overview_activities.py |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/hamster/overview_activities.py b/hamster/overview_activities.py
index d94e621..057729c 100644
--- a/hamster/overview_activities.py
+++ b/hamster/overview_activities.py
@@ -70,7 +70,7 @@ class OverviewBox(gtk.VBox):
 
 
     def fill_facts_tree(self):
-        # remember any selection - will try to match by        
+        # remember any selection - will try to match by
         self.fact_tree.detach_model()
         self.fact_tree.clear()
 
@@ -91,22 +91,11 @@ class OverviewBox(gtk.VBox):
 
 
     def delete_selected(self):
-        selection = self.fact_tree.get_selection()
-        (model, iter) = selection.get_selected()
-
-        if model[iter][0] == -1:
-            return #not a fact
-
-        next_row = model.iter_next(iter)
-
-        if next_row:
-            selection.select_iter(next_row)
-        else:
-            path = model.get_path(iter)[0] - 1
-            if path > 0:
-                selection.select_path(path)
+        fact = self.fact_tree.get_selected_fact()
+        if not fact or isinstance(fact, dt.date):
+            return
 
-        runtime.storage.remove_fact(model[iter][0])
+        runtime.storage.remove_fact(fact['id'])
 
     def copy_selected(self):
         selection = self.fact_tree.get_selection()
@@ -136,7 +125,7 @@ class OverviewBox(gtk.VBox):
 
     def on_facts_row_activated(self, tree, path, column):
         self.launch_edit(tree.get_selected_fact())
-            
+
     def launch_edit(self, fact_or_date):
         if isinstance(fact_or_date, dt.date):
             dialogs.edit.show(self, fact_date = fact_or_date)



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