Clear images on toot destroy

This commit is contained in:
bleakgrey 2018-05-23 00:37:51 +03:00
parent 19d4bbe98f
commit da526cc1e8
3 changed files with 16 additions and 16 deletions

View File

@ -120,9 +120,9 @@ public class Tootle.NetManager : GLib.Object {
}
public Json.Object parse (Soup.Message msg) throws GLib.Error {
// stdout.printf ("Status Code: %u\n", msg.status_code);
// stdout.printf ("Message length: %lld\n", msg.response_body.length);
// stdout.printf ("Object: \n%s\n", (string) msg.response_body.data);
// debug ("Status Code: %u", msg.status_code);
// debug ("Message length: %lld", msg.response_body.length);
// debug ("Object: %s", (string) msg.response_body.data);
var parser = new Json.Parser ();
parser.load_from_data ((string) msg.response_body.flatten ().data, -1);
@ -130,9 +130,9 @@ public class Tootle.NetManager : GLib.Object {
}
public Json.Array parse_array (Soup.Message msg) throws GLib.Error {
// stdout.printf ("Status Code: %u\n", msg.status_code);
// stdout.printf ("Message length: %lld\n", msg.response_body.length);
// stdout.printf ("Array: \n%s\n", (string) msg.response_body.data);
// debug ("Status Code: %u", msg.status_code);
// debug ("Message length: %lld", msg.response_body.length);
// debug ("Array: %s", (string) msg.response_body.data);
var parser = new Json.Parser ();
parser.load_from_data ((string) msg.response_body.flatten ().data, -1);
@ -153,16 +153,9 @@ public class Tootle.NetManager : GLib.Object {
public void load_image (string url, Gtk.Image image) {
var msg = new Soup.Message("GET", url);
msg.finished.connect(() => {
// var data = msg.response_body.flatten ().data;
// var stream = new MemoryInputStream.from_data (data);
// var pixbuf = new Gdk.Pixbuf.from_stream (stream);
// image.set_from_pixbuf (pixbuf);
var loader = new PixbufLoader ();
var data = msg.response_body.data;
loader.write (data);
loader.close ();
var pixbuf = loader.get_pixbuf ();
var stream = new MemoryInputStream.from_data (data);
var pixbuf = new Gdk.Pixbuf.from_stream (stream);
image.set_from_pixbuf (pixbuf);
});
Tootle.network.queue (msg);

View File

@ -27,6 +27,11 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
add (grid);
grid.show ();
label.hide ();
destroy.connect (() => {
if (image != null)
image.clear ();
});
}
public AttachmentWidget (Attachment att) {

View File

@ -10,6 +10,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
public Gtk.Separator? separator;
public Gtk.Grid grid;
public Granite.Widgets.Avatar avatar;
private const int avatar_size = 32;
public Gtk.Label title_user;
public Gtk.Label title_date;
public Gtk.Label title_acct;
@ -176,6 +177,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
attachments.destroy ();
destroy.connect (() => {
avatar.show_default (avatar_size);
if(separator != null)
separator.destroy ();
});
@ -220,7 +222,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
reblog.tooltip_text = _("This post can't be boosted");
}
Tootle.network.load_avatar (formal.account.avatar, avatar);
Tootle.network.load_avatar (formal.account.avatar, avatar, avatar_size);
}
public bool is_spoiler () {