# HG changeset patch # User Goffi # Date 1582731742 -3600 # Node ID f8ba934ea462b9a0ac8e0c239997489d20d37124 # Parent efee0e0afb785abfc4974c05ebc26ff7f45d1d72 core: new showHeadWidget method to show/hide notifications header. diff -r efee0e0afb78 -r f8ba934ea462 cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Wed Feb 26 16:41:27 2020 +0100 +++ b/cagou/core/cagou_main.py Wed Feb 26 16:42:22 2020 +0100 @@ -341,6 +341,27 @@ def on_stop(self): return local_platform.on_stop() + def showHeadWidget(self, show=None, animation=True): + """Show/Hide the head widget + + @param show(bool, None): True to show, False to hide, None to switch + @param animation(bool): animate the show/hide if True + """ + head = self.root.head_widget + if bool(self.root.head_widget.height) == show: + return + if head.height: + if animation: + Animation(height=0, opacity=0, duration=0.3).start(head) + else: + head.height = head.opacity = 0 + else: + if animation: + Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) + else: + head.height = head.HEIGHT + head.opacity = 1 + def key_input(self, window, key, scancode, codepoint, modifier): # we first check if selected widget handles the key @@ -367,11 +388,7 @@ return True elif key == 110 and 'alt' in modifier: # M-n we hide/show notifications - head = self.root.head_widget - if head.height: - Animation(height=0, opacity=0, duration=0.3).start(head) - else: - Animation(height=head.HEIGHT, opacity=1, duration=0.3).start(head) + self.showHeadWidget() return True else: return False