From ed5f7b18bd5c92269300e63706adae77a3bbe966 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 2 Apr 2016 01:23:51 +0100 Subject: Remove the global Win._win_core, instead pass core to the two *GlobalInfoBar. --- poezio/core/core.py | 4 ++-- poezio/windows/base_wins.py | 8 -------- poezio/windows/info_bar.py | 6 ++++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/poezio/core/core.py b/poezio/core/core.py index 5e78020a..f5539d59 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -86,7 +86,7 @@ class Core(object): self.information_buffer.add_window(self.information_win) self.left_tab_win = None - self.tab_win = windows.GlobalInfoBar() + self.tab_win = windows.GlobalInfoBar(self) # Whether the XML tab is opened self.xml_tab = None self.xml_buffer = TextBuffer() @@ -1641,7 +1641,7 @@ class Core(object): except: log.error('Curses error on infobar resize', exc_info=True) return - self.left_tab_win = windows.VerticalGlobalInfoBar(truncated_win) + self.left_tab_win = windows.VerticalGlobalInfoBar(self, truncated_win) elif not self.size.core_degrade_y: self.tab_win.resize(1, tabs.Tab.width, tabs.Tab.height - 2, 0) diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py index a4fad3f4..1a578350 100644 --- a/poezio/windows/base_wins.py +++ b/poezio/windows/base_wins.py @@ -34,7 +34,6 @@ class DummyWin(object): return False class Win(object): - _win_core = None _tab_win = None def __init__(self): self._win = None @@ -149,10 +148,3 @@ class Win(object): self.addnstr(' '*size, size, to_curses_attr(color)) else: self.addnstr(' '*size, size) - - @property - def core(self): - if not Win._win_core: - Win._win_core = singleton.Singleton(core.Core) - return Win._win_core - diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py index abd956cd..4790a76f 100644 --- a/poezio/windows/info_bar.py +++ b/poezio/windows/info_bar.py @@ -16,8 +16,9 @@ from . import Win from theming import get_theme, to_curses_attr class GlobalInfoBar(Win): - def __init__(self): + def __init__(self, core): Win.__init__(self) + self.core = core def refresh(self): log.debug('Refresh: %s', self.__class__.__name__) @@ -62,8 +63,9 @@ class GlobalInfoBar(Win): self._refresh() class VerticalGlobalInfoBar(Win): - def __init__(self, scr): + def __init__(self, core, scr): Win.__init__(self) + self.core = core self._win = scr def refresh(self): -- cgit v1.2.3