From 5b5db4c637b68b41cd2aaceeccda60fe90a1b895 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 15 Nov 2020 02:26:18 +0800 Subject: [PATCH] =?utf8?q?=E8=8E=B7=E5=8F=96=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Reply/gtk.go | 56 ++++++++++++++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 56f4cb5..626e18e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ demo/*.mkv demo/qtbox demo/main demo/face/* +demo/demo.run diff --git a/Reply/gtk.go b/Reply/gtk.go index e5bb400..895caba 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -159,7 +159,12 @@ func Gtk_danmu() { pixbuf,e = gdk.PixbufCopy(v) } else { pixbuf,e = gdk.PixbufNewFromFileAtSize(img_src, 40, 40); - if e == nil {imgbuf[img_src],e = gdk.PixbufCopy(pixbuf)} + if e == nil { + if len(imgbuf) > max_img { + for k,_ := range imgbuf {delete(imgbuf,k);break} + } + imgbuf[img_src],e = gdk.PixbufCopy(pixbuf) + } } if e == nil {tmp_list.img.SetFromPixbuf(pixbuf)} } @@ -206,33 +211,6 @@ func Gtk_danmu() { } } - glib.TimeoutAdd(uint(3000), func()(o bool){ - o = true - - if gtkGetList.Len() == 0 {return} - el := gtkGetList.Front() - if el == nil {return} - if uid,ok := gtkGetList.Remove(el).(string);ok{ - go func(){ - src := F.Get_face_src(uid) - if src == "" {return} - req := p.Req() - if e := req.Reqf(p.Rval{ - Url:src, - SaveToPath:Gtk_img_path + `/` + uid, - Timeout:3, - }); e != nil{log.Println(e);} - }() - } - - { - if len(imgbuf) > max_img { - for k,_ := range imgbuf {delete(imgbuf,k);break} - } - } - return - }) - win.ShowAll() } @@ -255,6 +233,28 @@ func Gtk_danmu() { }) } }() + + glib.TimeoutAdd(uint(3000), func()(o bool){ + o = true + + if gtkGetList.Len() == 0 {return} + el := gtkGetList.Front() + if el == nil {return} + if uid,ok := gtkGetList.Remove(el).(string);ok{ + go func(){ + src := F.Get_face_src(uid) + if src == "" {return} + req := p.Req() + if e := req.Reqf(p.Rval{ + Url:src, + SaveToPath:Gtk_img_path + `/` + uid, + Timeout:3, + }); e != nil{log.Println(e);} + }() + } + + return + }) }) application.Connect("shutdown", func() { -- 2.39.2