commit 8a83598d588b2a58da7cfd852c107bb925233835 Author: Damian Johnson atagar@torproject.org Date: Tue Sep 13 10:34:21 2016 -0700
Merge Controller init methods
I really hate the two stage init() we hacked in to account for panels calling get_controller(). This is a hack too, but little cleaner for our init to simply set the singleton. --- nyx/controller.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/nyx/controller.py b/nyx/controller.py index 63aa13c..a50f2d4 100644 --- a/nyx/controller.py +++ b/nyx/controller.py @@ -60,6 +60,9 @@ def get_controller(): Provides the nyx controller instance. """
+ if NYX_CONTROLLER is None: + Controller() # constructor sets NYX_CONTROLLER + return NYX_CONTROLLER
@@ -98,6 +101,7 @@ class Controller(Interface): top to bottom on the page. """
+ global NYX_CONTROLLER super(Controller, self).__init__()
self._page_panels = [] @@ -106,9 +110,9 @@ class Controller(Interface): self._force_redraw = False self._last_drawn = 0
- def init(self): + NYX_CONTROLLER = self + self._header_panel = nyx.panel.header.HeaderPanel() - first_page_panels = []
if CONFIG['features.panels.show.graph']: first_page_panels.append(nyx.panel.graph.GraphPanel()) @@ -131,11 +135,6 @@ class Controller(Interface): if CONFIG['features.panels.show.interpreter']: self._page_panels.append([nyx.panel.interpreter.InterpreterPanel()])
- self.quit_signal = False - self._page = 0 - self._force_redraw = False - self._last_drawn = 0 - def header_panel(self): return self._header_panel
@@ -207,10 +206,6 @@ def start_nyx(): Main draw loop context. """
- global NYX_CONTROLLER - - NYX_CONTROLLER = Controller() - NYX_CONTROLLER.init() interface = get_controller()
if not CONFIG['features.acsSupport']:
tor-commits@lists.torproject.org