[Getan-commits] [PATCH 17 of 32] Avoid resetting the focus when changing from DeleteEntryState back to the

Wald Commits scm-commit at wald.intevation.org
Fri Oct 11 14:34:01 CEST 2013


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1381486146 -7200
# Node ID dc92981ec59193992ef1d63b7cb8182ba8b7cc0d
# Parent  349b4571e1209dc5ffae4f67c51b0721635bbdd5
Avoid resetting the focus when changing from DeleteEntryState back to the
DefaultEntryListState

This change will avoids resetting the focus of the current entry in the
EntryList to the first entry.

diff -r 349b4571e120 -r dc92981ec591 getan/states.py
--- a/getan/states.py	Fri Oct 11 12:06:42 2013 +0200
+++ b/getan/states.py	Fri Oct 11 12:09:06 2013 +0200
@@ -523,11 +523,13 @@
         if keys.get_entry_delete() in key:
             if self.view.selection:
                 self.set_next_state(DeleteEntryState(self.projectlist_state,
+                                                     self,
                                                      self.controller,
                                                      self.view))
             else:
                 entry = self.view.item_in_focus()
                 self.set_next_state(DeleteEntryState(self.projectlist_state,
+                                                     self,
                                                      self.controller, self.view,
                                                      [entry]))
             return True
@@ -555,10 +557,11 @@
         'delete': _("Really delete this entry? (y/n)"),
     }
 
-    def __init__(self, state, controller, view, entries=None):
+    def __init__(self, state, old_state, controller, view, entries=None):
         super(DeleteEntryState, self).__init__(state, controller, view)
         self.view.set_footer_text(self.msg('delete'), 'question')
         self.entries = entries
+        self.old_state = old_state
         if not self.entries:
             self.entries = [x.item for x in self.view.selection]
 
@@ -569,17 +572,15 @@
                 self.controller.delete_entries(self.entries)
                 self.renew_focus()
             self.view.set_footer_text("", 'entry_footer')
-            self.set_next_state(DefaultEntryListState(self.projectlist_state,
-                                                      self.controller,
-                                                      self.view))
+            # avoid creating new DefaultEntryListState and setting focus
+            self.set_next_state(self.old_state)
             self.controller.project_view.show_total_time()
             return True
 
         if 'n' in key or keys.get_escape() in key:
             self.view.set_footer_text("", 'entry_footer')
-            self.set_next_state(DefaultEntryListState(self.projectlist_state,
-                                                      self.controller,
-                                                      self.view))
+            # avoid creating new DefaultEntryListState and setting focus
+            self.set_next_state(self.old_state)
             return True
 
         return False


More information about the Getan-commits mailing list