Unify two very similar methods

This commit is contained in:
René Stadler 2008-01-02 20:54:33 +01:00 committed by Stefan Sauer
parent 2fa90648aa
commit e47a5a70d4

View file

@ -1782,34 +1782,29 @@ class Window (object):
def handle_hide_after_line_action_activate (self, action):
self.hide_range (after = True)
def handle_hide_before_line_action_activate (self, action):
self.hide_range (after = False)
def hide_range (self, after):
model = self.log_view.props.model
first_index = model.line_index_to_top (0)
try:
filtered_line_index = self.get_active_line_index ()
except ValueError:
return
if after:
first_index = model.line_index_to_top (0)
last_index = model.line_index_to_top (filtered_line_index)
self.logger.info ("hiding lines after %i (abs %i), first line is abs %i",
filtered_line_index,
last_index,
first_index)
self.push_view_state ()
self.log_range.set_range (first_index, last_index)
if self.log_filter:
self.log_filter.super_model_changed_range ()
self.update_model ()
self.pop_view_state ()
self.actions.show_hidden_lines.props.sensitive = True
def handle_hide_before_line_action_activate (self, action):
try:
filtered_line_index = self.get_active_line_index ()
except ValueError:
return
model = self.log_view.props.model
else:
first_index = model.line_index_to_top (filtered_line_index)
last_index = model.line_index_to_top (len (model) - 1)