[jokosher-devel] create_new_instrument_type function for Extension API
- From: Luke Tilley <sinisterguy gmail com>
- To: Jokosher Devel List <jokosher-devel-list gnome org>
- Subject: [jokosher-devel] create_new_instrument_type function for Extension API
- Date: Wed, 27 Sep 2006 17:45:15 -0400
I made a little function so extensions can add their own instruments.
Index: Extension.py
===================================================================
--- Extension.py (revision 717)
+++ Extension.py (working copy)
@@ -163,6 +163,41 @@
that equals instrumentID.
"""
self.mainapp.project.DeleteInstrument(instrumentID)
+
+ def create_new_instrument_type(self, defaultName, typeString, imagePath):
+ """
+ Creates and new instrument type in
+ the user's .jokosher/instruments folder
+ return 0: sucess
+ return 1: file exists
+ """
+ instrument_file = os.path.join(Globals.INSTR_PATHS[1], typeString+".instr")
+
+ if not os.path.exists(instrument_file):
+ print "Creating instrument"
+ core = {"icon": "value", "type": "value"}
+
+ instr = ConfigParser.ConfigParser()
+
+ instr.add_section("core")
+ instr.add_section("i18n")
+
+ shutil.copyfile(imagePath, Globals.INSTR_PATHS[1]+"/images/"+os.path.basename(imagePath))
+
+ core["icon"] = os.path.basename(imagePath)
+ core["type"] = typeString
+
+ for key in core:
+ instr.set("core", key, core[key])
+ instr.set("i18n", "en", defaultName)
+
+ file = open(instrument_file, 'w')
+ instr.write(file)
+ file.close()
+ return 0
+ else:
+ print "Instrument Type already exists!"
+ return 1
def add_export_format(self, description, extension, encoderName, muxerName=None, requiresAudioconvert=False):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]