Skip to content

Commit

Permalink
Scroll the view after deleting pages
Browse files Browse the repository at this point in the history
Close #501
  • Loading branch information
kbengs authored and jeromerobert committed Jan 31, 2023
1 parent 6932ea1 commit a53e289
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pdfarranger/pdfarranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def __init__(self, *args, **kwargs):
self.metadata = {}
self.pressed_button = None
self.click_path = None
self.scroll_path = None
self.rendering_thread = None
self.export_process = None
self.post_action = None
Expand Down Expand Up @@ -932,6 +933,9 @@ def iv_size_allocate(self, _iconview, _allocation):
self.set_adjustment_limits()
if self.vadj_percent is not None:
self.vadj_percent_handler(restore=True)
if self.scroll_path:
GObject.idle_add(self.scroll_to_path2, self.scroll_path)
self.scroll_path = None

def set_adjustment_limits(self):
hscrollbar = self.sw.get_hscrollbar()
Expand Down Expand Up @@ -1340,13 +1344,28 @@ def clear_selected(self, add_to_undomanager=True):
row = model[-1]
path = row.path
self.iconview.select_path(path)
self.scroll_path = path
self.update_iconview_geometry()
self.iv_selection_changed_event()
self.iconview.grab_focus()
self.silent_render()
self.update_max_zoom_level()
malloc_trim()

def scroll_to_path2(self, path):
"""scroll_to_path() with modifications.
* Don't scroll to a oversized page that already is filling window
* Scroll only vertically
"""
cell = self.iconview.get_cell_rect(path)[1]
if cell.y <= 0 and cell.y + cell.height >= self.sw.get_allocated_height():
return
sw_hadj = self.sw.get_hadjustment()
sw_hpos = sw_hadj.get_value()
self.iconview.scroll_to_path(path, False, 0, 0)
sw_hadj.set_value(sw_hpos)

def copy_pages(self):
"""Collect data from selected pages"""

Expand Down

0 comments on commit a53e289

Please sign in to comment.