(maybe) fix attachment dialog
This commit is contained in:
parent
8071885618
commit
744f59cf38
|
@ -1,6 +1,7 @@
|
||||||
package gts
|
package gts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -216,8 +217,7 @@ func SpawnUploader(dirpath string, callback func(absolutePaths []string)) {
|
||||||
"Upload", "Cancel",
|
"Upload", "Cancel",
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Throttler.Connect(dialog)
|
// BindPreviewer(dialog)
|
||||||
BindPreviewer(dialog)
|
|
||||||
|
|
||||||
if dirpath == "" {
|
if dirpath == "" {
|
||||||
p, err := os.Getwd()
|
p, err := os.Getwd()
|
||||||
|
@ -231,7 +231,10 @@ func SpawnUploader(dirpath string, callback func(absolutePaths []string)) {
|
||||||
dialog.SetCurrentFolder(dirpath)
|
dialog.SetCurrentFolder(dirpath)
|
||||||
dialog.SetSelectMultiple(true)
|
dialog.SetSelectMultiple(true)
|
||||||
|
|
||||||
if res := dialog.Run(); res != int(gtk.RESPONSE_ACCEPT) {
|
res := dialog.Run()
|
||||||
|
dialog.Destroy()
|
||||||
|
|
||||||
|
if res != int(gtk.RESPONSE_ACCEPT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,18 +247,54 @@ func BindPreviewer(fc *gtk.FileChooserNativeDialog) {
|
||||||
img, _ := gtk.ImageNew()
|
img, _ := gtk.ImageNew()
|
||||||
|
|
||||||
fc.SetPreviewWidget(img)
|
fc.SetPreviewWidget(img)
|
||||||
fc.Connect("update-preview",
|
fc.Connect("update-preview", func(interface{}) { loadImage(fc, img) })
|
||||||
func(fc *gtk.FileChooserNativeDialog) {
|
}
|
||||||
file := fc.GetPreviewFilename()
|
|
||||||
|
func loadImage(fc *gtk.FileChooserNativeDialog, img *gtk.Image) {
|
||||||
b, err := gdk.PixbufNewFromFileAtScale(file, 256, 256, true)
|
file := fc.GetPreviewFilename()
|
||||||
if err != nil {
|
|
||||||
fc.SetPreviewWidgetActive(false)
|
go func() {
|
||||||
return
|
var animation *gdk.PixbufAnimation
|
||||||
}
|
var pixbuf *gdk.Pixbuf
|
||||||
|
|
||||||
img.SetFromPixbuf(b)
|
defer ExecAsync(func() {
|
||||||
fc.SetPreviewWidgetActive(true)
|
if fc.GetPreviewFilename() == file {
|
||||||
},
|
if animation == nil && pixbuf == nil {
|
||||||
)
|
fc.SetPreviewWidgetActive(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if animation != nil {
|
||||||
|
img.SetFromAnimation(animation)
|
||||||
|
} else {
|
||||||
|
img.SetFromPixbuf(pixbuf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fc.SetPreviewWidgetActive(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
l, err := gdk.PixbufLoaderNew()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := os.Open(file)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
if _, err := io.Copy(l, f); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := l.Close(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if pixbuf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,9 +254,6 @@ func (v *View) SetFolded(folded bool) {
|
||||||
// Change to a mini breadcrumb if we're collapsed.
|
// Change to a mini breadcrumb if we're collapsed.
|
||||||
v.Header.SetMiniBreadcrumb(folded)
|
v.Header.SetMiniBreadcrumb(folded)
|
||||||
|
|
||||||
// Show the right back button if we're collapsed.
|
|
||||||
v.Header.SetShowBackButton(folded)
|
|
||||||
|
|
||||||
// Hide the username in the input bar if we're collapsed.
|
// Hide the username in the input bar if we're collapsed.
|
||||||
v.InputView.Username.SetRevealChild(!folded)
|
v.InputView.Username.SetRevealChild(!folded)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/diamondburned/cchat-gtk/internal/log"
|
"github.com/diamondburned/cchat-gtk/internal/log"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/config/preferences"
|
"github.com/diamondburned/cchat-gtk/internal/ui/config/preferences"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/messages"
|
"github.com/diamondburned/cchat-gtk/internal/ui/messages"
|
||||||
|
"github.com/diamondburned/cchat-gtk/internal/ui/primitives"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/service"
|
"github.com/diamondburned/cchat-gtk/internal/ui/service"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/service/auth"
|
"github.com/diamondburned/cchat-gtk/internal/ui/service/auth"
|
||||||
"github.com/diamondburned/cchat-gtk/internal/ui/service/session"
|
"github.com/diamondburned/cchat-gtk/internal/ui/service/session"
|
||||||
|
@ -115,6 +116,11 @@ func NewApplication() *App {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// We'd still want to control the visibility of the back button when we
|
||||||
|
// fold, however.
|
||||||
|
primitives.LeafletOnFold(&app.Leaflet,
|
||||||
|
app.MessageView.Header.SetShowBackButton)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue