def on_notebook_tab_switch(self, notebook, page, page_num, title_label, window, notebook_identifier): """Triggered whenever a left-bar notebook tab is changed. Updates the title of the corresponding notebook and updates the title of the left-bar window in case un-docked. :param notebook: The GTK notebook where a tab-change occurred :param page_num: The page number of the currently-selected tab :param title_label: The label holding the notebook's title :param window: The left-bar window, for which the title should be changed :param notebook_identifier: A string identifying whether the notebook is the upper or the lower one """ title = gui_helper_label.set_notebook_title(notebook, page_num, title_label) window.reset_title(title, notebook_identifier) self.on_switch_page_check_collapse_button(notebook, page_num)
def __init__(self, state_machine_manager_model, view): assert isinstance(state_machine_manager_model, StateMachineManagerModel) assert isinstance(view, MainWindowView) ExtendedController.__init__(self, state_machine_manager_model, view) gui_singletons.main_window_controller = self self.observe_model(gui_singletons.gui_config_model) self.shortcut_manager = None self.handler_ids = {} self.currently_pressed_keys = set() self.state_machine_execution_model = gui_singletons.state_machine_execution_model self.observe_model(self.state_machine_execution_model) # shortcut manager self.shortcut_manager = ShortcutManager(view['main_window']) ###################################################### # debug console ###################################################### debug_console_controller = DebugConsoleController( gui_singletons.gui_config_model, view.debug_console_view) self.add_controller('debug_console_controller', debug_console_controller) ###################################################### # library tree ###################################################### self.library_manager_model = gui_singletons.library_manager_model library_controller = LibraryTreeController(self.library_manager_model, view.library_tree) self.add_controller('library_controller', library_controller) ###################################################### # state icons ###################################################### state_icon_controller = StateIconController( state_machine_manager_model, view.state_icons, self.shortcut_manager) self.add_controller('state_icon_controller', state_icon_controller) ###################################################### # state machine tree ###################################################### state_machine_tree_controller = StateMachineTreeController( state_machine_manager_model, view.state_machine_tree) self.add_controller('state_machine_tree_controller', state_machine_tree_controller) ###################################################### # states editor ###################################################### states_editor_ctrl = StatesEditorController( state_machine_manager_model, view.states_editor) self.add_controller('states_editor_ctrl', states_editor_ctrl) ###################################################### # state machines editor ###################################################### state_machines_editor_ctrl = StateMachinesEditorController( state_machine_manager_model, view.state_machines_editor) self.add_controller('state_machines_editor_ctrl', state_machines_editor_ctrl) ###################################################### # global variable editor ###################################################### global_variable_manager_ctrl = GlobalVariableManagerController( gui_singletons.global_variable_manager_model, view.global_var_editor) self.add_controller('global_variable_manager_ctrl', global_variable_manager_ctrl) ###################################################### # modification history ###################################################### state_machine_history_controller = ModificationHistoryTreeController( state_machine_manager_model, view.state_machine_history) self.add_controller('state_machine_history_controller', state_machine_history_controller) self.modification_history_was_focused = False ###################################################### # state machine execution history ###################################################### execution_history_ctrl = ExecutionHistoryTreeController( state_machine_manager_model, view.execution_history) self.add_controller('execution_history_ctrl', execution_history_ctrl) ###################################################### # menu bar ###################################################### menu_bar_controller = MenuBarController( state_machine_manager_model, view, self.shortcut_manager, rafcon.core.singleton.state_machine_execution_engine) self.add_controller('menu_bar_controller', menu_bar_controller) ###################################################### # tool bar ###################################################### tool_bar_controller = ToolBarController(state_machine_manager_model, view.tool_bar) self.add_controller('tool_bar_controller', tool_bar_controller) ###################################################### # Undocked Windows Controllers ###################################################### for window_key in constants.UNDOCKABLE_WINDOW_KEYS: widget_name = window_key.lower() + "_container" window_ctrl_name = window_key.lower() + "_window_controller" undocked_window_view = getattr(view, window_key.lower() + "_window") redock_callback = partial(self.redock_sidebar, window_key, widget_name, window_ctrl_name) window_ctrl = UndockedWindowController(state_machine_manager_model, undocked_window_view, redock_callback) self.add_controller(window_ctrl_name, window_ctrl) # Initialize the Left-Bar Notebooks' titles according to initially-selected tabs upper_title = gui_helper_label.set_notebook_title( view['upper_notebook'], view['upper_notebook'].get_current_page(), view['upper_notebook_title']) lower_title = gui_helper_label.set_notebook_title( view['lower_notebook'], view['lower_notebook'].get_current_page(), view['lower_notebook_title']) # Initialize the Left-Bar un-docked window title view.left_bar_window.initialize_title( gui_helper_label.create_left_bar_window_title( upper_title, lower_title)) view.right_bar_window.initialize_title('STATE EDITOR') view.console_window.initialize_title('CONSOLE') self.left_bar_child = view['top_level_h_pane'].get_child1() self.right_bar_child = view['right_h_pane'].get_child2() self.console_child = view['central_v_pane'].get_child2() self.left_bar_hidden = False self.right_bar_hidden = False self.console_hidden = False