Exemple #1
0
 def __init__(self):
     self.images = ImageList()
     self.cur_image = None
     self.surfaces = ObjectList()
     self.cur_surface = None
     self.volumes = ObjectList()
     self.cur_volume = None
     self.materials = {
         'surface_default': SurfaceMaterial.default(),
         'volume_default': VolumeMaterial.default()
     }
Exemple #2
0
    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()
Exemple #3
0
 def __init__(self):
     self.images = ImageList()
     self.cur_image = None
     self.surfaces = ObjectList()
     self.cur_surface = None
     self.volumes = ObjectList()
     self.cur_volume = None
     self.materials = {
         'default': SurfaceMaterial.default(),
         'bronze': SurfaceMaterial.bronze(),
         'silver': SurfaceMaterial.silver(),
         'gold': SurfaceMaterial.gold(),
         'volume_default': VolumeMaterial.default()
     }
    def __init__(self, project, mainwindow):
        defs = [("_", object),
                ("Name", str),
                ("Policy", str),
                ("Type", str),
                ("Default", str),
                ("Description", str)]
        buttons = [
            (None, gtk.STOCK_ADD, self._add_parameter),
            (None, gtk.STOCK_REMOVE, self._remove_parameter),
            (None, gtk.STOCK_EDIT, self._edit_parameter)]

        ObjectList.__init__(self, defs, buttons)
        self.project = project
        self.mainwindow = mainwindow

        self.fill(project.get_parameters())
Exemple #5
0
    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()
Exemple #6
0
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")
Exemple #7
0
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")