1bd04c04b076 — Alain Leufroy 2 years ago
main widget: allow user to specify a maximalized pane on startup.
2 files changed, 18 insertions(+), 6 deletions(-)

M lairucrem/config.py
M lairucrem/widgets/mainwidget.py
M lairucrem/config.py +4 -0
@@ 333,11 333,15 @@ TOPIC_NAME_REGEXP = re.compile('.*\x02(.
 
 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
 
 

          
M lairucrem/widgets/mainwidget.py +14 -6
@@ 136,8 136,11 @@ class _maximizable_contenxt_base:
     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 @@ class packer(delegate_to_widget_mixin('_
         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 @@ class packer(delegate_to_widget_mixin('_
         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 @@ class packer(delegate_to_widget_mixin('_
         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]