Resize all attachments (#49)

This commit is contained in:
bleakgrey 2018-07-04 01:36:03 +03:00
parent a629ac5b18
commit 128cd4ee3b
1 changed files with 7 additions and 6 deletions

View File

@ -5,6 +5,7 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
public Attachment? attachment; public Attachment? attachment;
private bool editable = false; private bool editable = false;
private const int PREVIEW_SIZE = 350;
private const int SMALL_SIZE = 64; private const int SMALL_SIZE = 64;
public Gtk.Label label; public Gtk.Label label;
@ -38,8 +39,8 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
rebind (); rebind ();
} }
public int get_small_size () { public int get_size (int size) {
return SMALL_SIZE * get_style_context ().get_scale (); return size * get_style_context ().get_scale ();
} }
public void rebind () { public void rebind () {
@ -54,10 +55,10 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
image.margin = 3; image.margin = 3;
image.set_tooltip_text (attachment.description); image.set_tooltip_text (attachment.description);
image.show (); image.show ();
if (editable)
Tootle.network.load_scaled_image (attachment.preview_url, image, get_small_size ()); var size = editable ? SMALL_SIZE : PREVIEW_SIZE;
else network.load_scaled_image (attachment.preview_url, image, get_size (size));
Tootle.network.load_image (attachment.preview_url, image);
grid.attach (image, 0, 0); grid.attach (image, 0, 0);
label.hide (); label.hide ();
break; break;