def setup(self, connection): """Setup the manager.""" self._connection = connection self._conn_mgr = ConnectionManager() self._conn_mgr.setup(connection) self._conn_mgr.add_observer( command_sent=self.on_command, response_received=self.on_response, stream_response_received=self.on_stream_response, init_packet=self.on_init_packet) # Add a hook in the gobject main loop to monitor for incoming data # on the socket. gobject.io_add_watch( connection.socket.handle, gobject.IO_IN | gobject.IO_HUP | gobject.IO_ERR, self.on_io_event) self._view = PageView() self._view['tab_button'].connect( 'clicked', self.on_tab_close_button_clicked) self._view['source_view'].connect( 'button-press-event', self.on_button_press_on_source_view) self._view['source_list'].connect( 'row-activated', self.on_source_list_row_activated) self._view['get_uri_button'].connect( 'clicked', self.on_get_uri_button_clicked) self._view['uri_entry'].connect( 'activate', self.on_get_uri_button_clicked) self._view['property_notebook'].connect( 'property-clicked', self.on_property_clicked)
class PageManager(Manager): def __init__(self): super(Manager, self).__init__() self._source_cache = SourceCache() self._page_num = None self._init_steps_done = set() def setup(self, connection): """Setup the manager.""" self._connection = connection self._conn_mgr = ConnectionManager() self._conn_mgr.setup(connection) self._conn_mgr.add_observer( command_sent=self.on_command, response_received=self.on_response, stream_response_received=self.on_stream_response, init_packet=self.on_init_packet) # Add a hook in the gobject main loop to monitor for incoming data # on the socket. gobject.io_add_watch( connection.socket.handle, gobject.IO_IN | gobject.IO_HUP | gobject.IO_ERR, self.on_io_event) self._view = PageView() self._view['tab_button'].connect( 'clicked', self.on_tab_close_button_clicked) self._view['source_view'].connect( 'button-press-event', self.on_button_press_on_source_view) self._view['source_list'].connect( 'row-activated', self.on_source_list_row_activated) self._view['get_uri_button'].connect( 'clicked', self.on_get_uri_button_clicked) self._view['uri_entry'].connect( 'activate', self.on_get_uri_button_clicked) self._view['property_notebook'].connect( 'property-clicked', self.on_property_clicked) @property def conn_mgr(self): return self._conn_mgr def send_continuation(self, command): self._conn_mgr.send_continuation(command, self.on_cont_status) def refresh_page_number(self): notebook = AppView.get_instance()['notebook'] self._page_num = notebook.page_num(self._view['outer_box']) def _set_line_breakpoint(self, line_num): source = self._view['source_view'].current_source if not source: return breaks_on_line = source.get_breakpoints_on_line(line_num) if len(breaks_on_line) > 0: return callback = bind_params(self.on_breakpoint_set, source, line_num) self._conn_mgr.send_line_breakpoint_set(source.file_uri, line_num + 1, callback) def _remove_line_breakpoint(self, line_num): source = self._view['source_view'].current_source if not source: return breaks_on_line = source.get_breakpoints_on_line(line_num) if len(breaks_on_line) == 0: return id = breaks_on_line[0]['id'] callback = bind_params(self.on_breakpoint_remove, source, id) self._conn_mgr.send_breakpoint_remove(id, callback) def on_io_event(self, source, condition): # Called from the gobject main loop when an event occurs on the # connection socket. if condition == gobject.IO_IN: try: self._conn_mgr.process_response() except ConnectionClosed, e: self._conn_mgr.close_connection() app_view = AppView.get_instance() app_view['notebook'].set_current_page(self._page_num) app_view.show_error('conn_closed') app_view['notebook'].remove_page(self._page_num) elif condition == gobject.IO_HUP: self._conn_mgr.close_connection()