def unhide_plugin(self, id): """ Unhide plugin with given id. This will unhide the plugin so queries return it again, and write this change to the config """ self.__hidden_plugins.remove(id) config.set("plugin.hiddenplugins", list(self.__hidden_plugins)) config.save() self.__hidden_changed()
def unhide_plugin(self, id): """ Unhide plugin with given id. This will unhide the plugin so queries return it again, and write this change to the config """ self.__hidden_plugins.remove(id) config.set('plugin.hiddenplugins', list(self.__hidden_plugins)) config.save() self.__hidden_changed()
def _save_position(self): """ Save the window's position to the config file """ if self.horiz_position_key is not None: (horiz_position, vert_position) = self.window.get_position() config.set(self.horiz_position_key, horiz_position) config.set(self.vert_position_key, vert_position) config.save()
def _save_size(self): """ Save the dimensions of the window to the config file """ if self.width_key is not None: (width, height) = self.window.get_size() config.set(self.width_key, width) config.set(self.height_key, height) config.save()
def hide_plugin(self, id): """ Hide plugin with given id. This will hide the plugin so queries do not return it anymore, and write this change to the config. Note that config will then emit a signal """ self.__hidden_plugins.add(id) config.set("plugin.hiddenplugins", list(self.__hidden_plugins)) config.save() self.__hidden_changed()
def hide_plugin(self, id): """ Hide plugin with given id. This will hide the plugin so queries do not return it anymore, and write this change to the config. Note that config will then emit a signal """ self.__hidden_plugins.add(id) config.set('plugin.hiddenplugins', list(self.__hidden_plugins)) config.save() self.__hidden_changed()
def _save_size(self): """ Save the dimensions of the window to the config file """ # self.width_key is set in the subclass (or in setup_configs) if self.width_key is not None: (width, height) = self.window.get_size() config.set(self.width_key, width) config.set(self.height_key, height) config.save()
def _save_size(self): """ Save the dimensions of the window to the config file """ # self.width_key is set in the subclass, typically in its _local_init if self.width_key is not None: (width, height) = self.window.get_size() config.set(self.width_key, width) config.set(self.height_key, height) config.save()
def set_mapservice(self, mapkey): """ change the service that runs on click of the menutoolbutton used as callback menu on menu clicks """ self.mapservice = mapkey for label in self.mapslistlabel: label.set_label(self.mapservice_label()) label.show() config.set('interface.mapservice', mapkey) config.save()
def _save_position(self, save_config=True): """ Save the window's position to the config file (You can set save_config False if a _save_size() will instantly follow) """ # self.horiz_position_key is set in the subclass (or in setup_configs) if self.horiz_position_key is not None: (horiz_position, vert_position) = self.window.get_position() config.set(self.horiz_position_key, horiz_position) config.set(self.vert_position_key, vert_position) if save_config: config.save()
def set_mapservice(self, action, value): """ change the service that runs on click of the menutoolbutton used as callback menu on menu clicks """ if action: action.set_state(value) self.mapservice = mapkey = value.get_string() config.set('interface.mapservice', mapkey) config.save() _ui = self.__create_maps_menu_actions() self.uimanager.add_ui_from_string(_ui) self.uimanager.update_menu() return False
def _update(self): """ store changed objects formats in DB """ update = False for prim_obj, dummy in self.xobjects: obj_value = self.obj_values[prim_obj] if obj_value.object_fmt != obj_value.stored_fmt: constant = 'preferences.%sprefix' % PREFIXES[prim_obj] config.set(constant, obj_value.object_fmt) update = True if update: config.save() self.db.set_prefixes(config.get('preferences.iprefix'), config.get('preferences.oprefix'), config.get('preferences.fprefix'), config.get('preferences.sprefix'), config.get('preferences.cprefix'), config.get('preferences.pprefix'), config.get('preferences.eprefix'), config.get('preferences.rprefix'), config.get('preferences.nprefix'))
def _update(self): """ store changed objects formats in DB """ update = False for prim_obj, dummy in self.xobjects: obj_value = self.obj_values[prim_obj] if obj_value.object_fmt != obj_value.stored_fmt: constant = 'preferences.%sprefix' % PREFIXES[prim_obj] config.set(constant, obj_value.object_fmt) update = True if update: config.save() self.db.set_prefixes( config.get('preferences.iprefix'), config.get('preferences.oprefix'), config.get('preferences.fprefix'), config.get('preferences.sprefix'), config.get('preferences.cprefix'), config.get('preferences.pprefix'), config.get('preferences.eprefix'), config.get('preferences.rprefix'), config.get('preferences.nprefix'))
def update_checkbox(self, obj, constant): config.set(constant, obj.get_active()) config.save()
def _cleanup_on_exit(self): config.set('behavior.addmedia-image-dir', self.last_directory) config.set('behavior.addmedia-relative-path', self.relative_path) config.save()
def _cleanup_on_exit(self): config.set("behavior.addmedia-image-dir", self.last_directory) config.set("behavior.addmedia-relative-path", self.relative_path) config.save()
def __refresh_addon_list(self, obj): """ Reloads the addons from the wiki into the list. """ if sys.version_info[0] < 3: from urllib2 import urlopen else: from urllib.request import urlopen from ..utils import ProgressMeter URL = "%s%s" % (URL_WIKISTRING, WIKI_EXTRAPLUGINS_RAWDATA) try: fp = urlopen(URL) except: print("Error: cannot open %s" % URL) return pm = ProgressMeter(_("Refreshing Addon List")) pm.set_pass(header=_("Reading gramps-project.org...")) state = "read" rows = [] row = [] lines = fp.readlines() pm.set_pass(total=len(lines), header=_("Reading gramps-project.org...")) for line in lines: pm.step() if line.startswith("|-") or line.startswith("|}"): if row != []: rows.append(row) state = "row" row = [] elif state == "row": if line.startswith("|"): row.append(line[1:].strip()) else: state = "read" fp.close() rows.sort(key=lambda row: (row[1], row[0])) self.addon_model.clear() # clear the config list: config.get('plugin.addonplugins')[:] = [] pm.set_pass(total=len(rows), header=_("Checking addon...")) for row in rows: pm.step() try: # from wiki: help_name, ptype, image, desc, use, rating, contact, download = row except: continue help_url = _("Unknown Help URL") if help_name.startswith("[[") and help_name.endswith("]]"): name = help_name[2:-2] if "|" in name: help_url, name = name.split("|", 1) elif help_name.startswith("[") and help_name.endswith("]"): name = help_name[1:-1] if " " in name: help_url, name = name.split(" ", 1) else: name = help_name url = _("Unknown URL") if download.startswith("[[") and download.endswith("]]"): # Not directly possible to get the URL: url = download[2:-2] if "|" in url: url, text = url.split("|", 1) # need to get a page that says where it is: fp = urlopen("%s%s%s" % (URL_WIKISTRING, url, "&action=edit&externaledit=true&mode=file")) for line in fp: if line.startswith("URL="): junk, url = line.split("=", 1) break fp.close() elif download.startswith("[") and download.endswith("]"): url = download[1:-1] if " " in url: url, text = url.split(" ", 1) if (url.endswith(".zip") or url.endswith(".ZIP") or url.endswith(".tar.gz") or url.endswith(".tgz")): # Then this is ok: self.addon_model.append(row=[ help_name, name, ptype, image, desc, use, rating, contact, download, url ]) config.get('plugin.addonplugins').append([ help_name, name, ptype, image, desc, use, rating, contact, download, url ]) pm.close() config.save()
def __refresh_addon_list(self, obj): """ Reloads the addons from the wiki into the list. """ from urllib.request import urlopen from ..utils import ProgressMeter URL = "%s%s" % (URL_WIKISTRING, WIKI_EXTRAPLUGINS_RAWDATA) try: fp = urlopen(URL) except: print("Error: cannot open %s" % URL) return pm = ProgressMeter(_("Refreshing Addon List")) pm.set_pass(header=_("Reading gramps-project.org...")) state = "read" rows = [] row = [] lines = fp.readlines() pm.set_pass(total=len(lines), header=_("Reading gramps-project.org...")) for line in lines: pm.step() if line.startswith("|-") or line.startswith("|}"): if row != []: rows.append(row) state = "row" row = [] elif state == "row": if line.startswith("|"): row.append(line[1:].strip()) else: state = "read" fp.close() rows.sort(key=lambda row: (row[1], row[0])) self.addon_model.clear() # clear the config list: config.get('plugin.addonplugins')[:] = [] pm.set_pass(total=len(rows), header=_("Checking addon...")) for row in rows: pm.step() try: # from wiki: help_name, ptype, image, desc, use, rating, contact, download = row except: continue help_url = _("Unknown Help URL") if help_name.startswith("[[") and help_name.endswith("]]"): name = help_name[2:-2] if "|" in name: help_url, name = name.split("|", 1) elif help_name.startswith("[") and help_name.endswith("]"): name = help_name[1:-1] if " " in name: help_url, name = name.split(" ", 1) else: name = help_name url = _("Unknown URL") if download.startswith("[[") and download.endswith("]]"): # Not directly possible to get the URL: url = download[2:-2] if "|" in url: url, text = url.split("|", 1) # need to get a page that says where it is: fp = urlopen("%s%s%s" % (URL_WIKISTRING, url, "&action=edit&externaledit=true&mode=file")) for line in fp: if line.startswith("URL="): junk, url = line.split("=", 1) break fp.close() elif download.startswith("[") and download.endswith("]"): url = download[1:-1] if " " in url: url, text = url.split(" ", 1) if (url.endswith(".zip") or url.endswith(".ZIP") or url.endswith(".tar.gz") or url.endswith(".tgz")): # Then this is ok: self.addon_model.append(row=[help_name, name, ptype, image, desc, use, rating, contact, download, url]) config.get('plugin.addonplugins').append([help_name, name, ptype, image, desc, use, rating, contact, download, url]) pm.close() config.save()