def __init__(self, dbstate, user, options_class, name, callback=None): tool.Tool.__init__(self, dbstate, options_class, name) if not dbstate.db: return # Initialize the server if running for the first time. if not Topola.server: Topola.server = TopolaServer(HTTP_PORT) Topola.server.start() Topola.server.set_database(dbstate.db) display_url( 'https://pewu.github.io/topola-viewer/#/view' + '?utm_source=gramps&handleCors=false&standalone=false' + '&url=http://127.0.0.1:{}/'.format(HTTP_PORT))
def __init__(self, dbstate, user, options_class, name, callback=None): tool.Tool.__init__(self, dbstate, options_class, name) if not dbstate.db: return if not Topola.server: Topola.server = TopolaServer() Topola.server.start() temp_file = mkstemp()[1] ged_writer = GedcomWriter(dbstate.db, User()) ged_writer.write_gedcom_file(temp_file) Topola.server.set_path(temp_file) display_url('https://pewu.github.io/topola-viewer/#/view' + '?utm_source=gramps&handleCors=false&standalone=false' + '&url=http://127.0.0.1:{}/'.format(HTTP_PORT))
def refresh_list(self): grid = self.g.get_object('grid1') row = 3 for plugin_name in self.plugin_list: grid.remove_row(3) for plugin_name in self.plugin_list: is_installed = self.is_installed(plugin_name) #print(plugin_name,is_installed) label1 = Gtk.Label(plugin_name) grid.attach(label1, 0, row, 1, 1) label1.show() if is_installed: label2 = Gtk.Label(sgettext("fetchplugins|installed")) grid.attach(label2, 1, row, 1, 1) label2.show() button_label = sgettext("fetchplugins|Remove") button_install_or_remove = Gtk.Button(button_label) button_install_or_remove.connect("clicked", lambda obj, plugin_name=plugin_name: self.__remove_plugin(plugin_name)) else: button_label = sgettext("fetchplugins|Install") button_install_or_remove = Gtk.Button(button_label) button_install_or_remove.connect("clicked", lambda obj, plugin_name=plugin_name: self.__install_plugin(plugin_name)) grid.attach(button_install_or_remove, 2, row, 1, 1) button_install_or_remove.show() help_url = help_base_url + plugin_name button_help = Gtk.Button(sgettext("fetchplugins|Help")) button_help.connect("clicked", lambda obj, url=help_url: display_url(url)) grid.attach(button_help, 3, row, 1, 1) button_help.show() row += 1 grid.show()
def get_url(self, citation): for handle in citation.get_note_list(): note = self.dbstate.db.get_note_from_handle(handle) text = note.get() url_match = re.compile(r'https?://[^\s]+') result = URL_MATCH.search(text) if result: url = result.group(0) link_func = lambda x,y,z: display_url(url) name = (url, None) link_label = widgets.LinkLabel(name, link_func, None, False, theme=self.theme) link_label.set_tooltip_text(_('Click to visit this link')) return link_label return None
def on_help_clicked(self, widget): """ Display the relevant portion of Gramps manual. """ display_url(WIKI_URL)
def callback(self, widget): results = make_person_dict(self.dbstate, self.handle) display_url(self.pattern % results, self.uistate)
def on_help_clicked(self, widget): display_url("https://www.gramps-project.org/wiki/index.php/PlaceCoordinateGramplet")
def WriteXML(self, log, first, last, surnames, places, sources): """ Write the result of the query for distributed, shared protocols """ # Custom XML file in buffer self.lang = xml_lang() self.title = _('I am looking at ...') self.footer = _('Content generated by Gramps') self.surnames_title = _('Surnames') self.places_name = _('Places') self.sources_title = _('List of sources') time = date.Today() xml = etree.Element("query") xml.set("lang", self.lang) xml.set("title", self.title) xml.set("footer", self.footer) xml.set("date", gramps.gen.datehandler.displayer.display(time)) xml.set("first", first) xml.set("last", last) # only for info doc = etree.ElementTree(xml) # custom countries list (re-use some Gramps translations ...) ;) countries = [ '', _('Australia'), _('Brazil'), _('Bulgaria'), _('Canada'), _('Chile'), _('China'), _('Croatia'), _('Czech Republic'), _('England'), _('Finland'), _('France'), _('Germany'), _('India'), _('Japan'), _('Norway'), _('Portugal'), _('Russia'), _('Sweden'), _('United States of America'), ] c = etree.SubElement(xml, "clist") self.name = _('Name') self.country = _('Country') c.set("pname", self.name) c.set("country", self.country) for country in countries: c1 = etree.SubElement(c, "country") c1.text = country # data log [(k1, v1), (k2, v2)] = log l = etree.SubElement(xml, "log") l.set("date", v1) l.set("version", v2) s = etree.SubElement(xml, "surnames") s.set("title", self.surnames_title) surnames.sort() cnt = [] for surname in surnames: if surname not in cnt: s1 = etree.SubElement(s, "surname") s1.text = surname cnt.append(surname) p = etree.SubElement(xml, "places") p.set("pname", self.places_name) places.sort() for place in places: p1 = etree.SubElement(p, "place") p1.text = place src = etree.SubElement(xml, "sources") src.set("title", self.sources_title) sources.sort() for source in sources: src1 = etree.SubElement(src, "source") src1.text = source content = etree.XML(etree.tostring(xml, encoding="UTF-8")) # XSLT process xslt_doc = etree.parse( os.path.join(USER_PLUGINS, 'lxml', 'query_html.xsl')) transform = etree.XSLT(xslt_doc) outdoc = transform(content) #print(type(outdoc)) html = os.path.join(USER_PLUGINS, 'lxml', 'query.html') outfile = open(html, 'w') outfile.write(str(outdoc)) outfile.close() # clear the etree content.clear() # This is the end ! sys.stdout.write(_('1. Has generated "%s".\n') % html) LOG.info( _('Try to open\n "%s"\n into your prefered web navigator ...') % html) display_url(html)
def on_activate_link(label, uri): # see aboutdialog.py _show_url() display_url(uri) return True
def WriteXML(self, log, first, last, surnames, places, sources): """ Write the result of the query for distributed, shared protocols """ # Custom XML file in buffer self.lang = xml_lang() self.title = _('I am looking at ...') self.footer = _('Content generated by Gramps') self.surnames_title = _('Surnames') self.places_name = _('Places') self.sources_title = _('List of sources') time = date.Today() xml = etree.Element("query") xml.set("lang", self.lang) xml.set("title", self.title) xml.set("footer", self.footer) xml.set("date", gramps.gen.datehandler.displayer.display(time)) xml.set("first", first) xml.set("last", last) # only for info doc = etree.ElementTree(xml) # custom countries list (re-use some Gramps translations ...) ;) countries = ['', _('Australia'), _('Brazil'), _('Bulgaria'), _('Canada'), _('Chile'), _('China'), _('Croatia'), _('Czech Republic'), _('England'), _('Finland'), _('France'), _('Germany'), _('India'), _('Japan'), _('Norway'), _('Portugal'), _('Russia'), _('Sweden'), _('United States of America'), ] c = etree.SubElement(xml, "clist") self.name = _('Name') self.country = _('Country') c.set("pname", self.name) c.set("country", self.country) for country in countries: c1 = etree.SubElement(c, "country") c1.text = country # data log [(k1, v1),(k2, v2)] = log l = etree.SubElement(xml, "log") l.set("date", v1) l.set("version", v2) s = etree.SubElement(xml, "surnames") s.set("title", self.surnames_title) surnames.sort() cnt = [] for surname in surnames: if surname not in cnt: s1 = etree.SubElement(s, "surname") s1.text = surname cnt.append(surname) p = etree.SubElement(xml, "places") p.set("pname", self.places_name) places.sort() for place in places: p1 = etree.SubElement(p, "place") p1.text = place src = etree.SubElement(xml, "sources") src.set("title", self.sources_title) sources.sort() for source in sources: src1 = etree.SubElement(src, "source") src1.text = source content = etree.XML(etree.tostring(xml, encoding="UTF-8")) # XSLT process xslt_doc = etree.parse(os.path.join(USER_PLUGINS, 'lxml', 'query_html.xsl')) transform = etree.XSLT(xslt_doc) outdoc = transform(content) #print(type(outdoc)) html = os.path.join(USER_PLUGINS, 'lxml', 'query.html') outfile = open(html, 'w') outfile.write(str(outdoc)) outfile.close() # clear the etree content.clear() # This is the end ! sys.stdout.write(_('1. Has generated "%s".\n') % html) LOG.info(_('Try to open\n "%s"\n into your prefered web navigator ...') % html) display_url(html)
def callback(self, widget): from gramps.gui.display import display_url results = make_person_dict(self.dbstate, self.handle) display_url(self.pattern % results, self.uistate)
def cb_start_browser(self, obj): display_url("http://localhost:{}".format(self.port))
def on_pref_help_clicked(self, dummy): ''' Button: Display the relevant portion of GRAMPS manual''' display_url(PREFS_WIKI)
def __help(self, obj ): url = "http://wiki.isotammi.net/wiki/Gramps-laajennus:PropertyEditor" display.display_url(url)
def on_showInBrowserButton_clicked(self, widget): if(len(self.entry_lat.get_text()) > 0 and len(self.entry_long.get_text()) > 0): path = "http://maps.google.com/maps?q=%s,%s" % ( self.entry_lat.get_text(), self.entry_long.get_text()) display_url(path)
def on_help_clicked(self, dummy): """ Button: Display the relevant portion of GRAMPS manual""" display_url(WIKI_PAGE)
def on_help_clicked(self, obj): """Display the relevant portion of GRAMPS manual""" display_url(WIKI_PAGE)
def __display(self): """Show the url in an external browser""" if self.url: display_url(self.url)
def show_help(self, obj): url = "http://wiki.isotammi.net/wiki/Name_Editor_Tool" display_url(url)
def on_help_clicked(self, dummy): ''' Button: Display the relevant portion of GRAMPS manual''' display_url(WIKI_PAGE)