diff --git a/internal/gts/httputil/image.go b/internal/gts/httputil/image.go index 7c61323..026fd56 100644 --- a/internal/gts/httputil/image.go +++ b/internal/gts/httputil/image.go @@ -18,33 +18,21 @@ import ( type ImageContainer interface { SetFromPixbuf(*gdk.Pixbuf) SetFromAnimation(*gdk.PixbufAnimation) + GetSizeRequest() (w, h int) Connect(string, interface{}, ...interface{}) (glib.SignalHandle, error) } -type ImageContainerSizer interface { - ImageContainer - GetSizeRequest() (w, h int) - SetSizeRequest(w, h int) -} - -type dummySizer struct { - ImageContainer -} - -func (dummySizer) GetSizeRequest() (int, int) { return -1, -1 } -func (dummySizer) SetSizeRequest(int, int) {} - // AsyncImage loads an image. This method uses the cache. func AsyncImage(img ImageContainer, url string, procs ...imgutil.Processor) { - asyncImage(dummySizer{img}, url, procs) -} - -// AsyncImageSized resizes using GdkPixbuf. This method uses the cache. -func AsyncImageSized(img ImageContainerSizer, url string, procs ...imgutil.Processor) { asyncImage(img, url, procs) } -func asyncImage(img ImageContainerSizer, url string, procs []imgutil.Processor) { +// AsyncImageSized resizes using GdkPixbuf. This method uses the cache. +func AsyncImageSized(img ImageContainer, url string, procs ...imgutil.Processor) { + asyncImage(img, url, procs) +} + +func asyncImage(img ImageContainer, url string, procs []imgutil.Processor) { if url == "" { return } @@ -68,7 +56,6 @@ func asyncImage(img ImageContainerSizer, url string, procs []imgutil.Processor) w, h = imgutil.MaxSize(imgW, imgH, w, h) if w != imgW || h != imgH { l.SetSize(w, h) - execIfCtx(ctx, func() { img.SetSizeRequest(w, h) }) } }) } diff --git a/internal/ui/primitives/roundimage/button.go b/internal/ui/primitives/roundimage/button.go index bfa4c05..e14195d 100644 --- a/internal/ui/primitives/roundimage/button.go +++ b/internal/ui/primitives/roundimage/button.go @@ -23,25 +23,25 @@ func NewButton() (*Button, error) { image, _ := NewImage(0) image.Show() - b, _ := NewEmptyButton() + b := NewEmptyButton() b.SetImage(image) return b, nil } -func NewEmptyButton() (*Button, error) { +func NewEmptyButton() *Button { b, _ := gtk.ButtonNew() b.SetRelief(gtk.RELIEF_NONE) roundButtonCSS(b) - return &Button{Button: b}, nil + return &Button{Button: b} } // NewCustomButton creates a new rounded button with the given Imager. If the // given Imager implements the Connector interface (aka *StaticImage), then the // function will implicitly connect its handlers to the button. func NewCustomButton(img Imager) (*Button, error) { - b, _ := NewEmptyButton() + b := NewEmptyButton() b.SetImage(img) if connector, ok := img.(Connector); ok { diff --git a/internal/ui/primitives/roundimage/roundimage.go b/internal/ui/primitives/roundimage/roundimage.go index f545eb0..3d9523a 100644 --- a/internal/ui/primitives/roundimage/roundimage.go +++ b/internal/ui/primitives/roundimage/roundimage.go @@ -26,9 +26,10 @@ type Connector interface { type Imager interface { gtk.IWidget RadiusSetter + SetSizeRequest(w, h int) // Embed setters. - httputil.ImageContainerSizer + httputil.ImageContainer GetPixbuf() *gdk.Pixbuf GetAnimation() *gdk.PixbufAnimation diff --git a/internal/ui/rich/labeluri/labeluri.go b/internal/ui/rich/labeluri/labeluri.go index 5553a25..ffb74bd 100644 --- a/internal/ui/rich/labeluri/labeluri.go +++ b/internal/ui/rich/labeluri/labeluri.go @@ -193,7 +193,7 @@ func largeText(text string) string { func popoverImg(url string, round bool) gtk.IWidget { var btn *gtk.Button var img *gtk.Image - var idl httputil.ImageContainerSizer + var idl httputil.ImageContainer if round { b, _ := roundimage.NewButton()