debug-viewer: window: add helper to get visible range

Move this code to the window class, as multiple plugins are going to need it.
This commit is contained in:
Stefan Sauer 2016-10-10 15:59:49 +02:00
parent 561c612472
commit 3b1e2833a3
2 changed files with 18 additions and 11 deletions

View file

@ -640,6 +640,22 @@ class Window (object):
self.pop_view_state() self.pop_view_state()
self.actions.show_hidden_lines.props.sensitive = True self.actions.show_hidden_lines.props.sensitive = True
def get_range(self):
view = self.log_view
model = view.get_model()
visible_range = view.get_visible_range()
if visible_range is None:
return None
start_path, end_path = visible_range
if not start_path or not end_path:
return None
ts1 = model.get_value(model.get_iter(start_path),
model.COL_TIME)
ts2 = model.get_value(model.get_iter(end_path),
model.COL_TIME)
return (ts1, ts2)
@action @action
def handle_show_hidden_lines_action_activate(self, action): def handle_show_hidden_lines_action_activate(self, action):

View file

@ -975,19 +975,10 @@ class AttachedWindow (object):
def update_timeline_position(self): def update_timeline_position(self):
view = self.window.log_view visible_range = self.window.get_range()
model = view.get_model()
visible_range = view.get_visible_range()
if visible_range is None: if visible_range is None:
return return
start_path, end_path = visible_range ts1, ts2 = visible_range
if not start_path or not end_path:
return
ts1 = model.get_value(model.get_iter(start_path),
model.COL_TIME)
ts2 = model.get_value(model.get_iter(end_path),
model.COL_TIME)
self.timeline.update_position(ts1, ts2) self.timeline.update_position(ts1, ts2)
def handle_show_action_toggled(self, action): def handle_show_action_toggled(self, action):