[PATCH 4/4] 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 |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 4b55367..0c0395d 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -169,7 +169,23 @@ 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.get_value(itr, 0) == store.get_value(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
+        itr2 = store.iter_next(itr2)
+        while store.get_value(store.iter_next(itr2), 0) != store.get_value(itr, 0):
+            itr2 = store.iter_next(itr2)
         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