mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +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,16 +1765,17 @@ 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
|
||||||
|
|
||||||
|
selected_index = self.default_index
|
||||||
|
start_index = self.default_start_index
|
||||||
|
|
||||||
|
if selected_index is not None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
select_index = model.line_index_from_top (selected_index)
|
select_index = model.line_index_from_top (selected_index)
|
||||||
except IndexError, exc:
|
except IndexError, exc:
|
||||||
|
@ -1779,10 +1787,26 @@ class Window (object):
|
||||||
path = (select_index,)
|
path = (select_index,)
|
||||||
sel.select_path (path)
|
sel.select_path (path)
|
||||||
|
|
||||||
# FIXME: Instead of scrolling to the selected row, try to restore
|
if start_index is None or scroll_to_selection:
|
||||||
# the previous visible range.
|
|
||||||
self.log_view.scroll_to_cell (path, use_align = True, row_align = .5)
|
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):
|
||||||
|
|
||||||
view = self.log_view
|
view = self.log_view
|
||||||
|
@ -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