Beispiel #1
0
class ShrinkEditor:
    def __init__(self, parent, storage):
        self.storage = storage
        self.intf = parent.intf
        self.parent = parent
        self.dialog = Dialog(_("Partitions to Shrink"), closeButton=False)
        self.dialog.addWidget(ShrinkWidget(self))
        self.dialog.resize(QSize(0,0))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []

            if not rc:
                self.destroy()
                return (rc, operations)

            widget = self.dialog.content

            request = widget.partitions.itemData(widget.partitions.currentIndex()).toPyObject()
            newsize = widget.sizeSpin.value()

            try:
                operations.append(OperationResizeFormat(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize FileSystem Error"),
                                        _("%(device)s: %(msg)s") %
                                        {'device': request.format.device, 'msg': e.message},
                                        type="error")
                continue

            try:
                operations.append(OperationResizeDevice(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize Device Error"),
                                              _("%(name)s: %(msg)s") %
                                               {'name': request.name, 'msg': e.message},
                                               type="warning")
                continue

            # everything ok, fall out of loop
            break

        self.dialog.destroy()

        return (rc, operations)

    def destroy(self):
        if self.dialog:
            self.dialog = None
Beispiel #2
0
class ShrinkEditor:
    def __init__(self, parent, storage):
        self.storage = storage
        self.intf = parent.intf
        self.parent = parent
        self.dialog = Dialog(_("Partitions to Shrink"), closeButton=False)
        self.dialog.addWidget(ShrinkWidget(self))
        self.dialog.resize(QSize(0,0))

    def run(self):
        if self.dialog is None:
            return []

        while 1:
            rc = self.dialog.exec_()
            operations = []

            if not rc:
                self.destroy()
                return (rc, operations)

            widget = self.dialog.content

            request = widget.partitions.itemData(widget.partitions.currentIndex())#.toPyObject() burada hata olabilir
            newsize = widget.sizeSpin.value()

            try:
                operations.append(OperationResizeFormat(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize FileSystem Error"),
                                        _("%(device)s: %(msg)s") %
                                        {'device': request.format.device, 'msg': e.message},
                                        type="error")
                continue

            try:
                operations.append(OperationResizeDevice(request, newsize))
            except ValueError as e:
                self.intf.messageWindow(_("Resize Device Error"),
                                              _("%(name)s: %(msg)s") %
                                               {'name': request.name, 'msg': e.message},
                                               type="warning")
                continue

            # everything ok, fall out of loop
            break

        self.dialog.destroy()

        return (rc, operations)

    def destroy(self):
        if self.dialog:
            self.dialog = None