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)
def _produce_item(self, message): tile = widgets.PhotoTile() self._prepare_item(tile) tile.style_class = "PisakEmailDraftsTile" tile.hilite_tool = widgets.Aperture() tile.connect("clicked", self.item_handler, message) return tile
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
def _generate_tiles(self): tiles = [] for index in range(self.from_idx, self.to_idx): if index < self.data_length: item = self.symbols[index] tile = widgets.PhotoTile() tile.label.set_style_class("PisakSymbolerPhotoTileLabel") if item.text: label = item.text else: label = os.path.splitext(os.path.split(item.path)[-1])[0] tile.label_text = label tile.hilite_tool = widgets.Aperture() tile.connect("activate", lambda source, tile: self.target.append_symbol(tile), tile) tile.set_background_color(colors.LIGHT_GREY) tile.ratio_width = self.tile_ratio_width tile.ratio_height = self.tile_ratio_height tile.ratio_spacing = self.tile_ratio_spacing tile.preview_ratio_width = self.tile_preview_ratio_width tile.preview_ratio_height = self.tile_preview_ratio_height tile.scale_mode = Mx.ImageScaleMode.FIT tile.preview_path = item.path else: tile = Clutter.Actor() tiles.append(tile) return tiles
def _produce_item(self, data_item): tile = widgets.PhotoTile() self._prepare_item(tile) tile.hilite_tool = widgets.Aperture() tile.connect("clicked", self.item_handler, data_item.id, self.data_set_idx) tile.scale_mode = Mx.ImageScaleMode.FIT tile.preview_path = data_item.path return tile
def _produce_item(self, folder): tile = widgets.PhotoTile() self._prepare_item(tile) tile.style_class = "PisakAudioFolderTile" tile.hilite_tool = widgets.Aperture() tile.connect("clicked", self.item_handler, folder['id']) tile.scale_mode = Mx.ImageScaleMode.FIT tile.preview_path = folder['cover_path'] tile.label_text = folder['name'] return tile
def _produce_item(self, value): tile = widgets.PhotoTile() self._prepare_item(tile) tile.style_class = "PisakSymbolerPhotoTileLabel" tile.hilite_tool = widgets.Aperture() tile.set_background_color(colors.LIGHT_GREY) tile.scale_mode = Mx.ImageScaleMode.FIT tile.preview_path = dirs.get_symbol_path(value) tile.label_text = value return tile
def _produce_item(self, movie): tile = widgets.PhotoTile() self._prepare_item(tile) tile.style_class = "PisakMoviePhotoTile" tile.connect("clicked", self.item_handler, movie.id) tile.hilite_tool = widgets.Aperture() tile.scale_mode = Mx.ImageScaleMode.FIT self._set_preview(tile, movie.extra.get("cover")) tile.label_text = os.path.splitext(os.path.split(movie.path)[-1])[0] return tile
def _produce_item(self, album): tile = widgets.PhotoTile() self._prepare_item(tile) tile.label_text = album.name tile.style_class = "PisakViewerPhotoTile" tile.connect("clicked", self.item_handler, album.id) tile.hilite_tool = widgets.Aperture() preview_path = album.get_preview_path() if preview_path: tile.preview_path = preview_path return tile
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
def _generate_tiles(self): tiles = [] for index in range(self.from_idx, self.to_idx): if index < self.data_length: tile = widgets.PhotoTile() tile.hilite_tool = widgets.Aperture() tile.connect("activate", self.tiles_handler, self.photos[index].id, self.album) tile.scale_mode = Mx.ImageScaleMode.FIT tile.ratio_width = self.tile_ratio_width tile.ratio_height = self.tile_ratio_height tile.preview_path = self.photos[index].path else: tile = Clutter.Actor() tiles.append(tile) return tiles
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
def _generate_tiles(self): tiles = [] for index in range(self.from_idx, self.to_idx): if index < self.data_length: album = self.albums[index] tile = widgets.PhotoTile() tile.label_text = album.name tile.label.set_style_class("PisakViewerPhotoTile") tile.connect("activate", self.tiles_handler, album.id) tile.hilite_tool = widgets.Aperture() tile.ratio_width = self.tile_ratio_width tile.ratio_height = self.tile_ratio_height tile.ratio_spacing = self.tile_ratio_spacing tile.preview_ratio_height = self.tile_preview_ratio_height tile.preview_ratio_widtht = self.tile_preview_ratio_width tile.preview_path = album.get_preview_path() tiles.append(tile) return tiles