mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
Restore visible range of log view when changing filter
This commit is contained in:
parent
b155f21610
commit
e971bda1ae
1 changed files with 43 additions and 19 deletions
|
@ -1729,6 +1729,7 @@ class Window (object):
|
||||||
def push_view_state (self):
|
def push_view_state (self):
|
||||||
|
|
||||||
self.default_index = None
|
self.default_index = None
|
||||||
|
self.default_start_index = None
|
||||||
|
|
||||||
model = self.log_view.props.model
|
model = self.log_view.props.model
|
||||||
if model is None:
|
if model is None:
|
||||||
|
@ -1746,6 +1747,12 @@ class Window (object):
|
||||||
|
|
||||||
self.default_index = super_index
|
self.default_index = super_index
|
||||||
|
|
||||||
|
vis_range = self.log_view.get_visible_range ()
|
||||||
|
if vis_range is not None:
|
||||||
|
start_path, end_path = vis_range
|
||||||
|
start_index = start_path[0]
|
||||||
|
self.default_start_index = model.line_index_to_top (start_index)
|
||||||
|
|
||||||
def update_model (self, model = None):
|
def update_model (self, model = None):
|
||||||
|
|
||||||
if model is None:
|
if model is None:
|
||||||
|
@ -1758,30 +1765,47 @@ class Window (object):
|
||||||
self.log_view.set_model (None)
|
self.log_view.set_model (None)
|
||||||
self.log_view.props.model = model
|
self.log_view.props.model = model
|
||||||
|
|
||||||
def pop_view_state (self):
|
def pop_view_state (self, scroll_to_selection = False):
|
||||||
|
|
||||||
selected_index = self.default_index
|
|
||||||
if selected_index is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
model = self.log_view.props.model
|
model = self.log_view.props.model
|
||||||
if model is None:
|
if model is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
selected_index = self.default_index
|
||||||
select_index = model.line_index_from_top (selected_index)
|
start_index = self.default_start_index
|
||||||
except IndexError, exc:
|
|
||||||
self.logger.debug ("abs line index %i filtered out, not reselecting",
|
if selected_index is not None:
|
||||||
selected_index)
|
|
||||||
else:
|
|
||||||
assert select_index >= 0
|
|
||||||
sel = self.log_view.get_selection ()
|
|
||||||
path = (select_index,)
|
|
||||||
sel.select_path (path)
|
|
||||||
|
|
||||||
# FIXME: Instead of scrolling to the selected row, try to restore
|
try:
|
||||||
# the previous visible range.
|
select_index = model.line_index_from_top (selected_index)
|
||||||
self.log_view.scroll_to_cell (path, use_align = True, row_align = .5)
|
except IndexError, exc:
|
||||||
|
self.logger.debug ("abs line index %i filtered out, not reselecting",
|
||||||
|
selected_index)
|
||||||
|
else:
|
||||||
|
assert select_index >= 0
|
||||||
|
sel = self.log_view.get_selection ()
|
||||||
|
path = (select_index,)
|
||||||
|
sel.select_path (path)
|
||||||
|
|
||||||
|
if start_index is None or scroll_to_selection:
|
||||||
|
self.log_view.scroll_to_cell (path, use_align = True, row_align = .5)
|
||||||
|
|
||||||
|
if start_index is not None and not scroll_to_selection:
|
||||||
|
|
||||||
|
def traverse ():
|
||||||
|
for i in xrange (start_index, len (model)):
|
||||||
|
yield i
|
||||||
|
for i in xrange (start_index - 1, 0, -1):
|
||||||
|
yield i
|
||||||
|
for current_index in traverse ():
|
||||||
|
try:
|
||||||
|
target_index = model.line_index_from_top (current_index)
|
||||||
|
except IndexError:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
path = (target_index,)
|
||||||
|
self.log_view.scroll_to_cell (path, use_align = True, row_align = 0.)
|
||||||
|
break
|
||||||
|
|
||||||
def update_view (self):
|
def update_view (self):
|
||||||
|
|
||||||
|
@ -1890,7 +1914,7 @@ class Window (object):
|
||||||
self.log_range.reset ()
|
self.log_range.reset ()
|
||||||
self.log_filter = None
|
self.log_filter = None
|
||||||
self.update_model (self.log_range)
|
self.update_model (self.log_range)
|
||||||
self.pop_view_state ()
|
self.pop_view_state (scroll_to_selection = True)
|
||||||
self.actions.show_hidden_lines.props.sensitive = False
|
self.actions.show_hidden_lines.props.sensitive = False
|
||||||
|
|
||||||
def handle_edit_copy_line_action_activate (self, action):
|
def handle_edit_copy_line_action_activate (self, action):
|
||||||
|
|
Loading…
Reference in a new issue