コード例 #1
0
 def _produce_item(self, post_item):
     post = post_item.content
     tile = Tile()
     self._prepare_item(tile)
     frame = widgets.Frame()
     frame.set_style_class("PisakBlogPostTile")
     tile.add_child(frame)
     tile.connect("clicked", self.item_handler, post_item)
     tile.hilite_tool = widgets.Aperture()
     if isinstance(post, dict):
         post_title = post["title"]
         post_date = post["date"]
     else:
         post_title = post.title
         post_date = post.date
     tile.title.set_text(
         html_parsers.extract_text(post_title) or _NO_POST_TITLE)
     if isinstance(post_date, str):
         parsed = post_date.split("+")[0].replace("T", " ")
         try:
             parsed = parsed.split('-')[0]
             post_date = datetime.strptime(parsed, "%Y-%m-%d %H:%M:%S")
         except ValueError as err:
             _LOG.warning(err)
             post_date = None
     if post_date:
         tile.date.set_text(utils.date_to_when(post_date))
     return tile
コード例 #2
0
ファイル: widgets.py プロジェクト: Sasza/pisak
    def __init__(self, mailbox):
        super().__init__()
        self.hilite_tool = widgets.Aperture()

        self.label = layout.Box()
        self.box.add_child(self.label)
        self.label.orientation = Clutter.Orientation.VERTICAL
        self.label.ratio_spacing = 0.03

        frame = widgets.Frame()
        frame.set_style_class('PisakEmailMessageTile')
        self.add_child(frame)

        margin = unit.h(0.0095)

        # create separate label for each header, specific to the given
        # `mailbox`; each label is set as an attribute of `self` with a
        # name of the corresponding header's lower-cased name;
        # list of headers is at the moment taken from the `imap_client` module.
        for header in imap_client.MAILBOX_HEADERS[mailbox]:
            label = Mx.Label()
            setattr(self, header.lower(), label)
            label.set_margin_right(margin)
            label.set_margin_left(margin)
            label.get_clutter_text().set_line_alignment(Pango.Alignment.CENTER)
            label.set_style_class('PisakEmailMessageTile' + header)
            self.label.add_child(label)
コード例 #3
0
 def _produce_item(self, blog):
     tile = widgets.PhotoTile()
     tile.style_class = "PisakBlogBlogTile"
     self._prepare_item(tile)
     frame = widgets.Frame()
     tile.add_child(frame)
     tile.hilite_tool = widgets.Aperture()
     url = urlparse(blog)
     blog_name = url.path[1:] if "blogi.pisak.org" in url.netloc \
         else url.netloc
     tile.label_text = blog_name
     tile.connect("clicked", self.item_handler, blog, blog_name)
     return tile
コード例 #4
0
ファイル: widgets.py プロジェクト: Sasza/pisak
 def _produce_item(self, contact):
     tile = widgets.PhotoTile()
     self._prepare_item(tile)
     frame = widgets.Frame()
     frame.set_x_expand(False)
     frame.set_y_expand(False)
     frame.set_size(*tile.get_size())
     tile.add_frame(frame)
     tile.style_class = 'PisakEmailAddressTile'
     tile.hilite_tool = widgets.Aperture()
     tile.connect("clicked", self.item_handler, contact)
     tile.label_text = contact.content.name if contact.content.name \
         else contact.content.address
     if contact.content.photo:
         tile.preview_path = contact.content.photo
     tile.spec["toggled"] = contact.flags.get("picked")
     return tile