class PyflakeView(PidaView): icon_name = 'python-icon' label_text = _('Python Errors') def create_ui(self): self.errors_ol = ObjectList( Column('markup', use_markup=True) ) self.errors_ol.set_headers_visible(False) self.errors_ol.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.add_main_widget(self.errors_ol) self.errors_ol.connect('double-click', self._on_errors_double_clicked) self.errors_ol.show_all() self.sort_combo = AttrSortCombo( self.errors_ol, [ ('lineno', _('Line Number')), ('message_string', _('Message')), ('name', _('Type')), ], 'lineno', ) self.sort_combo.show() self.add_main_widget(self.sort_combo, expand=False) def clear_items(self): self.errors_ol.clear() def set_items(self, items): self.clear_items() for item in items: self.errors_ol.append(self.decorate_pyflake_message(item)) def decorate_pyflake_message(self, msg): args = [('<b>%s</b>' % arg) for arg in msg.message_args] msg.message_string = msg.message % tuple(args) msg.name = msg.__class__.__name__ msg.markup = ('<tt>%s </tt><i>%s</i>\n%s' % (msg.lineno, msg.name, msg.message_string)) return msg def _on_errors_double_clicked(self, ol, item): self.svc.boss.editor.cmd('goto_line', line=item.lineno) def can_be_closed(self): self.svc.get_action('show_python_errors').set_active(False)
class SourceView(PidaGladeView): gladefile = 'python-source-browser' locale = locale icon_name = 'python-icon' label_text = _('Source') def create_ui(self): self.source_tree.set_columns( [ Column('linenumber'), Column('ctype_markup', use_markup=True), Column('nodename_markup', use_markup=True), ] ) self.source_tree.set_headers_visible(False) self.sort_box = AttrSortCombo( self.source_tree, [ ('linenumber', _('Line Number')), ('nodename', _('Name')), ('nodetype', _('Type')), ], 'linenumber' ) self.sort_box.show() self.main_vbox.pack_start(self.sort_box, expand=False) def clear_items(self): self.source_tree.clear() def add_node(self, node, parent): self.source_tree.append(parent, node) def can_be_closed(self): self.svc.get_action('show_python_source').set_active(False) def on_source_tree__double_click(self, tv, item): self.svc.boss.editor.cmd('goto_line', line=item.linenumber)