def mouseClick(self,w,e): x,y = self.view.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT,int(e.x),int(e.y)) if gtk.keysyms.Control_L in self.keymap.keys and e.button == 1: iter = self.view.get_iter_at_location(int(x),int(y)) cursor = self.cursorUnderMouse(iter.get_line()+1, iter.get_line_offset()) if cursor: referenced = cursor.referenced if referenced: location = referenced.location file = os.path.normpath(location.file.name) if file == self.clang.file: self.codeeditor.jump_to_position(("",location.line,0)) print "Jump to line:",location.line return from mainwindow import Tab from codeedit import CodeFileEditor codeedit = CodeFileEditor(self.project.get_syntax_highlight_key(),file) codeedit.jump_to_position(("",referenced.location.line,0)) window = self.view.parent.parent.parent.parent.parent tabname = os.path.basename(file) tab = Tab(tabname, codeedit) window.add_tab(tab,True) print "move to: ",referenced.location return True
def __init__(self, app): gtk.VBox.__init__(self) self.app = app box = gtk.HBox() hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_START) button = gtk.Button(stock=gtk.STOCK_ADD) button.connect("clicked", lambda w: self.add_test()) hbox.add(button) button = gtk.Button(stock=gtk.STOCK_REMOVE) button.connect( "clicked", lambda w: self.remove_test(self.objlist.selected_object())) hbox.add(button) button = gtk.Button(stock=gtk.STOCK_EXECUTE) button.connect("clicked", lambda w: self.execute(self.objlist.selected_object())) hbox.add(button) box.pack_start(hbox, False, False) self.switch = gtk.combo_box_new_text() self.switch.append_text("Build") self.switch.append_text("Build & Run") self.switch.append_text("Build & Traced Run") self.switch.append_text("Build & Run + Valgrind") self.switch.append_text("Simulation") self.switch.append_text("Simulation + Valgrind") self.switch.set_active(4) # Select 'Simulation' as default box.pack_start(self.switch, False, False) self.pack_start(box, False, False) hbox = gtk.HBox() self.objlist = ObjectList([("_", object), ("Tests", str)]) self.objlist.set_size_request(100, 100) self.objlist.object_as_row = lambda obj: [obj, obj.name] self.objlist.cursor_changed = self.cursor_changed hbox.pack_start(self.objlist, False, False) self.editor = CodeFileEditor( app, self.app.project.get_syntax_highlight_key()) hbox.pack_start(self.editor) self.pack_start(hbox) tests = collect_tests(app.project) self.objlist.fill(tests) if tests: self.cursor_changed(tests[0]) self.objlist.select_first() else: self.cursor_changed(None) self.show_all()
def __init__(self, app): gtk.VBox.__init__(self) self.app = app box = gtk.HBox() hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_START) button = gtk.Button(stock = gtk.STOCK_ADD) button.connect("clicked", lambda w: self.add_test()) hbox.add(button) button = gtk.Button(stock = gtk.STOCK_REMOVE) button.connect("clicked", lambda w: self.remove_test(self.objlist.selected_object())) hbox.add(button) button = gtk.Button(stock = gtk.STOCK_EXECUTE) button.connect("clicked", lambda w: self.execute(self.objlist.selected_object())) hbox.add(button) box.pack_start(hbox, False, False) self.switch = gtk.combo_box_new_text() self.switch.append_text("Build") self.switch.append_text("Build & Run") self.switch.append_text("Build & Traced Run") self.switch.append_text("Build & Run + Valgrind") self.switch.append_text("Simulation") self.switch.append_text("Simulation + Valgrind") self.switch.set_active(4) # Select 'Simulation' as default box.pack_start(self.switch, False, False) self.pack_start(box, False, False) hbox = gtk.HBox() self.objlist = ObjectList([("_", object), ("Tests", str) ]) self.objlist.set_size_request(100, 100) self.objlist.object_as_row = lambda obj: [ obj, obj.name ] self.objlist.cursor_changed = self.cursor_changed hbox.pack_start(self.objlist, False, False) self.editor = CodeFileEditor(app, self.app.project.get_syntax_highlight_key()) hbox.pack_start(self.editor) self.pack_start(hbox) tests = collect_tests(app.project) self.objlist.fill(tests) if tests: self.cursor_changed(tests[0]) self.objlist.select_first() else: self.cursor_changed(None) self.show_all()
class CodeTestList(gtk.VBox): def __init__(self, app): gtk.VBox.__init__(self) self.app = app box = gtk.HBox() hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_START) button = gtk.Button(stock = gtk.STOCK_ADD) button.connect("clicked", lambda w: self.add_test()) hbox.add(button) button = gtk.Button(stock = gtk.STOCK_REMOVE) button.connect("clicked", lambda w: self.remove_test(self.objlist.selected_object())) hbox.add(button) button = gtk.Button(stock = gtk.STOCK_EXECUTE) button.connect("clicked", lambda w: self.execute(self.objlist.selected_object())) hbox.add(button) box.pack_start(hbox, False, False) self.switch = gtk.combo_box_new_text() self.switch.append_text("Build") self.switch.append_text("Build & Run") self.switch.append_text("Build & Traced Run") self.switch.append_text("Build & Run + Valgrind") self.switch.append_text("Simulation") self.switch.append_text("Simulation + Valgrind") self.switch.set_active(4) # Select 'Simulation' as default box.pack_start(self.switch, False, False) self.pack_start(box, False, False) hbox = gtk.HBox() self.objlist = ObjectList([("_", object), ("Tests", str) ]) self.objlist.set_size_request(100, 100) self.objlist.object_as_row = lambda obj: [ obj, obj.name ] self.objlist.cursor_changed = self.cursor_changed hbox.pack_start(self.objlist, False, False) self.editor = CodeFileEditor(app, self.app.project.get_syntax_highlight_key()) hbox.pack_start(self.editor) self.pack_start(hbox) tests = collect_tests(app.project) self.objlist.fill(tests) if tests: self.cursor_changed(tests[0]) self.objlist.select_first() else: self.cursor_changed(None) self.show_all() def save(self): if self.editor.get_sensitive(): self.editor.save() def cursor_changed(self, obj): if self.editor.get_sensitive(): self.editor.save() if obj is None: self.editor.set_text("") self.editor.set_sensitive(False) return self.editor.set_sensitive(True) self.editor.load(obj.get_filename()) def refresh_tests(self): tests = collect_tests(self.app.project) self.objlist.refresh(tests) self.cursor_changed(self.objlist.selected_object()) def add_test(self): codetest = CodeTest(self.app.project, "") if testname_dialog(self.app.window, codetest): if not add_test(self.app.project, codetest): self.app.show_error_dialog( "Test {0.name} already exists".format(codetest)) else: return self.refresh_tests() self.objlist.select_object(codetest) self.cursor_changed(codetest) def remove_test(self, obj): if obj is not None: self.cursor_changed(None) obj.remove() tests = collect_tests(self.app.project) self.objlist.clear() self.objlist.fill(tests) self.objlist.select_first() def execute(self, obj): def build(callback): build_config = self.app.project.get_build_config("lib") self.app.start_build(self.app.project, build_config, lambda: obj.build(self.app, callback)) target = self.switch.get_active_text() if target == "Build": build(lambda: self.app.console_write("Build finished\n", "success")) elif target == "Build & Run": build(lambda: obj.run(self.app)) elif target == "Simulation": build(lambda: obj.simulation(self.app, False)) elif target == "Simulation + Valgrind": build(lambda: obj.simulation(self.app, True)) else: self.app.console_write( "Target '{0}' is not implemented.\n".format(target), "error")
class CodeTestList(gtk.VBox): def __init__(self, app): gtk.VBox.__init__(self) self.app = app box = gtk.HBox() hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_START) button = gtk.Button(stock=gtk.STOCK_ADD) button.connect("clicked", lambda w: self.add_test()) hbox.add(button) button = gtk.Button(stock=gtk.STOCK_REMOVE) button.connect( "clicked", lambda w: self.remove_test(self.objlist.selected_object())) hbox.add(button) button = gtk.Button(stock=gtk.STOCK_EXECUTE) button.connect("clicked", lambda w: self.execute(self.objlist.selected_object())) hbox.add(button) box.pack_start(hbox, False, False) self.switch = gtk.combo_box_new_text() self.switch.append_text("Build") self.switch.append_text("Build & Run") self.switch.append_text("Build & Traced Run") self.switch.append_text("Build & Run + Valgrind") self.switch.append_text("Simulation") self.switch.append_text("Simulation + Valgrind") self.switch.set_active(4) # Select 'Simulation' as default box.pack_start(self.switch, False, False) self.pack_start(box, False, False) hbox = gtk.HBox() self.objlist = ObjectList([("_", object), ("Tests", str)]) self.objlist.set_size_request(100, 100) self.objlist.object_as_row = lambda obj: [obj, obj.name] self.objlist.cursor_changed = self.cursor_changed hbox.pack_start(self.objlist, False, False) self.editor = CodeFileEditor( app, self.app.project.get_syntax_highlight_key()) hbox.pack_start(self.editor) self.pack_start(hbox) tests = collect_tests(app.project) self.objlist.fill(tests) if tests: self.cursor_changed(tests[0]) self.objlist.select_first() else: self.cursor_changed(None) self.show_all() def save(self): if self.editor.get_sensitive(): self.editor.save() def cursor_changed(self, obj): if self.editor.get_sensitive(): self.editor.save() if obj is None: self.editor.set_text("") self.editor.set_sensitive(False) return self.editor.set_sensitive(True) self.editor.load(obj.get_filename()) def refresh_tests(self): tests = collect_tests(self.app.project) self.objlist.refresh(tests) self.cursor_changed(self.objlist.selected_object()) def add_test(self): codetest = CodeTest(self.app.project, "") if testname_dialog(self.app.window, codetest): if not add_test(self.app.project, codetest): self.app.show_error_dialog( "Test {0.name} already exists".format(codetest)) else: return self.refresh_tests() self.objlist.select_object(codetest) self.cursor_changed(codetest) def remove_test(self, obj): if obj is not None: self.cursor_changed(None) obj.remove() tests = collect_tests(self.app.project) self.objlist.clear() self.objlist.fill(tests) self.objlist.select_first() def execute(self, obj): def build(callback): build_config = self.app.project.get_build_config("lib") self.app.start_build(self.app.project, build_config, lambda: obj.build(self.app, callback)) target = self.switch.get_active_text() if target == "Build": build( lambda: self.app.console_write("Build finished\n", "success")) elif target == "Build & Run": build(lambda: obj.run(self.app)) elif target == "Simulation": build(lambda: obj.simulation(self.app, False)) elif target == "Simulation + Valgrind": build(lambda: obj.simulation(self.app, True)) else: self.app.console_write( "Target '{0}' is not implemented.\n".format(target), "error")