--- a/PluginProjectDjango.py Wed Mar 27 09:22:59 2013 +0100 +++ b/PluginProjectDjango.py Sun Mar 31 17:07:43 2013 +0200 @@ -149,6 +149,8 @@ self.__mainMenu = None self.__e5project = e5App().getObject("Project") + + self.__supportedVariants = [] def __checkVersions(self): """ @@ -185,18 +187,21 @@ self.__mainMenu = self.__object.initMenu() - try: - self.__e5project.registerProjectType("Django", self.trUtf8("Django"), - self.fileTypesCallback, - lexerAssociationCallback=self.lexerAssociationCallback, - binaryTranslationsCallback=self.binaryTranslationsCallback, - progLanguages=["Python2", "Python3"]) - except TypeError: - # for backward compatibility - self.__e5project.registerProjectType("Django", self.trUtf8("Django"), - self.fileTypesCallback, - lexerAssociationCallback=self.lexerAssociationCallback, - binaryTranslationsCallback=self.binaryTranslationsCallback) + self.__supportedVariants = self.__object.supportedPythonVariants() + + if self.__supportedVariants: + try: + self.__e5project.registerProjectType("Django", self.trUtf8("Django"), + self.fileTypesCallback, + lexerAssociationCallback=self.lexerAssociationCallback, + binaryTranslationsCallback=self.binaryTranslationsCallback, + progLanguages=self.__supportedVariants[:]) + except TypeError: + # for backward compatibility + self.__e5project.registerProjectType("Django", self.trUtf8("Django"), + self.fileTypesCallback, + lexerAssociationCallback=self.lexerAssociationCallback, + binaryTranslationsCallback=self.binaryTranslationsCallback) from Project.ProjectBrowser import SourcesBrowserFlag, FormsBrowserFlag, \ TranslationsBrowserFlag, OthersBrowserFlag @@ -366,3 +371,31 @@ @param prefClass preferences class used as the storage area """ Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value) + + if key in ["VirtualEnvironmentPy2", "VirtualEnvironmentPy3"]: + self.__reregisterProjectType() + + def __reregisterProjectType(self): + """ + Private method to re-register the project type. + """ + supportedVariants = self.__object.supportedPythonVariants() + if supportedVariants != self.__supportedVariants: + # step 1: unregister + self.__e5project.unregisterProjectType("Django") + + # step 2: register again with new language settings + self.__supportedVariants = supportedVariants + if self.__supportedVariants: + try: + self.__e5project.registerProjectType("Django", self.trUtf8("Django"), + self.fileTypesCallback, + lexerAssociationCallback=self.lexerAssociationCallback, + binaryTranslationsCallback=self.binaryTranslationsCallback, + progLanguages=self.__supportedVariants[:]) + except TypeError: + # for backward compatibility + self.__e5project.registerProjectType("Django", self.trUtf8("Django"), + self.fileTypesCallback, + lexerAssociationCallback=self.lexerAssociationCallback, + binaryTranslationsCallback=self.binaryTranslationsCallback)