progress

package
v0.0.0-...-bd1a654 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, url, dst string, b *Bar) error

Download is a helper function that downloads the resource at the given URL into the path at the given dst. The download progress is shown in the bar.

Types

type Bar

type Bar struct {
	*gtk.Box
	Label       *gtk.Label
	ProgressBar *gtk.ProgressBar
	// contains filtered or unexported fields
}

Bar describes a progress bar.

func NewBar

func NewBar() *Bar

NewBar creates a new progress bar.

func (*Bar) Add

func (b *Bar) Add(n int64)

Add adds the given n value.

func (*Bar) Error

func (b *Bar) Error(err error)

Error changes bar to indicate an error.

func (*Bar) Set

func (b *Bar) Set(n int64)

Set sets the given n value.

func (*Bar) SetLabelFunc

func (b *Bar) SetLabelFunc(labelFn func(n, max int64) string)

SetLabelFunc sets the function to render the progress bar label. It only does something if Max is set to a value. This method must only be called before Add is called, otherwise the state is invalid.

func (*Bar) SetMax

func (b *Bar) SetMax(max int64)

SetMax sets the max value of the bar.

func (*Bar) SetShowText

func (b *Bar) SetShowText(showText bool)

SetShowText sets whether or not the bar shows the label.

func (*Bar) SetText

func (b *Bar) SetText(text string)

SetText sets the bar's text.

type Reader

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

Reader wraps a progress bar and implements io.Reader.

func WrapReader

func WrapReader(r io.Reader, b *Bar) *Reader

WrapReader wraps the given io.Reader to also update the given Bar.

func (*Reader) Bar

func (r *Reader) Bar() *Bar

Bar returns the reader's bar.

func (*Reader) Read

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

Read implements io.Reader.

Jump to

Keyboard shortcuts

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