def __init__(self, buf): buf.worksheet.connect('chunk-inserted', self.on_chunk_inserted) buf.worksheet.connect('chunk-changed', self.on_chunk_changed) buf.worksheet.connect('chunk-status-changed', self.on_chunk_status_changed) buf.worksheet.connect('notify::state', self.on_notify_state) buf.connect('add-custom-result', self.on_add_custom_result) buf.connect('pair-location-changed', self.on_pair_location_changed) gtk.TextView.__init__(self, buf) self.set_border_window_size(gtk.TEXT_WINDOW_LEFT, 10) self.set_left_margin(2) # Attach a "behavior object" to the view which, by ugly hacks, makes it # do simply and reasonable things for cut-and-paste and DND sanitize_textview_ipc.sanitize_view(self) self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK) self.__completion_popup = CompletionPopup(self) self.__doc_popup = DocPopup() self.__mouse_over_object = None self.__mouse_over_timeout = None buf = self.get_buffer() self.__mouse_over_start = buf.create_mark(None, buf.get_start_iter(), True)
def __init__(self, buf): self.edit_only = buf.worksheet.edit_only if not self.edit_only: buf.worksheet.sig_chunk_inserted.connect( self.on_chunk_inserted ) buf.worksheet.sig_chunk_changed.connect( self.on_chunk_changed ) buf.worksheet.sig_chunk_status_changed.connect( self.on_chunk_status_changed ) buf.worksheet.sig_chunk_deleted.connect( self.on_chunk_deleted ) buf.worksheet.sig_state.connect( self.on_notify_state ) # Track changes to update completion buf.connect_after('insert-text', self.on_after_insert_text) buf.connect_after('delete-range', self.on_after_delete_range) buf.connect_after('end-user-action', self.on_after_end_user_action) self.__inserted_in_user_action = False self.__deleted_in_user_action = False if not self.edit_only: self.sidebar = Sidebar() else: self.sidebar = None buf.connect('add-custom-result', self.on_add_custom_result) buf.connect('add-sidebar-results', self.on_add_sidebar_results) buf.connect('remove-sidebar-results', self.on_remove_sidebar_results) buf.connect('pair-location-changed', self.on_pair_location_changed) gtk.TextView.__init__(self, buf) if not self.edit_only: self.set_border_window_size(gtk.TEXT_WINDOW_LEFT, LEFT_MARGIN_WIDTH) self.set_left_margin(2) # Attach a "behavior object" to the view which, by ugly hacks, makes it # do simply and reasonable things for cut-and-paste and DND sanitize_textview_ipc.sanitize_view(self) self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK) self.__completion_popup = CompletionPopup(self) self.__doc_popup = DocPopup() self.__mouse_over_object = None self.__mouse_over_timeout = None self.__mouse_over_start = buf.create_mark(None, buf.get_start_iter(), True) self.__arg_highlight_start = None self.__arg_highlight_end = None buf.connect('mark-set', self.on_mark_set) self.__cursor_chunk = None self.__scroll_to_result = False self.__scroll_to = buf.create_mark(None, buf.get_start_iter(), True) self.__scroll_idle = None self.__update_sidebar_positions_idle = 0 self.__pixels_below_buffer = 0 self.__last_chunk = None self.connect('destroy', self.on_destroy)