Exemple #1
0
    def on_quit(self, action=None):
        """
        On quit, show a dialog proposing to save the changes if the scene has
        been modified.
        """
        do_quit = True

        if self.scene.model_modified:
            dialog = QuitDialog(self.window)

            discard_changes = False
            while do_quit and self.scene.model_modified and not discard_changes:
                response = dialog.run()

                if response == QuitDialog.RESPONSE_SAVE:
                    dialog.hide()
                    self.on_save()
                elif response == QuitDialog.RESPONSE_SAVE_AS:
                    dialog.hide()
                    self.on_save_as()
                elif response in [QuitDialog.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                    do_quit = False
                elif response == QuitDialog.RESPONSE_DISCARD:
                    discard_changes = True

            dialog.destroy()

        if do_quit:
            gtk.main_quit()
Exemple #2
0
    def save_changes_dialog(self):
        proceed = True
        if self.scene and self.scene.model_modified:
            dialog = QuitDialog(self.window)
            ask_again = True

            while ask_again:
                response = dialog.run()
                if response == QuitDialog.RESPONSE_SAVE:
                    self.save_file()
                    ask_again = False
                elif response == QuitDialog.RESPONSE_SAVE_AS:
                    self.save_file_as()
                    ask_again = self.scene.model_modified
                elif response in [QuitDialog.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
                    ask_again = False
                    proceed = False
                elif response == QuitDialog.RESPONSE_DISCARD:
                    ask_again = False

            dialog.destroy()

        return proceed