Ejemplo n.º 1
0
 def get_attribute_grid(self, attrs):
     grid = Gtk.Grid()
     row = 0
     for attr in attrs:
         if str(attr.get_type()) != _('Order'):
             label = widgets.BasicLabel('%s: ' % str(attr.get_type()))
             grid.attach(label, 0, row, 1, 1)
             label = widgets.BasicLabel(attr.get_value())
             grid.attach(label, 1, row, 1, 1)
             row += 1
     grid.show_all()
     return grid
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def write_full_citation(self, chandle):

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

        citation = self.dbstate.db.get_citation_from_handle(chandle)
        shandle = citation.get_reference_handle()
        source = self.dbstate.db.get_source_from_handle(shandle)
        heading = source.get_title() + ' ' + citation.get_page()

        vbox.pack_start(widgets.BasicLabel(heading), False, False, 0)

        hbox = self.load_images(citation)
        vbox.pack_start(hbox, False, False, 0)

        eventbox = self.make_dragbox(vbox, 'Citation', chandle)
        eventbox.show_all()

        self.vbox2.pack_start(eventbox, False, False, 1)
Ejemplo n.º 5
0
    def write_citation(self, vbox, chandle):
        citation = self.dbstate.db.get_citation_from_handle(chandle)
        shandle = citation.get_reference_handle()
        source = self.dbstate.db.get_source_from_handle(shandle)
        heading = source.get_title()
        page = citation.get_page()
        if page:
            heading += ' \u2022 ' + page

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        url_label = self.get_url(citation)
        if url_label:
            box.pack_start(url_label, False, False, 0)
        hbox = self.load_images(citation)
        box.pack_start(hbox, False, False, 0)

        if len(hbox.get_children()) > 0 or url_label:
            exp = Gtk.Expander(label=heading)
            exp.add(box)
            vbox.pack_start(exp, False, False, 0)
        else:
            label = widgets.BasicLabel(heading)
            vbox.pack_start(label, False, False, 0)
Ejemplo n.º 6
0
    def write_title(self, event):

        self.handle = event.handle

        grid = Gtk.Grid()
        grid.set_column_spacing(12)
        grid.set_row_spacing(0)

        # event title and edit button
        etype = str(event.get_type())
        desc = event.get_description()
        if desc:
            title = '%s (%s)' % (etype, desc)
        else:
            title = etype
        fmt = '<span size="larger" weight="bold">%s</span>'
        text = fmt % escape(title)
        label = widgets.MarkupLabel(text, halign=Gtk.Align.END)
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_event_button, event.handle)
            button.set_tooltip_text(_('Edit %s') % title)
        else:
            button = None

        hbox = widgets.LinkBox(label, button)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(event))
            hbox.pack_start(tag_list, False, False, 0)
        eventbox = self.make_dragbox(hbox, 'Event', event.get_handle())
        grid.attach(eventbox, 0, 0, 2, 1)

        subgrid = Gtk.Grid()
        subgrid.set_column_spacing(12)
        subgrid.set_row_spacing(0)
        eventbox = self.make_dragbox(subgrid, 'Event', event.get_handle())
        grid.attach(eventbox, 1, 1, 1, 1)

        # Gramps ID
        subgrid.attach(widgets.BasicLabel("%s:" % _('ID')), 1, 0, 1, 1)
        label = widgets.BasicLabel(event.gramps_id)
        label.set_hexpand(True)
        subgrid.attach(label, 2, 0, 1, 1)

        # Date
        subgrid.attach(widgets.BasicLabel("%s:" % 'Date'), 1, 1, 1, 1)
        subgrid.attach(widgets.BasicLabel(get_date(event)), 2, 1, 1, 1)

        # Place
        place = place_displayer.display_event(self.dbstate.db, event)
        subgrid.attach(widgets.BasicLabel("%s:" % 'Place'), 1, 2, 1, 1)
        subgrid.attach(widgets.BasicLabel(place), 2, 2, 1, 1)

        grid.show_all()
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox.pack_start(grid, False, True, 0)

        # Attributes
        attrs = event.get_attribute_list()
        if len(attrs):
            ex = Gtk.Expander(label='%s:' % _('Attributes'))
            attr_grid = self.get_attribute_grid(attrs)
            ex.set_margin_start(24)
            ex.add(attr_grid)
            ex.show()
            vbox.pack_start(ex, False, True, 0)

        vbox.show_all()
        return vbox
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
 def write_data(self, box, title):
     box.add(widgets.BasicLabel(title))
Ejemplo n.º 9
0
    def write_title(self, person):

        self.handle = person.handle

        grid = Gtk.Grid()
        grid.set_column_spacing(12)
        grid.set_row_spacing(0)

        # name and edit button
        name = name_displayer.display(person)
        fmt = '<span size="larger" weight="bold">%s</span>'
        text = fmt % escape(name)
        label = widgets.DualMarkupLabel(text, _GenderCode[person.gender],
                                        halign=Gtk.Align.END)
        if self._config.get('preferences.releditbtn'):
            button = widgets.IconButton(self.edit_person_button,
                                        person.handle)
            button.set_tooltip_text(_('Edit %s') % name)
        else:
            button = None


        hbox = widgets.LinkBox(label, button)
        if self.show_tags:
            tag_list = TagList(self.get_tag_list(person))
            hbox.pack_start(tag_list, False, False, 0)
        eventbox = self.make_dragbox(hbox, 'Person', person.get_handle())
        grid.attach(eventbox, 0, 0, 2, 1)

        subgrid = Gtk.Grid()
        subgrid.set_column_spacing(12)
        subgrid.set_row_spacing(0)
        eventbox = self.make_dragbox(subgrid, 'Person', person.get_handle())
        grid.attach(eventbox, 1, 1, 1, 1)

        # GRAMPS ID
        subgrid.attach(widgets.BasicLabel("%s:" % _('ID')), 1, 0, 1, 1)
        label = widgets.BasicLabel(person.gramps_id)
        label.set_hexpand(True)
        subgrid.attach(label, 2, 0, 1, 1)

        # Birth event.
        birth = get_birth_or_fallback(self.dbstate.db, person)
        if birth:
            birth_title = birth.get_type()
        else:
            birth_title = _("Birth")

        subgrid.attach(widgets.BasicLabel("%s:" % birth_title), 1, 1, 1, 1)
        subgrid.attach(widgets.BasicLabel(self.format_event(birth)), 2, 1, 1, 1)

        death = get_death_or_fallback(self.dbstate.db, person)
        if death:
            death_title = death.get_type()
        else:
            death_title = _("Death")

        showed_death = False
        if birth:
            birth_date = birth.get_date_object()
            if (birth_date and birth_date.get_valid()):
                if death:
                    death_date = death.get_date_object()
                    if (death_date and death_date.get_valid()):
                        age = death_date - birth_date
                        subgrid.attach(widgets.BasicLabel("%s:" % death_title),
                                      1, 2, 1, 1)
                        subgrid.attach(widgets.BasicLabel("%s (%s)" %
                                                         (self.format_event(death), age),
                                                         Pango.EllipsizeMode.END),
                                      2, 2, 1, 1)
                        showed_death = True
                if not showed_death:
                    age = Today() - birth_date
                    if probably_alive(person, self.dbstate.db):
                        subgrid.attach(widgets.BasicLabel("%s:" % _("Alive")),
                                      1, 2, 1, 1)
                        subgrid.attach(widgets.BasicLabel("(%s)" % age, Pango.EllipsizeMode.END),
                                      2, 2, 1, 1)
                    else:
                        subgrid.attach(widgets.BasicLabel("%s:" % _("Death")),
                                      1, 2, 1, 1)
                        subgrid.attach(widgets.BasicLabel("%s (%s)" % (_("unknown"), age),
                                                         Pango.EllipsizeMode.END),
                                      2, 2, 1, 1)
                    showed_death = True

        if not showed_death:
            subgrid.attach(widgets.BasicLabel("%s:" % death_title),
                          1, 2, 1, 1)
            subgrid.attach(widgets.BasicLabel(self.format_event(death)),
                          2, 2, 1, 1)

        mbox = Gtk.Box()
        mbox.add(grid)

        # image
        image_list = person.get_media_list()
        if image_list:
            button = self.get_thumbnail(image_list[0], size=SIZE_NORMAL)
            if button:
                mbox.pack_end(button, False, True, 0)
        mbox.show_all()
        return mbox