コード例 #1
0
    def write_child(self, handle, index, child_should_be_linked):
        """
        Write a child cell (used for children and siblings of active person)
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        parent = self.has_children(
                    self.dbstate.db.get_person_from_handle(handle))
        emph = False
        if child_should_be_linked and parent:
            emph = True
        elif child_should_be_linked and not parent:
            emph = False
        elif parent and not child_should_be_linked:
            emph = None

        if child_should_be_linked:
            link_func = self._person_link
        else:
            link_func = None

        name = self.get_name(handle, True)
        link_label = widgets.LinkLabel(name, link_func, handle, emph,
                                       theme=self.theme)
        link_label.set_padding(3, 0)
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_person_button, handle)
            button.set_tooltip_text(_('Edit %s') % name[0])
        else:
            button = None

        hbox = Gtk.Box()
        hbox.set_spacing(6)
        l = widgets.BasicLabel("%d." % index)
        l.set_width_chars(3)
        l.set_halign(Gtk.Align.END)
        hbox.pack_start(l, False, False, 0)
        person = self.dbstate.db.get_person_from_handle(handle)
        hbox.pack_start(link_label, False, False, 0)
        if self.show_details:
            box = self.info_box(handle)
            if box:
                hbox.pack_start(box, False, False, 0)
        if button is not None:
            hbox.pack_start(button, False, False, 0)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(person))
            hbox.pack_start(tag_list, False, False, 0)
        hbox.show()
        vbox.pack_start(hbox, True, True, 0)

        ev = self.make_dragbox(vbox, 'Person', handle)

        if not child_should_be_linked:
            frame = Gtk.Frame()
            frame.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
            frame.add(ev)
            return frame
        else:
            return ev
コード例 #2
0
    def write_event(self, event_ref, spouse, index):
        handle = event_ref.ref
        event = self.dbstate.db.get_event_from_handle(handle)
        etype = str(event.get_type())
        desc = event.get_description()
        who = get_participant_from_event(self.dbstate.db, handle)

        title = etype
        if desc:
            title = '%s (%s)' % (title, desc)
        if spouse:
            spouse_name = name_displayer.display(spouse)
            title = '%s - %s' % (title, spouse_name)

        role = event_ref.get_role()
        if role in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
            emph = True
        else:
            emph = False
            title = '%s of %s' % (title, who)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        link_func = self._event_link
        name = (title, None)
        handle = event_ref.ref
        link_label = widgets.LinkLabel(name, link_func, handle, emph,
                                       theme=self.theme)
        link_label.set_padding(3, 0)
        link_label.set_tooltip_text(_('Click to make this event active'))
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_event_button, handle)
            button.set_tooltip_text(_('Edit %s') % name[0])
        else:
            button = None

        hbox = widgets.LinkBox(link_label, button)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(event))
            hbox.pack_start(tag_list, False, False, 0)
        vbox.pack_start(hbox, False, False, 0)

        line2 = self.format_event(event)
        vbox.pack_start(widgets.BasicLabel(line2), False, False, 0)

        for handle in event.get_citation_list():
            self.write_citation(vbox, handle)

        eventbox = self.make_dragbox(vbox, 'Event', handle)
        eventbox.show_all()
        self.vbox2.pack_start(eventbox, False, False, 1)
コード例 #3
0
 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
コード例 #4
0
ファイル: eventpage.py プロジェクト: pmraps/addons-source
    def write_participant(self, person, attrs):

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        handle = person.handle
        name = self.get_name(handle, True)
        if self.has_children(person):
            emph = True
        else:
            emph = False
        link_func = self._person_link
        link_label = widgets.LinkLabel(name,
                                       link_func,
                                       handle,
                                       emph,
                                       theme=self.theme)
        link_label.set_padding(3, 0)
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_person_button, handle)
            button.set_tooltip_text(_('Edit %s') % name[0])
        else:
            button = None

        hbox = Gtk.Box()
        hbox.set_spacing(6)
        hbox.pack_start(link_label, False, False, 0)
        if self.show_details:
            box = self.info_box(handle)
            if box:
                hbox.pack_start(box, False, False, 0)
        if button is not None:
            hbox.pack_start(button, False, False, 0)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(person))
            hbox.pack_start(tag_list, False, False, 0)
        vbox.pack_start(hbox, False, False, 0)

        # Write attributes
        attr_grid = self.get_attribute_grid(attrs)
        attr_grid.set_margin_start(24)
        vbox.pack_start(attr_grid, False, False, 0)

        eventbox = self.make_dragbox(vbox, 'Person', handle)
        eventbox.show_all()

        self.vbox2.pack_start(eventbox, False, False, 1)
コード例 #5
0
    def write_person(self, title, handle):
        """
        Create and show a person cell.
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        if handle:
            name = self.get_name(handle, True)
            person = self.dbstate.db.get_person_from_handle(handle)
            parent = len(person.get_parent_family_handle_list()) > 0
            if parent:
                emph = True
            else:
                emph = False
            link_label = widgets.LinkLabel(name, self._person_link,
                                           handle, emph, theme=self.theme)
            if self._config.get('preferences.releditbtn'):
                button = widgets.IconButton(self.edit_person_button, handle)
                button.set_tooltip_text(_('Edit %s') % name[0])
            else:
                button = None
            hbox = Gtk.Box()
            hbox.set_spacing(6)
            hbox.pack_start(link_label, False, False, 0)
            if self.show_details:
                box = self.info_box(handle)
                if box:
                    hbox.pack_start(box, False, False, 0)
            if button is not None:
                hbox.pack_start(button, False, False, 0)
            if self.show_tags:
                tag_list = TagList(self.get_tag_list(person))
                hbox.pack_start(tag_list, False, False, 0)
            vbox.pack_start(hbox, True, True, 0)
        else:
            link_label = Gtk.Label(label=_('Unknown'))
            link_label.set_halign(Gtk.Align.START)
            link_label.show()
            vbox.pack_start(link_label, True, True, 0)

        return vbox
コード例 #6
0
    def write_node(self, grid, event_ref, spouse, index, start_date):
        handle = event_ref.ref
        event = self.dbstate.db.get_event_from_handle(handle)
        etype = str(event.get_type())
        desc = event.get_description()
        who = get_participant_from_event(self.dbstate.db, handle)

        title = etype
        if desc:
            title = '%s (%s)' % (title, desc)
        if spouse:
            spouse_name = name_displayer.display(spouse)
            title = '%s - %s' % (title, spouse_name)

        role = event_ref.get_role()
        if role in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
            emph = True
        else:
            emph = False
            title = '%s of %s' % (title, who)

        vbox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        link_func = self._event_link
        name = (title, None)
        handle = event_ref.ref
        link_label = widgets.LinkLabel(name, link_func, handle, emph,
                                       theme=self.theme)
        link_label.set_padding(3, 0)
        link_label.set_tooltip_text(_('Click to make this event active'))
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_event_button, handle)
            button.set_tooltip_text(_('Edit %s') % name[0])
        else:
            button = None

        hbox = widgets.LinkBox(link_label, button)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(event))
            hbox.pack_start(tag_list, False, False, 0)
        vbox1.pack_start(hbox, False, False, 0)

        pname = place_displayer.display_event(self.dbstate.db, event)
        vbox1.pack_start(widgets.BasicLabel(pname), False, False, 0)
        vbox1.set_vexpand(False)
        vbox1.set_valign(Gtk.Align.CENTER)
        vbox1.show_all()

        eventbox = self.make_dragbox(vbox1, 'Event', handle)
        eventbox.set_hexpand(True)
        eventbox.set_vexpand(False)
        eventbox.set_valign(Gtk.Align.CENTER)
        eventbox.set_margin_top(1)
        eventbox.set_margin_bottom(1)
        eventbox.show_all()

        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        dobj = event.get_date_object()
        date = widgets.BasicLabel(displayer.display(dobj))
        vbox2.pack_start(date, False, False, 0)
        if start_date is not None:
            age_precision = config.get('preferences.age-display-precision')
            diff = (dobj - start_date).format(precision=age_precision)
            age = widgets.BasicLabel(diff)
            vbox2.pack_start(age, False, False, 0)
        vbox2.set_valign(Gtk.Align.CENTER)
        grid.add(vbox2)

        tl = Timeline()
        grid.attach_next_to(tl, vbox2, Gtk.PositionType.RIGHT, 1, 1)

        grid.attach_next_to(eventbox, tl, Gtk.PositionType.RIGHT, 1, 1)