aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_summary
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_summary')
-rw-r--r--main/src/ui/conversation_summary/conversation_item_skeleton.vala4
-rw-r--r--main/src/ui/conversation_summary/image_display.vala17
2 files changed, 18 insertions, 3 deletions
diff --git a/main/src/ui/conversation_summary/conversation_item_skeleton.vala b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
index 127f0179..33d135fc 100644
--- a/main/src/ui/conversation_summary/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
@@ -9,7 +9,7 @@ namespace Dino.Ui.ConversationSummary {
public class ConversationItemSkeleton : Box {
- private Image image = new Image() { margin_top=2, valign=Align.START, visible=true };
+ private AvatarImage image = new AvatarImage() { margin_top=2, valign=Align.START, visible=true, allow_gray = false };
public StreamInteractor stream_interactor;
public Conversation conversation { get; set; }
@@ -24,7 +24,7 @@ public class ConversationItemSkeleton : Box {
this.stream_interactor = stream_interactor;
if (item.requires_avatar) {
- Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(32, 32, image.scale_factor)).set_greyscale(item.dim).draw_jid(stream_interactor, item.jid, conversation.account));
+ image.set_jid(stream_interactor, item.jid, conversation.account);
}
if (item.display_time != null) {
default_header = new DefaultSkeletonHeader(stream_interactor, conversation, item) { visible=true };
diff --git a/main/src/ui/conversation_summary/image_display.vala b/main/src/ui/conversation_summary/image_display.vala
index 7b77759b..c1cd32a1 100644
--- a/main/src/ui/conversation_summary/image_display.vala
+++ b/main/src/ui/conversation_summary/image_display.vala
@@ -54,7 +54,7 @@ public class ImageDisplay : Plugins.MetaConversationItem {
if (pixbuf.width > max_scaled_width) {
pixbuf = pixbuf.scale_simple(max_scaled_width, (int) ((double) max_scaled_width / pixbuf.width * pixbuf.height), Gdk.InterpType.BILINEAR);
}
- pixbuf = AvatarGenerator.crop_corners(pixbuf, 3 * image.get_scale_factor());
+ pixbuf = crop_corners(pixbuf, 3 * image.get_scale_factor());
Util.image_set_from_scaled_pixbuf(image, pixbuf);
Util.force_css(image, "* { box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.1); margin: 2px; border-radius: 3px; }");
@@ -103,6 +103,21 @@ public class ImageDisplay : Plugins.MetaConversationItem {
return event_box;
}
+ private static Gdk.Pixbuf crop_corners(Gdk.Pixbuf pixbuf, double radius = 3) {
+ Cairo.Context ctx = new Cairo.Context(new Cairo.ImageSurface(Cairo.Format.ARGB32, pixbuf.width, pixbuf.height));
+ Gdk.cairo_set_source_pixbuf(ctx, pixbuf, 0, 0);
+ double degrees = Math.PI / 180.0;
+ ctx.new_sub_path();
+ ctx.arc(pixbuf.width - radius, radius, radius, -90 * degrees, 0 * degrees);
+ ctx.arc(pixbuf.width - radius, pixbuf.height - radius, radius, 0 * degrees, 90 * degrees);
+ ctx.arc(radius, pixbuf.height - radius, radius, 90 * degrees, 180 * degrees);
+ ctx.arc(radius, radius, radius, 180 * degrees, 270 * degrees);
+ ctx.close_path();
+ ctx.clip();
+ ctx.paint();
+ return Gdk.pixbuf_get_from_surface(ctx.get_target(), 0, 0, pixbuf.width, pixbuf.height);
+ }
+
private void update_info(Label url_label, string? info) {
string url = info ?? "";
if (url.has_prefix("https://")) url = url.substring(8);