Beispiel #1
0
 def setup(self):
     undo.setstack(undo.Stack())
     @undo.undoable
     def action():
         yield
     self.action = action
     self.calls = 0
Beispiel #2
0
 def test_setstack(self):
     'Test that a new stack can be set'
     old = undo.stack()
     new = undo.Stack()
     undo.setstack(new)
     stack = undo.stack()
     assert stack is new
     assert stack is not old
Beispiel #3
0
 def setup(self):
     # Create a mock action for use in tests
     class Action:
         def do(self): pass
         def undo(self): pass
         def text(self):
             return 'blah'
     self.action = Action()
     undo.setstack(undo.Stack())
Beispiel #4
0
    def setup(self):
        # Test a complicated nested case
        @undo.undoable
        def add(seq, item):
            seq.append(item)
            yield 'Add'
            delete(seq)

        @undo.undoable
        def delete(seq):
            value = seq.pop()
            yield 'Delete'
            add(seq, value)

        self.add = add
        self.delete = delete
        undo.setstack(undo.Stack())
Beispiel #5
0
    def __init__(self):
        log.info('MainWindow - initialise')

        # Check for project active status
        self.project_active = False

        # Setup main data model
        self.data = data.datamodel.DataModel()

        # Initialise undo/redo stack
        self.stack = undo.Stack()
        undo.setstack(self.stack)
        # Save point in stack for checking change state
        self.stack.savepoint()

        # Other variables
        self.filename = None

        # Setup main window
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            misc.abs_path("interface", "mainwindow.glade"))
        self.window = self.builder.get_object("window_main")
        self.builder.connect_signals(self)

        # Setup project settings dictionary
        self.project_settings_dict = dict()
        for item_code in misc.global_vars:
            self.project_settings_dict[item_code] = ''

        # Load global Variables
        misc.set_global_platform_vars()

        # Setup about dialog
        self.about_dialog = self.builder.get_object("aboutdialog")

        # Setup schedule View
        self.treeview_schedule = self.builder.get_object("treeview_schedule")
        self.schedule_view = view.schedule.ScheduleView(
            self.window, self.treeview_schedule, self.data.schedule)

        # Setup bill View
        self.treeview_bill = self.builder.get_object("treeview_bill")
        self.bill_view = view.bill.BillView(self.window, self.data,
                                            self.treeview_bill)

        # Setup measurement View
        self.treeview_meas = self.builder.get_object("treeview_meas")
        self.measurements_view = view.measurement.MeasurementsView(
            self.window, self.data, self.treeview_meas)

        # Darg-Drop support for files
        self.window.drag_dest_set(
            Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT
            | Gtk.DestDefaults.DROP,
            [Gtk.TargetEntry.new("text/uri-list", 0, 80)], Gdk.DragAction.COPY)
        self.window.connect('drag-data-received', self.drag_data_received)

        # Setup custom measurement items
        file_names = [f for f in os.listdir(misc.abs_path('templates'))]
        module_names = []
        for f in file_names:
            if f[-3:] == '.py' and f != '__init__.py':
                module_names.append(f[:-3])
        self.custom_menus = []
        popupmenu = self.builder.get_object("popover_meas_box")
        module_names.sort()
        for module_name in module_names:
            try:
                package = __import__('templates.' + module_name)
                module = getattr(package, module_name)
                custom_object = module.CustomItem()
                name = custom_object.name
                menuitem = Gtk.ModelButton(text=name)
                popupmenu.pack_start(menuitem, False, False, 0)
                menuitem.set_visible(True)
                menuitem.connect("clicked", self.onMeasCustomMenuClicked,
                                 module_name)
                self.custom_menus.append(menuitem)
                log.info('Plugin loaded - ' + module_name)
            except ImportError:
                log.error('Error Loading plugin - ' + module_name)
Beispiel #6
0
 def setup(self):
     #Set undo.stack() to a list, stored as self.stack
     self.stack = []
     undo.setstack(self.stack)
Beispiel #7
0
 def setup(self):
     undo.setstack(undo.Stack())