Use the event handler to refresh when the tab changes

This commit is contained in:
mathieui 2018-07-23 20:38:34 +02:00
parent fdc797aec7
commit 54875e1ad5
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3
3 changed files with 10 additions and 14 deletions

View file

@ -48,7 +48,7 @@ pytest-3.5:
- python3 setup.py install
- py.test -v test/
pyest-3.6:
pytest-3.6:
stage: test
image: python:3.6
script:
@ -61,7 +61,7 @@ pyest-3.6:
- python3 setup.py install
- py.test -v test/
pyest-latest:
pytest-latest:
stage: test
image: python:3.6
script:

View file

@ -214,9 +214,6 @@ class CommandCore:
if match is None:
return
self.core.tabs.set_current_tab(match)
old_tab.on_lose_focus()
self.core.tabs.current_tab.on_gain_focus()
self.core.refresh_window()
@command_args_parser.quoted(2)
def move_tab(self, args):
@ -496,9 +493,6 @@ class CommandCore:
tab = tabs.BookmarksTab(self.core, self.core.bookmarks)
self.core.tabs.append(tab)
self.core.tabs.set_current_tab(tab)
old_tab.on_lose_focus()
tab.on_gain_focus()
self.core.refresh_window()
@command_args_parser.quoted(0, 1)
def remove_bookmark(self, args):

View file

@ -98,6 +98,8 @@ class Core:
self.plugins_autoloaded = False
self.plugin_manager = PluginManager(self)
self.events = events.EventHandler()
self.events.add_event_handler('tab_change',
self.on_tab_change)
self.tabs = Tabs(self.events)
self.previous_tab_nb = 0
@ -347,6 +349,12 @@ class Core:
self.add_configuration_handler("", self.on_any_config_change)
def on_tab_change(self, old_tab, new_tab):
"""Whenever the current tab changes, change focus and refresh"""
old_tab.on_lose_focus()
new_tab.on_gain_focus()
self.refresh_window()
def on_any_config_change(self, option, value):
"""
Update the roster, in case a roster option changed.
@ -1028,19 +1036,13 @@ class Core:
"""
rotate the rooms list to the right
"""
self.tabs.current_tab.on_lose_focus()
self.tabs.next()
self.tabs.current_tab.on_gain_focus()
self.refresh_window()
def rotate_rooms_left(self, args=None):
"""
rotate the rooms list to the right
"""
self.tabs.current_tab.on_lose_focus()
self.tabs.prev()
self.tabs.current_tab.on_gain_focus()
self.refresh_window()
def go_to_room_number(self):
"""