Ejemplo n.º 1
0
 def ok_handler(dlg, path):
     try:
         index = self.instrument.index
         self.instrument.song.instruments.import_from_file(index, path)
         self.instrument = self.instrument.song.instruments[index]
         self.instr_imported_channel.publish(self.instrument)
     except Exception, e:
         utils.show_error_dialog('Import Failed', str(e), self)
Ejemplo n.º 2
0
 def ok_handler(dlg, path):
     try:
         proj = load_srm(path)
         sav_obj.projects[index] = proj
         channels.SONG_MODIFIED(index).publish(proj)
     except Exception, e:
         utils.show_error_dialog(
             "can't load file", 'Error loading file: %s' % (e), None, e)
Ejemplo n.º 3
0
 def ok_handler(dlg, path):
     try:
         proj = event_handlers.load_lsdsng(path)
         sav_obj.projects[index] = proj
     except Exception, e:
         utils.show_error_dialog(
             "can't load file", 'Error loading file: %s' % (e),
             None)
Ejemplo n.º 4
0
def get_song_from_windows(projects_window, main_window, ignore_existing=False):
    selected_obj = projects_window.sav_project_list.GetSelectedObject()
    index = selected_obj.index
    current_proj = selected_obj.project

    if current_proj is not None and not ignore_existing:
        utils.show_error_dialog(
            "Invalid Selection",
            "Song slot %d is currently occupied and cannot be saved over" %
            (index + 1), None)
        return

    sav_obj = main_window.get_sav()

    return (index, sav_obj)
Ejemplo n.º 5
0
    def saveCopy(self):
        file_name = self._active_doc.getSaveFilename()

        try:
            self._active_doc.saveDrawingPDF()
            file_size = get_file_size(self._active_doc.getSavePath())
            self.l.info('Saved copy "{}" from "{}".'.format(file_name, self._active_doc.path))
            self.tempStatusMessage('Saved copy as "{}" ({})'.format(file_name, format_file_size(file_size)))
        except RuntimeError as e:
            msg = str(e).capitalize()
            self.l.error(msg)
            show_error_dialog(self, msg)

        if self._active_dir is not None:
            self._active_dir.refresh()
Ejemplo n.º 6
0
    def ok_handler(dlg, path):
        sav_obj = None

        def progress_update_function(message, step, total_steps, still_working):
            pass

        try:
            sav_obj = SAVFile(path, callback=progress_update_function)

            if sav_obj is not None:
                main_window.set_sav(sav_obj)
                main_window.update_models()
        except Exception, e:
            utils.show_error_dialog(
                "Failed to load '%s'" % (dlg.GetFilename()),
                e, projects_window)
Ejemplo n.º 7
0
    def openDocument(self, new_doc, standalone=False):
        assert isinstance(new_doc, GMDoc)

        if standalone:
            self.closeDirectory()

        self._active_doc = new_doc

        try:
            self._active_doc.open()
            self.onDocumentOpened()
        except RuntimeError as e:
            msg = str(e).capitalize()
            self.l.error(msg)
            show_error_dialog(self, msg)
            self.tempStatusMessage('Could not open "{}".'.format(new_doc.name))

            if self._active_dir is not None:
                self._active_dir.refresh()
Ejemplo n.º 8
0
    def openDirectory(self, path):
        self.closeDirectory()

        try:
            self._active_dir = GMDir(self, path)
            self._active_dir.setupTab(self.ui.tabWidget)

            self.ui.tabWidget.setCurrentIndex(self._active_dir.tab_index)

            if len(self._active_dir.documents) > 0:
                if self._active_doc is not None:
                    self.closeDocument()

                doc = self._active_dir.getDocumentByIndex(0)
                self.openDocument(doc)
        except OSError as e:
            msg = str(e).capitalize()
            self.l.error(msg)
            show_error_dialog(self, msg)
            self.tempStatusMessage('Could not open directory "{}".'.format(path))

        self.updateDirectoryActions()
        self.updateFileActions()