[PATCH] Select the previous item when RemoveButton is clicked (KeyboardSpoke)

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

 



---
 pyanaconda/ui/gui/spokes/keyboard.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 4b55367..8e9e56d 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -169,7 +169,24 @@ class KeyboardSpoke(NormalSpoke):
             return
 
         (store, itr) = selection.get_selected()
+        itr2 = store.get_iter_first()
+        #if the first item is selected, try to select the next one
+        if store[itr][0] == store[itr2][0]:
+            itr2 = store.iter_next(itr2)
+            if itr2: #next one existing
+                selection.select_iter(itr2)
+            #nothing left to be selected
+            store.remove(itr)
+            return
+
+        #the selected item is not the first, select the previous one
+        #XXX: there is no model.iter_previous() so we have to find it this way
+        itr3 = store.iter_next(itr2) #look-ahead iterator
+        while itr3 and (store[itr3][0] != store[itr][0]):
+            itr2 = store.iter_next(itr2)
+            itr3 = store.iter_next(itr3)
         store.remove(itr)
+        selection.select_iter(itr2)
 
     def on_up_clicked(self, button):
         selection = self.builder.get_object("layoutSelection")
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux