private string GetTrackArtworkId(DatabaseTrackInfo track) { return(PodcastService.ArtworkIdFor(PodcastTrackInfo.From(track).Feed)); }
public override void Render(CellContext context, double cellWidth, double cellHeight) { if (BoundObject == null) { return; } if (!(BoundObject is Feed)) { throw new InvalidCastException("ColumnCellPodcast can only bind to Feed objects"); } Feed feed = (Feed)BoundObject; bool is_default = false; ImageSurface image = artwork_manager == null ? null : artwork_manager.LookupScaleSurface(PodcastService.ArtworkIdFor(feed), image_size, true); if (image == null) { image = default_cover_image; is_default = true; } // int image_render_size = is_default ? image.Height : (int)cellHeight - 8; int image_render_size = image_size; int x = image_spacing; int y = ((int)cellHeight - image_render_size) / 2; ArtworkRenderer.RenderThumbnail(context.Context, image, false, x, y, image_render_size, image_render_size, !is_default, context.Theme.Context.Radius); int fl_width = 0, fl_height = 0, sl_width = 0, sl_height = 0; context.Widget.StyleContext.Save(); context.Widget.StyleContext.AddClass("cell"); context.StyleContext.State |= context.State; Cairo.Color text_color = CairoExtensions.GdkRGBAToCairoColor(context.Widget.StyleContext.GetColor(context.StyleContext.State)); context.Widget.StyleContext.Restore(); text_color.A = 0.75; Pango.Layout layout = context.Layout; layout.Width = (int)((cellWidth - cellHeight - x - 10) * Pango.Scale.PangoScale); layout.Ellipsize = Pango.EllipsizeMode.End; layout.FontDescription.Weight = Pango.Weight.Bold; // Compute the layout sizes for both lines for centering on the cell int old_size = layout.FontDescription.Size; layout.SetText(feed.Title ?? String.Empty); layout.GetPixelSize(out fl_width, out fl_height); if (feed.DbId > 0) { layout.FontDescription.Weight = Pango.Weight.Normal; layout.FontDescription.Size = (int)(old_size * Pango.Scale.Small); layout.FontDescription.Style = Pango.Style.Italic; if (feed.LastDownloadTime == DateTime.MinValue) { layout.SetText(Catalog.GetString("Never updated")); } else if (feed.LastDownloadTime.Date == DateTime.Now.Date) { layout.SetText(String.Format(Catalog.GetString("Updated at {0}"), feed.LastDownloadTime.ToShortTimeString())); } else { layout.SetText(String.Format(Catalog.GetString("Updated {0}"), Hyena.Query.RelativeTimeSpanQueryValue.RelativeToNow(feed.LastDownloadTime).ToUserQuery())); } layout.GetPixelSize(out sl_width, out sl_height); } // Calculate the layout positioning x = ((int)cellHeight - x) + 10; y = (int)((cellHeight - (fl_height + sl_height)) / 2); // Render the second line first since we have that state already if (feed.DbId > 0) { context.Context.MoveTo(x, y + fl_height); context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); } // Render the first line, resetting the state layout.SetText(feed.Title ?? String.Empty); layout.FontDescription.Weight = Pango.Weight.Bold; layout.FontDescription.Size = old_size; layout.FontDescription.Style = Pango.Style.Normal; layout.SetText(feed.Title ?? String.Empty); context.Context.MoveTo(x, y); text_color.A = 1; context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); }