async methods
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
00c15ba185
commit
0b9f41fff0
1 changed files with 6 additions and 10 deletions
|
@ -56,7 +56,7 @@ public class Extension.Player : Gtk.Box {
|
|||
return bebra;
|
||||
}
|
||||
|
||||
private void quanitize (Gdk.Pixbuf pixbuf) {
|
||||
private async void quanitize (Gdk.Pixbuf pixbuf) {
|
||||
var histogram = new Gee.HashMap<Gdk.RGBA?, int>
|
||||
(
|
||||
(a) => ((uint8) a.red * 255 + ((uint8) a.green * 255 << 8) + ((uint8) a.blue * 255 << 16)),
|
||||
|
@ -99,7 +99,7 @@ public class Extension.Player : Gtk.Box {
|
|||
set_colors (colors);
|
||||
}
|
||||
|
||||
private Icon ? process_pixbuff (Icon? icon) {
|
||||
private async Icon ? process_pixbuff (Icon? icon) {
|
||||
if (icon == null)
|
||||
return null;
|
||||
Gdk.Pixbuf pixbuff = null;
|
||||
|
@ -108,7 +108,7 @@ public class Extension.Player : Gtk.Box {
|
|||
else if (icon is FileIcon) {
|
||||
var fi = (LoadableIcon) icon;
|
||||
try {
|
||||
pixbuff = new Gdk.Pixbuf.from_stream (fi.load (1024, null, null));
|
||||
pixbuff = yield new Gdk.Pixbuf.from_stream_async (yield fi.load_async (1024, null, null));
|
||||
} catch (Error err) {
|
||||
warning ("Icon load failed %s", err.message);
|
||||
return null;
|
||||
|
@ -140,7 +140,8 @@ public class Extension.Player : Gtk.Box {
|
|||
cr.paint ();
|
||||
|
||||
pixbuff = Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
quanitize (pixbuff);
|
||||
image.gicon = pixbuff;
|
||||
quanitize.begin (pixbuff);
|
||||
return pixbuff;
|
||||
}
|
||||
|
||||
|
@ -148,12 +149,7 @@ public class Extension.Player : Gtk.Box {
|
|||
foreach (var child in box.get_children ()) {
|
||||
switch (child.get_name ()) {
|
||||
case "img_art" :
|
||||
child.bind_property
|
||||
("gicon", image, "gicon", BindingFlags.SYNC_CREATE,
|
||||
(_, src, ref dst) => {
|
||||
dst = process_pixbuff ((Gdk.Pixbuf) src.get_object ());
|
||||
return true;
|
||||
});
|
||||
child.notify["gicon"].connect (() => process_pixbuff.begin (((Gtk.Image) child).gicon));
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue