def run(self): # Start debug view self._debug_view = LogView() self._browser.connect('message', self.print_message) self._browser._term_book.new_tab(self._debug_view) self._browser._term_book.reorder_child(self._debug_view, 0) keyval, modifier = gtk.accelerator_parse('<Control><Shift>c') self._browser._accels.connect_group(keyval, modifier, gtk.ACCEL_VISIBLE, self._toggle_terminal_key_pressed) self.print_message(self._browser, 'Message View plugin started.')
class MessageView(object): def __init__(self, browser): self._browser = browser self._debug_view = None def run(self): # Start debug view self._debug_view = LogView() self._browser.connect('message', self.print_message) self._browser._term_book.new_tab(self._debug_view) self._browser._term_book.reorder_child(self._debug_view, 0) keyval, modifier = gtk.accelerator_parse('<Control><Shift>c') self._browser._accels.connect_group(keyval, modifier, gtk.ACCEL_VISIBLE, self._toggle_terminal_key_pressed) self.print_message(self._browser, 'Message View plugin started.') def exit(self): try: self._browser.disconnect_by_func(self.print_message) self._browser._accels.disconnect_by_func( self._toggle_terminal_key_pressed) except Exception as err: print(err) finally: self._browser._term_book.close_tab(self._debug_view, force=True) self._debug_view = None def print_message(self, browser, message, color=0, data_color=''): # Log the message to the debug console. self._debug_view.log_message(message, color, data_color) return True def _toggle_terminal_key_pressed(self, accels=None, window=None, keyval=None, flags=None): """ _toggle_terminal_key_pressed() -> Toggle visibility of terminal tab box. """ self._browser._term_book.toggle_visible(self._debug_view)
class MessageView(object): def __init__(self, browser): self._browser = browser self._debug_view = None def run(self): # Start debug view self._debug_view = LogView() self._browser.connect('message', self.print_message) self._browser._term_book.new_tab(self._debug_view) self._browser._term_book.reorder_child(self._debug_view, 0) keyval, modifier = gtk.accelerator_parse('<Control><Shift>c') self._browser._accels.connect_group(keyval, modifier, gtk.ACCEL_VISIBLE, self._toggle_terminal_key_pressed) self.print_message(self._browser, 'Message View plugin started.') def exit(self): try: self._browser.disconnect_by_func(self.print_message) self._browser._accels.disconnect_by_func(self._toggle_terminal_key_pressed) except Exception as err: print(err) finally: self._browser._term_book.close_tab(self._debug_view, force=True) self._debug_view = None def print_message(self, browser, message, color=0, data_color=''): # Log the message to the debug console. self._debug_view.log_message(message, color, data_color) return True def _toggle_terminal_key_pressed(self, accels=None, window=None, keyval=None, flags=None): """ _toggle_terminal_key_pressed() -> Toggle visibility of terminal tab box. """ self._browser._term_book.toggle_visible(self._debug_view)