diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-18 23:54:37 +0100 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2018-01-18 23:56:48 +0100 |
commit | be21b8feaa212b441f456439ba8b2564b0985c04 (patch) | |
tree | d91ea0bad9c630f6bc6141414d7fec786b40897e /src/contacts-avatar.vala | |
parent | 86abe20743713abaea0abd244e0d31ef3a3dcad0 (diff) | |
download | gnome-contacts-be21b8feaa212b441f456439ba8b2564b0985c04.tar.gz |
Avatar: don't use a button.wip/nielsdg/avatar-no-button
Leave all the button logic out of it and just be a simple DrawingArea.
NOTE: we temporarily lose our border because of this, but with the new
avatars, this should no longer be a problem.
Diffstat (limited to 'src/contacts-avatar.vala')
-rw-r--r-- | src/contacts-avatar.vala | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/contacts-avatar.vala b/src/contacts-avatar.vala index 23ca495..5b0d1d6 100644 --- a/src/contacts-avatar.vala +++ b/src/contacts-avatar.vala @@ -23,42 +23,18 @@ using Gee; * The Avatar of a Contact is responsible for showing an {@link Individual}'s * avatar, or a fallback if it's not available. */ -public class Contacts.Avatar : Frame { +public class Contacts.Avatar : DrawingArea { private int size; private Gdk.Pixbuf? pixbuf; private Pango.Layout? layout; - public signal void clicked (); - - public Avatar (int size, bool with_button = false) { + public Avatar (int size) { this.size = size; + set_size_request (size, size); get_style_context ().add_class ("contacts-avatar"); - var image = new Image (); - image.set_size_request (size, size); - - if (with_button) { - var button = new Button (); - button.get_accessible ().set_name (_("Change avatar")); - button.get_style_context ().add_class ("contacts-square"); - button.set_relief (ReliefStyle.NONE); - button.set_focus_on_click (false); - button.add (image); - - button.clicked.connect ( () => { - this.clicked (); - }); - - this.add (button); - this.shadow_type = ShadowType.NONE; - } else { - this.add (image); - } - - image.show (); - image.draw.connect (draw_image); - + show (); } public void set_pixbuf (Gdk.Pixbuf a_pixbuf) { @@ -84,7 +60,7 @@ public class Contacts.Avatar : Frame { set_pixbuf (a_pixbuf); } - public bool draw_image (Cairo.Context cr) { + public override bool draw (Cairo.Context cr) { cr.save (); if (pixbuf != null) { |