Beispiel #1
0
    def on_new_project(self, button):
        # TODO: Save existing project if needed
        dialog = Gtk.FileChooserDialog("Please choose a folder", self.__main_window,
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK))
        dialog.set_default_size(800, 400)

        result = dialog.run()
        if result == Gtk.ResponseType.OK:
            proj = dialog.get_filename()
            if os.path.isdir(os.path.join(proj, ".soundclip")):
                logger.error("Project exists!")
                d = Gtk.MessageDialog(self.__main_window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                                      "Error: Project Exists")
                d.format_secondary_text("You cannot create a new project in the same directory as an existing one.")
                d.run()
                d.destroy()
            else:
                logger.info("Saving new project to {0}".format(proj))
                p = Project()
                p.change_root(proj)
                self.__main_window.change_project(p)
                # TODO: Project Properties window?
        elif result == Gtk.ResponseType.CANCEL:
            logger.debug("CANCEL")
        dialog.destroy()
Beispiel #2
0
    def on_open_project(self, button):
        # TODO: Save existing project if needed
        dialog = Gtk.FileChooserDialog("Please choose a folder", self.__main_window,
                                       Gtk.FileChooserAction.SELECT_FOLDER,
                                       (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, "Select", Gtk.ResponseType.OK))
        dialog.set_default_size(800, 400)

        result = dialog.run()
        if result == Gtk.ResponseType.OK:
            proj = dialog.get_filename()
            logger.debug("Opening from {0}".format(proj))
            p = Project.load(proj)
            if p:
                self.__main_window.change_project(p)
        elif result == Gtk.ResponseType.CANCEL:
            logger.debug("CANCEL")
        dialog.destroy()