def run(self): prefs = Utility.loadPrefs(Globals.options).get(PLUGIN_NAME) if prefs is not None: license = prefs.get('license') if license: setLicense(license) return False # no need to run again
def deactivatePlugin(self, project_name, plugin_env): view = self.itsView prefs = Utility.loadPrefs(Globals.options) pluginPrefs = self.widget.GetSubMenu().pluginPrefs for egg in plugin_env[project_name]: break else: return None def deleteItems(item): for child in item.iterChildren(): deleteItems(child) if isinstance(item, Kind): for instance in item.iterItems(): instance.delete(True) for ep in egg.get_entry_map('chandler.parcels').values(): parcel = Parcel.find_parcel_from_entrypoint(view, ep) if parcel is not None: deleteItems(parcel) parcel.delete(True) pluginPrefs[ep.dist.key] = 'inactive' if 'plugins' not in prefs: prefs['plugins'] = pluginPrefs else: prefs['plugins'].update(pluginPrefs) self.widget.GetSubMenu().pluginPrefs = prefs['plugins'] prefs.write() return egg
def showLocalePickerDialog(): win = LocalePickerDialog() win.CenterOnScreen() val = win.ShowModal() if val == wx.ID_OK: # Get the new locale and if it differs from # current locale restart Chandler currentLocale = getLocale() newLocale = win.GetValue() if newLocale != currentLocale: prefs = Utility.loadPrefs(Globals.options) if "options" not in prefs: prefs["options"] = {} prefs["options"]["locale"] = newLocale prefs.write() # The locale needs to be passed since # restart preserves the command line # options from the previous startup. # If the previous startup contained # a locale command line flag it # will override the value for the locale # just added to the prefs file and # Chandler will not switch the locale # as expected. wx.GetApp().restart(locale=newLocale) win.Destroy()
def instantiateWidget(self): menu = wxPluginMenu() menu.blockItem = self menu.pluginPrefs = Utility.loadPrefs(Globals.options).get('plugins', {}) # if we don't give the MenuItem a label, i.e. test = " " widgets # will use the assume the id is for a stock menuItem and will fail return wxMenuItem(None, id=self.getWidgetID(), text=" ", subMenu=menu)
def instantiateWidget(self): menu = wxPluginMenu() menu.blockItem = self menu.pluginPrefs = Utility.loadPrefs(Globals.options).get( 'plugins', {}) # if we don't give the MenuItem a label, i.e. test = " " widgets # will use the assume the id is for a stock menuItem and will fail return wxMenuItem(None, id=self.getWidgetID(), text=" ", subMenu=menu)
def activatePlugin(self, project_name, plugin_env): view = self.itsView prefs = Utility.loadPrefs(Globals.options) pluginPrefs = self.widget.GetSubMenu().pluginPrefs for egg in plugin_env[project_name]: pkg_resources.working_set.add(egg) for ep in egg.get_entry_map('chandler.parcels').values(): try: ep.require(plugin_env) requires = egg.requires(ep.extras) except pkg_resources.ResolutionError: logger.exception("Activating %s failed", egg.egg_name()) return None, None break else: return None, None dependencies = pkg_resources.working_set.resolve(requires) for ep in pkg_resources.iter_entry_points('chandler.parcels'): name = ep.dist.key if plugin_env[name]: # only handle plugin entrypoints if ep.dist == egg or ep.dist in dependencies: if pluginPrefs.get(name, 'inactive') == 'inactive': Parcel.load_parcel_from_entrypoint(view, ep) pluginPrefs[name] = 'active' else: dependencies.remove(ep.dist) if 'plugins' not in prefs: prefs['plugins'] = pluginPrefs else: prefs['plugins'].update(pluginPrefs) self.widget.GetSubMenu().pluginPrefs = prefs['plugins'] prefs.write() return egg, dependencies
def promptLicense(): dialog = LicenseDialog(wx.GetApp().mainFrame, -1) dialog.CenterOnScreen() if dialog.ShowModal() == wx.ID_OK: params = dialog.getParameters() else: params = None dialog.Destroy() if params is not None: license = params['license'] if license: prefs = Utility.loadPrefs(Globals.options) pluginPrefs = prefs.setdefault(PLUGIN_NAME, {}) pluginPrefs['license'] = license prefs.write() setLicense(license) return True return False