# HG changeset patch # User Alain Leufroy # Date 1639913724 -3600 # Sun Dec 19 12:35:24 2021 +0100 # Node ID 1bd04c04b076a1b2f6468bdc84daf21d571a22c9 # Parent fd54925d16ca14105058c97f1f37892c206c6b89 main widget: allow user to specify a maximalized pane on startup. diff --git a/lairucrem/config.py b/lairucrem/config.py --- a/lairucrem/config.py +++ b/lairucrem/config.py @@ -333,11 +333,15 @@ HORIZONTAL = 'horizontal' VERTICAL = 'vertical' +TREE = 'tree' +DETAILS = 'details' # Split orientation of the main widget. One of: # - None: orientation depends on the screen size # - HORIZONTAL: tree and diff panes are horizontally packed # - VERTICAL: tree and diff panes are vertically packed +# - TREE: maximalize the tree pane +# - DETAILS: maximalize the PATCH pane DEFAULT_MAIN_VIEW = None diff --git a/lairucrem/widgets/mainwidget.py b/lairucrem/widgets/mainwidget.py --- a/lairucrem/widgets/mainwidget.py +++ b/lairucrem/widgets/mainwidget.py @@ -136,8 +136,11 @@ def _unfocused_options(self): raise NotImplementedError - def toggle_maximize(self): - self._maximized = not(self._maximized) + def toggle_maximize(self, value=None): + if value is None: + self._maximized = not(self._maximized) + else: + self._maximized = value self._modified() def __iter__(self): @@ -173,7 +176,9 @@ return True def __init__(self, widgets): - self._orientation = config.DEFAULT_MAIN_VIEW + self._orientation = None + if config.DEFAULT_MAIN_VIEW in (config.HORIZONTAL, config.VERTICAL): + self._orientation = config.DEFAULT_MAIN_VIEW self._widgets = widgets self._original_widget = None self._column_widget = None @@ -183,6 +188,9 @@ if self._orientation: self._previous_size = ANY self._update_container() + if config.DEFAULT_MAIN_VIEW in (config.TREE, config.DETAILS): + self._set_focus_position(0 if config.DEFAULT_MAIN_VIEW == config.TREE else 1) + self._toggle_miximize(True) def render(self, size, focus): """render the widget""" @@ -211,9 +219,9 @@ self._column_widget.focus_position = num self._pile_widget.focus_position = num - def _toggle_miximize(self): - self._column_widget.contents.toggle_maximize() - self._pile_widget.contents.toggle_maximize() + def _toggle_miximize(self, value=None): + self._column_widget.contents.toggle_maximize(value) + self._pile_widget.contents.toggle_maximize(value) def _guess_orientation(self, size): cols = size[0]