Example #1
0
    def close(self, force=False):
        """Close editor, displays a confirmation dialog for unsaved files.

        Args:
          force: If True, the method doesn't check for changed contents.
        """
        if self.contents_changed() and not force:
            dlg = ConfirmSaveDialog(self.win, [self])
            resp = dlg.run()
            if resp == 1:
                ret = dlg.save_files()
            elif resp == 2:
                ret = True
            else:
                ret = False
            dlg.destroy()
        else:
            ret = True
        if ret:
            if self.get_data("win"):
                self.get_data("win").destroy()
            else:
                self.destroy()
            self.win.set_editor_active(self, False)
            self.win.editor_remove(self)
            return True
Example #2
0
    def close(self, force=False):
        """Close editor, displays a confirmation dialog for unsaved files.

        Args:
          force: If True, the method doesn't check for changed contents.
        """
        if self.contents_changed() and not force:
            dlg = ConfirmSaveDialog(self.win, [self])
            resp = dlg.run()
            if resp == 1:
                ret = dlg.save_files()
            elif resp == 2:
                ret = True
            else:
                ret = False
            dlg.destroy()
        else:
            ret = True
        if ret:
            if self.get_data("win"):
                self.get_data("win").destroy()
            else:
                self.destroy()
            self.win.set_editor_active(self, False)
            self.win.editor_remove(self)
            return True
Example #3
0
    def close_all_editors(self):
        """Closes all editors but checks for changes first.

        Returns:
          False if action was cancelled, otherwise True.
        """
        changed = []
        for item in self.queries.get_all_editors():
            if isinstance(item, Editor) and item.contents_changed():
                changed.append(item)
        if changed:
            dlg = ConfirmSaveDialog(self, changed)
            proceed = dlg.run()
            if proceed == 1:
                dlg.hide()
                if not dlg.save_files():
                    proceed = 0
            dlg.destroy()
            if proceed == 0:
                return False
        for item in self.queries.get_all_editors():
            item.close(force=True)
        return True
Example #4
0
    def close_all_editors(self):
        """Closes all editors but checks for changes first.

        Returns:
          False if action was cancelled, otherwise True.
        """
        changed = []
        for item in self.queries.get_all_editors():
            if isinstance(item, Editor) and item.contents_changed():
                changed.append(item)
        if changed:
            dlg = ConfirmSaveDialog(self, changed)
            proceed = dlg.run()
            if proceed == 1:
                dlg.hide()
                if not dlg.save_files():
                    proceed = 0
            dlg.destroy()
            if proceed == 0:
                return False
        for item in self.queries.get_all_editors():
            item.close(force=True)
        return True