gioexplorer

package
v0.0.0-...-7fd9240 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Explorer

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

Explorer facilitates opening OS-native dialogs to choose files and create files.

func NewExplorer

func NewExplorer(w *app.Window) (e *Explorer)

NewExplorer creates a new Explorer for the given *app.Window. The given app.Window must be unique and you should call NewExplorer once per new app.Window.

It's mandatory to use Explorer.ListenEvents on the same *app.Window.

func (*Explorer) ChooseFile

func (e *Explorer) ChooseFile(extensions ...string) (string, error)

ChooseFile shows the file selector, allowing the user to select a single file. Optionally, it's possible to define which file extensions is supported to be selected (such as `.jpg`, `.png`).

Example: ChooseFile(".jpg", ".png") will only accept the selection of files with .jpg or .png extensions.

In most known browsers, when user clicks cancel then this function never returns.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile or CreateFile, can happen at the same time, for each app.Window/Explorer.

func (*Explorer) ChooseFileIO

func (e *Explorer) ChooseFileIO(extensions ...string) (io.ReadCloser, error)

ChooseFileIO shows the file selector, allowing the user to select a single file. Optionally, it's possible to define which file extensions is supported to be selected (such as `.jpg`, `.png`).

Example: ChooseFileIO(".jpg", ".png") will only accept the selection of files with .jpg or .png extensions.

In some platforms the resulting `io.ReadCloser` is a `os.File`, but it's not a guarantee.

In most known browsers, when user clicks cancel then this function never returns.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile or CreateFile, can happen at the same time, for each app.Window/Explorer.

func (*Explorer) ChooseFiles

func (e *Explorer) ChooseFiles(extensions ...string) ([]string, error)

ChooseFiles shows the files selector, allowing the user to select multiple files. Optionally, it's possible to define which file extensions is supported to be selected (such as `.jpg`, `.png`).

Example: ChooseFiles(".jpg", ".png") will only accept the selection of files with .jpg or .png extensions.

In most known browsers, when user clicks cancel then this function never returns.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile{,s} or CreateFile, can happen at the same time, for each app.Window/Explorer.

func (*Explorer) ChooseFilesIO

func (e *Explorer) ChooseFilesIO(extensions ...string) ([]io.ReadCloser, error)

ChooseFilesIO shows the files selector, allowing the user to select multiple files. Optionally, it's possible to define which file extensions is supported to be selected (such as `.jpg`, `.png`).

Example: ChooseFilesIO(".jpg", ".png") will only accept the selection of files with .jpg or .png extensions.

In some platforms the resulting `io.ReadCloser` is a `os.File`, but it's not a guarantee.

In most known browsers, when user clicks cancel then this function never returns.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile{,s} or CreateFile, can happen at the same time, for each app.Window/Explorer.

func (*Explorer) CreateFile

func (e *Explorer) CreateFile(name string) (string, error)

CreateFile opens the file selector, and writes the given content into some file, which the use can choose the location.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile or CreateFile, can happen at the same time, for each Explorer.

func (*Explorer) CreateFileIO

func (e *Explorer) CreateFileIO(name string) (io.WriteCloser, error)

CreateFileIO opens the file selector, and writes the given content into some file, which the use can choose the location.

It's important to close the `io.WriteCloser`. In some platforms the file will be saved only when the writer is closer.

In some platforms the resulting `io.WriteCloser` is a `os.File`, but it's not a guarantee.

It's a blocking call, you should call it on a separated goroutine. For most OSes, only one ChooseFile or CreateFile, can happen at the same time, for each app.Window/Explorer.

func (*Explorer) ListenEvents

func (e *Explorer) ListenEvents(evt event.Event)

ListenEvents must get all the events from Gio, in order to get the GioView. You must include that function where you listen for Gio events.

Similar as:

select {
case e := <-window.Events():

	explorer.ListenEvents(e)
	switch e := e.(type) {
		(( ... your code ...  ))
	}
}

Jump to

Keyboard shortcuts

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