def new_page(self, directory=None): terminal = GuakeTerminal(self.guake) terminal.grab_focus() if not isinstance(directory, str): directory = os.environ['HOME'] try: if self.guake.settings.general.get_boolean('open-tab-cwd'): active_terminal = self.get_focused_terminal() directory = os.path.expanduser('~') if active_terminal: directory = active_terminal.get_current_directory() except Exception as e: pass terminal.spawn_sync_pid(directory) terminal_box = TerminalBox() terminal_box.set_terminal(terminal) root_terminal_box = RootTerminalBox(self.guake) root_terminal_box.set_child(terminal_box) page_num = self.append_page(root_terminal_box, None) self.set_tab_reorderable(root_terminal_box, True) self.show_all() # needed to show newly added tabs and pages # this is needed to initially set the last_terminal_focused, # one could also call terminal.get_parent().on_terminal_focus() terminal.emit("focus", Gtk.DirectionType.TAB_FORWARD) self.emit('terminal-spawned', terminal, terminal.pid) return root_terminal_box, page_num, terminal