Scroll to selected row

by roundabout, Sunday, 8 December 2024, 18:12:09 (1733681529), pushed by roundabout, Thursday, 12 December 2024, 14:59:13 (1734015553)

Author identity: vlad <vlad.muntoiu@gmail.com>

695ba2866e3b3f1cb710242e390b265b9c649e47

main.py

@@ -227,6 +227,7 @@ class Izvor(Gtk.Application):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        results_list.select_row(rows[next_index])
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        search_entry.grab_focus()  # Refocus the search entry
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.scroll_to_row(rows[next_index], results_list.get_adjustment())
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        return True
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if event.keyval == Gdk.KEY_Up:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -239,6 +240,7 @@ class Izvor(Gtk.Application):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        results_list.select_row(rows[prev_index])
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        search_entry.grab_focus()  # Refocus the search entry
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    self.scroll_to_row(rows[prev_index], results_list.get_adjustment())
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        return True
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if event.keyval == Gdk.KEY_Return and current_row:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -248,6 +250,18 @@ class Izvor(Gtk.Application):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    return False
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            def scroll_to_row(self, row, adjustment):
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                row_geometry = row.get_allocation()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                row_y = row_geometry.y
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                row_height = row_geometry.height
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                adjustment_value = adjustment.get_value()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                adjustment_upper = adjustment.get_upper() - adjustment.get_page_size()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if row_y + row_height > adjustment_value + adjustment.get_page_size():
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    adjustment.set_value(min(row_y + row_height - adjustment.get_page_size(), adjustment_upper))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                elif row_y < adjustment_value:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    adjustment.set_value(max(row_y, 0))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                def about(self, widget):
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    about_builder = Gtk.Builder()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    about_builder.add_from_file("about.ui")