Esempio n. 1
0
    def full(self):
        if self.description.startswith(self.abstract):
            desc = self.description[len(self.abstract):]
        else:
            desc = self.description

        if desc == '':
            return "%s\n\n%s" % (self.full_summary, esc(self.abstract))
        elif self.abstract == '':
            return "%s\n\n%s" % (self.full_summary, esc(desc))
        else:
            return "%s\n\n%s\n\n%s" \
                % (self.full_summary, esc(self.abstract), esc(desc))
Esempio n. 2
0
    def full(self):
        if self.description.startswith(self.abstract):
            desc = self.description[len(self.abstract):]
        else:
            desc = self.description

        if desc == '':
            return "%s\n\n%s" % (self.full_summary, esc(self.abstract))
        elif self.abstract == '':
            return "%s\n\n%s" % (self.full_summary, esc(desc))
        else:
            return "%s\n\n%s\n\n%s" \
                % (self.full_summary, esc(self.abstract), esc(desc))
Esempio n. 3
0
def strip_tags(text):
    # Strip HTML tags
    # TODO: regular expressions shouldn't be used for this
    text = re.sub(r'<(/)?[a-z]+[0-9]*>', '', text)
    text = re.sub(r'&amp;', '&', text)
    text = esc(text)
    return text
Esempio n. 4
0
def strip_tags(text):
    # Strip HTML tags
    # TODO: regular expressions shouldn't be used for this
    text = re.sub(r'<(/)?[a-z]+[0-9]*>', '', text)
    text = re.sub(r'&amp;', '&', text)
    text = esc(text)
    return text
Esempio n. 5
0
    def populate_store(self, event_omit):
        for day_name, event_iter in groupby(self.events, lambda e: e.day_name):
            header = '<span size="x-large" foreground="#aaa">%s</span>' % (
                esc(day_name))
            self.store.append((header, None, False, False, None))

            for event in event_iter:
                self.store.append((event.summary(omit=event_omit), event, event
                                   in self.schedule.favourites, True,
                                   get_color(event.track)))
Esempio n. 6
0
    def populate_store(self, event_omit):
        for day_name, event_iter in groupby(self.events, lambda e: e.day_name):
            header = '<span size="x-large" foreground="#aaa">%s</span>' % (
                esc(day_name))
            self.store.append((header, None, False, False, None))

            for event in event_iter:
                self.store.append(
                    (event.summary(omit=event_omit), event,
                     event in self.schedule.favourites, True,
                     get_color(event.track)))
Esempio n. 7
0
    def __init__(self, schedule, title, categories, event_fmt,
                 show_swatches=False):
        MaybeStackableWindow.__init__(self, title)
        self.schedule = schedule
        self.categories = categories
        self.event_fmt = event_fmt
        # This should really be   (str, list) but that doesn't seem to work:
        #   TypeError: could not get typecode from object
        # I guess list is not a subclass of object.
        self.store = gtk.ListStore(str, object, str, gtk.gdk.Color)

        for category, events in sorted(categories.items()):
            summary = """<b>%(category)s</b>
<small>%(event_summary)s</small>""" % {
                'category': esc(category),
                'event_summary': summarize_events(events),
            }
            colour = get_color(category) if show_swatches else None
            self.store.append((category, events, summary, colour))

        treeview = gtk.TreeView(self.store)
        treeview.set_headers_visible(False)
        treeview.connect("row-activated", self.category_activated)

        tvcolumn = gtk.TreeViewColumn('Stuff')
        treeview.append_column(tvcolumn)

        # FIXME: it'd be nice to show the colours on the room list, too, to
        # show which track(s) are in that room. But then we'd need to support
        # showing more than one.
        if show_swatches:
            add_swatch_cells(tvcolumn,
                colour_col=CategoryList.COL_CATEGORY_COLOUR)

        cell = gtk.CellRendererText()
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
        tvcolumn.pack_start(cell, True)

        tvcolumn.add_attribute(cell, 'markup',
            CategoryList.COL_CATEGORY_SUMMARY)

        pannable = MaybePannableArea()
        pannable.add(treeview)
        self.add_with_margins(pannable)

        self.show_all()
Esempio n. 8
0
    def __init__(self, node, date, room):
        self.id = node.getAttribute('id')
        self.room = room

        children = [ c for c in node.childNodes
                       if c.nodeType == Node.ELEMENT_NODE
                   ]
        for child in children:
            n = child.nodeName

            if n == 'title':
                self.title = get_text(child)
            elif n == 'start':
                self.start = date + get_time_delta(child)
            elif n == 'duration':
                self.duration = get_time_delta(child)
            elif n == 'track':
                self.track = get_text(child)

            # In practice, abstract and description are the only places that
            # stray newlines show up. FIXME: I think they're actually in
            # Markdown format, maybe we could use Python-Markdown to do better
            # than this?
            elif n == 'abstract':
                self.abstract = get_text(child, strip_newlines=True)
            elif n == 'description':
                self.description = get_text(child, strip_newlines=True)
            elif n == 'persons':
                # FIXME: maybe joining the people together should be up to the
                # widgets?
                self.person = get_text_from_children(child, 'person',
                    joiner=', ')
            else:
                pass

        self.end = self.start + self.duration

        # These are not methods because strftime showed up surprisingly high on
        # the profile. They're localized; I'm not sure if this is a good thing.
        self.day_name = self.start.strftime("%A")
        self.start_str = self.start.strftime('%H:%M')
        self.end_str = self.end.strftime('%H:%M')

        # And these are pre-computed because they were about a quarter of
        # showing the full list.
        bg = get_color(self.track)
        if bg.red + bg.green + bg.blue > (65535 * 3 / 2):
            fg = '#000000'
        else:
            fg = '#ffffff'

        self.bg = bg

        summary_data = {
            'title': esc(self.title),
            'speaker': esc(self.person),
            'day': self.day_name,
            'start': self.start_str,
            'end': self.end_str,
            'room': esc(self.room),
            'track': esc(self.track),
            'track_background': bg.to_string(),
            'track_foreground': fg
        }

        self.full_summary = Event.FULL_SUMMARY_FORMAT % summary_data
        self.summary_sans_day = Event.OMIT_DAY_FORMAT % summary_data
        self.summary_sans_room = Event.OMIT_ROOM_FORMAT % summary_data
        self.summary_sans_track = Event.OMIT_TRACK_FORMAT % summary_data
Esempio n. 9
0
    def __init__(self, node, date, room):
        self.id = node.getAttribute('id')
        self.room = room

        children = [
            c for c in node.childNodes if c.nodeType == Node.ELEMENT_NODE
        ]
        for child in children:
            n = child.nodeName

            if n == 'title':
                self.title = get_text(child)
            elif n == 'start':
                self.start = date + get_time_delta(child)
            elif n == 'duration':
                self.duration = get_time_delta(child)
            elif n == 'track':
                self.track = get_text(child)

            # In practice, abstract and description are the only places that
            # stray newlines show up. FIXME: I think they're actually in
            # Markdown format, maybe we could use Python-Markdown to do better
            # than this?
            elif n == 'abstract':
                self.abstract = get_text(child, strip_newlines=True)
            elif n == 'description':
                self.description = get_text(child, strip_newlines=True)
            elif n == 'persons':
                # FIXME: maybe joining the people together should be up to the
                # widgets?
                self.person = get_text_from_children(child,
                                                     'person',
                                                     joiner=', ')
            else:
                pass

        self.end = self.start + self.duration

        # These are not methods because strftime showed up surprisingly high on
        # the profile. They're localized; I'm not sure if this is a good thing.
        self.day_name = self.start.strftime("%A")
        self.start_str = self.start.strftime('%H:%M')
        self.end_str = self.end.strftime('%H:%M')

        # And these are pre-computed because they were about a quarter of
        # showing the full list.
        bg = get_color(self.track)
        if bg.red + bg.green + bg.blue > (65535 * 3 / 2):
            fg = '#000000'
        else:
            fg = '#ffffff'

        self.bg = bg

        summary_data = {
            'title': esc(self.title),
            'speaker': esc(self.person),
            'day': self.day_name,
            'start': self.start_str,
            'end': self.end_str,
            'room': esc(self.room),
            'track': esc(self.track),
            'track_background': bg.to_string(),
            'track_foreground': fg
        }

        self.full_summary = Event.FULL_SUMMARY_FORMAT % summary_data
        self.summary_sans_day = Event.OMIT_DAY_FORMAT % summary_data
        self.summary_sans_room = Event.OMIT_ROOM_FORMAT % summary_data
        self.summary_sans_track = Event.OMIT_TRACK_FORMAT % summary_data