attachment

package
v0.0.0-...-6513b37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ThumbSize = 72
	IconSize  = 56
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	*gtk.Revealer
	Scroll *gtk.ScrolledWindow
	Box    *gtk.Box
	// contains filtered or unexported fields
}

func New

func New() *Container

func (*Container) AddFile

func (c *Container) AddFile(path string) error

AddFile is used for the file picker.

func (*Container) AddFiles

func (c *Container) AddFiles(paths []string)

AddFiles is used for the file chooser's callback.

func (*Container) AddPixbuf

func (c *Container) AddPixbuf(pb *gdk.Pixbuf)

AddPixbuf is used for adding pixbufs from the clipboard.

func (*Container) Enabled

func (c *Container) Enabled() bool

Enabled returns whether or not the container allows attachments.

func (*Container) Files

func (c *Container) Files() []File

Files returns the list of attachments

func (*Container) Reset

func (c *Container) Reset()

Reset does NOT close files.

func (*Container) SetEnabled

func (c *Container) SetEnabled(enabled bool)

func (*Container) SetMarginStart

func (c *Container) SetMarginStart(margin int)

SetMarginStart sets the inner margin of the attachments carousel.

type File

type File struct {
	Prog *Progress
	Name string
	Size int64 // -1 = stream
}

File represents a middle format that can be used to create a MessageAttachment.

func NewFile

func NewFile(name string, size int64, open Open) File

NewFile creates a new attachment file with a progress state.

func (*File) AsAttachment

func (f *File) AsAttachment() cchat.MessageAttachment

AsAttachment turns File into a MessageAttachment. This method will always make a new MessageAttachment and will never return an old one.

The reason being MessageAttachment should never be reused, as it hides the fact that the io.Reader is reusable.

type MessageUploader

type MessageUploader struct {
	*gtk.Grid
}

func NewMessageUploader

func NewMessageUploader(files []File) *MessageUploader

NewMessageUploader creates a new MessageUploader. It returns nil if there are no files.

type Open

type Open = func() (io.ReadCloser, error)

type Progress

type Progress struct {
	// contains filtered or unexported fields
}

Progress wraps around a ReadCloser and implements a progress state for a reader.

func NewProgress

func NewProgress(r io.Reader, size int64) *Progress

NewProgress creates a new upload progress state.

func (*Progress) Read

func (p *Progress) Read(b []byte) (int, error)

type ProgressBar

type ProgressBar struct {
	PBar *gtk.ProgressBar
	Name *gtk.Label
}

func NewProgressBar

func NewProgressBar(file File) *ProgressBar

type ReusableReader

type ReusableReader struct {
	// contains filtered or unexported fields
}

ReusableReader provides an API which allows a reader to be used multiple times. It is NOT thread-safe to use.

func NewReusableReader

func NewReusableReader(open Open) *ReusableReader

NewReusableReader creates a new reader that is reusable after a read failure or a close. The given open() callback MUST be reproducible.

func (*ReusableReader) Read

func (r *ReusableReader) Read(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL