aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/avatar_generator.vala
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/avatar_generator.vala')
-rw-r--r--main/src/ui/avatar_generator.vala22
1 files changed, 12 insertions, 10 deletions
diff --git a/main/src/ui/avatar_generator.vala b/main/src/ui/avatar_generator.vala
index 7e44f7e2..dce8e3d6 100644
--- a/main/src/ui/avatar_generator.vala
+++ b/main/src/ui/avatar_generator.vala
@@ -152,16 +152,18 @@ public class AvatarGenerator {
Context rectancle_context = new Context(new ImageSurface(Format.ARGB32, width, height));
draw_colored_rectangle(rectancle_context, hex_color, width, height);
- Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE);
- Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null);
- Context context = new Context(icon_surface);
- context.set_operator(Operator.IN);
- context.set_source_rgba(1, 1, 1, 1);
- context.rectangle(0, 0, width, height);
- context.fill();
-
- rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2);
- rectancle_context.paint();
+ try {
+ Pixbuf icon_pixbuf = IconTheme.get_default().load_icon(icon, ICON_SIZE, IconLookupFlags.FORCE_SIZE);
+ Surface icon_surface = cairo_surface_create_from_pixbuf(icon_pixbuf, 1, null);
+ Context context = new Context(icon_surface);
+ context.set_operator(Operator.IN);
+ context.set_source_rgba(1, 1, 1, 1);
+ context.rectangle(0, 0, width, height);
+ context.fill();
+
+ rectancle_context.set_source_surface(icon_surface, width / 2 - ICON_SIZE / 2, height / 2 - ICON_SIZE / 2);
+ rectancle_context.paint();
+ } catch (Error e) { warning(@"Icon $icon does not exist"); }
return pixbuf_get_from_surface(rectancle_context.get_target(), 0, 0, width, height);
}