1#!/usr/bin/env python3 2# coding: utf-8 3 4# Copyright (C) 2017, 2018 Robert Griesel 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/> 17 18from setzer.app.service_locator import ServiceLocator 19 20 21class ShortcutsbarPresenter(object): 22 ''' Mediator between workspace and view. ''' 23 24 def __init__(self, document, view): 25 self.document = document 26 self.view = view 27 self.document.register_observer(self) 28 self.width = None 29 self.view.connect('size-allocate', self.on_size_allocate) 30 31 ''' 32 *** notification handlers, get called by observed workspace 33 ''' 34 35 def change_notification(self, change_code, notifying_object, parameter): 36 37 if change_code in ['document_empty', 'document_not_empty']: 38 self.update_wizard_button_visibility() 39 40 def on_size_allocate(self, widget, allocation): 41 if allocation.width != self.width: 42 self.width = allocation.width 43 self.update_wizard_button_visibility() 44 45 def update_wizard_button_visibility(self): 46 is_visible = (not self.document.is_empty()) and self.width > 675 47 self.view.wizard_button.label_revealer.set_reveal_child(is_visible) 48 49 50