aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/avatar_generator.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-29 15:15:28 +0100
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commit0102abeec1d2055b19dccbb7edc7f06e527642b1 (patch)
tree4018e82224c19142c4a7a6eced67d9c2550b2dd8 /main/src/ui/avatar_generator.vala
parentb9df78e4494879752e9e68dcc5d54e03fffe9467 (diff)
downloaddino-0102abeec1d2055b19dccbb7edc7f06e527642b1.tar.gz
dino-0102abeec1d2055b19dccbb7edc7f06e527642b1.zip
Fix warnings
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);
}