Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll the view after deleting pages #821

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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