Documentation
¶
Overview ¶
Package portaldialogs is the shell's dev.stubbe.lys.PortalDialogs1 host (lys-shell services/portal_dialogs and shell/portal_dialogs): the native dialogs behind the portal backend's Access, Account, AppChooser, DynamicLauncher, Usb and Wallpaper preview, in place of xdg-desktop-portal-gtk.
Index ¶
- Constants
- func CandidateApps(choices []string, contentType string) []desktopentry.App
- type AccessRequest
- type AccountInfo
- type ChooserRequest
- type Client
- func (c *Client) Access(ctx context.Context, caller portalreq.Caller, r AccessRequest) (granted bool, picked []portalreq.Selection, err error)
- func (c *Client) Account(ctx context.Context, caller portalreq.Caller, reason string, info AccountInfo) (shared bool, edited AccountInfo, err error)
- func (c *Client) ChooseApplication(ctx context.Context, caller portalreq.Caller, r ChooserRequest) (id string, err error)
- func (c *Client) ChooseDevices(ctx context.Context, caller portalreq.Caller, devices []Device) (allowed bool, picked []string, err error)
- func (c *Client) ConfirmInstall(ctx context.Context, caller portalreq.Caller, r LauncherRequest) (ok bool, name string, err error)
- func (c *Client) ConfirmWallpaper(ctx context.Context, caller portalreq.Caller, uri string) (ok bool, err error)
- func (c *Client) Dismiss(ctx context.Context, handle string) error
- func (c *Client) UpdateChoices(ctx context.Context, handle string, choices []string) (found bool, err error)
- type Daemon
- func (d *Daemon) Access(c portalreq.Caller, title, subtitle, body, grantLabel, denyLabel, icon string, ...) (bool, []portalreq.Selection, *dbus.Error)
- func (d *Daemon) Account(c portalreq.Caller, reason string, info AccountInfo) (bool, AccountInfo, *dbus.Error)
- func (d *Daemon) ChooseApplication(c portalreq.Caller, r ChooserRequest) (string, *dbus.Error)
- func (d *Daemon) ChooseDevices(c portalreq.Caller, devices []Device) (bool, []string, *dbus.Error)
- func (d *Daemon) ConfirmInstall(c portalreq.Caller, r LauncherRequest) (bool, string, *dbus.Error)
- func (d *Daemon) ConfirmWallpaper(c portalreq.Caller, uri string) (bool, *dbus.Error)
- func (d *Daemon) Dismiss(handle string) *dbus.Error
- func (d *Daemon) Export(conn *dbus.Conn) (func(), error)
- func (d *Daemon) UpdateChoices(handle string, choices []string) (bool, *dbus.Error)
- type Deps
- type Device
- type Dialogs
- func (h *Dialogs) Access(c portalreq.Caller, r AccessRequest) (bool, []portalreq.Selection)
- func (h *Dialogs) Account(c portalreq.Caller, reason string, info AccountInfo) (bool, AccountInfo)
- func (h *Dialogs) ChooseApplication(c portalreq.Caller, r ChooserRequest) string
- func (h *Dialogs) ChooseDevices(c portalreq.Caller, devices []Device) (bool, []string)
- func (h *Dialogs) ConfirmInstall(c portalreq.Caller, r LauncherRequest) (bool, string)
- func (h *Dialogs) ConfirmWallpaper(c portalreq.Caller, uri string) bool
- func (h *Dialogs) Dismiss(handle string)
- func (h *Dialogs) UpdateChoices(handle string, choices []string) bool
- type Host
- type LauncherRequest
- type Window
Constants ¶
const ( ServiceName = "dev.stubbe.lys.PortalDialogs1" ServicePath = dbus.ObjectPath("/dev/stubbe/lys/PortalDialogs") )
D-Bus identity (wayle-ipc portal_dialogs.rs).
Variables ¶
This section is empty.
Functions ¶
func CandidateApps ¶
func CandidateApps(choices []string, contentType string) []desktopentry.App
CandidateApps is the chooser's list (candidate_apps): the given app ids' entries, else the apps recommended for the type, else every app.
Types ¶
type AccessRequest ¶
type AccessRequest struct {
Title, Subtitle, Body string
GrantLabel, DenyLabel string
// Icon is a themed icon name for the permission, "" for none.
Icon string
// Choices are extra questions shown with the prompt.
Choices []portalreq.Choice
}
AccessRequest is one grant/deny prompt.
type AccountInfo ¶
type AccountInfo struct{ Name, Image string }
AccountInfo is what the Account dialog shares, (ss): the name and an avatar image path ("" for none).
type ChooserRequest ¶
type ChooserRequest struct {
// Choices are the app ids offered; none offers the apps for
// ContentType.
Choices []string
// LastChoice is the app id preselected, "" for none.
LastChoice string
// ContentType is the type opened, "" when unknown.
ContentType string
// Target names what is opened (a file's basename or a URI), ""
// for nothing to name.
Target string
}
ChooserRequest is one app chooser, (asss). App ids are desktop ids without ".desktop", as the portal speaks them.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the shell's dialogs; a dialog waits on the user, so the calls are bounded only by ctx.
func (*Client) Access ¶
func (c *Client) Access(ctx context.Context, caller portalreq.Caller, r AccessRequest) (granted bool, picked []portalreq.Selection, err error)
Access shows the grant/deny prompt.
func (*Client) Account ¶
func (c *Client) Account(ctx context.Context, caller portalreq.Caller, reason string, info AccountInfo) (shared bool, edited AccountInfo, err error)
Account asks to share info, which the user may edit first.
func (*Client) ChooseApplication ¶
func (c *Client) ChooseApplication(ctx context.Context, caller portalreq.Caller, r ChooserRequest) (id string, err error)
ChooseApplication picks a handler's app id; "" is a cancel.
func (*Client) ChooseDevices ¶
func (c *Client) ChooseDevices(ctx context.Context, caller portalreq.Caller, devices []Device) (allowed bool, picked []string, err error)
ChooseDevices asks which USB devices an app may open, replying the ids picked.
func (*Client) ConfirmInstall ¶
func (c *Client) ConfirmInstall(ctx context.Context, caller portalreq.Caller, r LauncherRequest) (ok bool, name string, err error)
ConfirmInstall asks to install a dynamic launcher, replying the name the user chose.
func (*Client) ConfirmWallpaper ¶
func (c *Client) ConfirmWallpaper(ctx context.Context, caller portalreq.Caller, uri string) (ok bool, err error)
ConfirmWallpaper previews uri and asks to set it.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon serves a Host as dev.stubbe.lys.PortalDialogs1.
func (*Daemon) Access ¶
func (d *Daemon) Access(c portalreq.Caller, title, subtitle, body, grantLabel, denyLabel, icon string, choices []portalreq.Choice) (bool, []portalreq.Selection, *dbus.Error)
Access is the grant/deny prompt.
func (*Daemon) Account ¶
func (d *Daemon) Account(c portalreq.Caller, reason string, info AccountInfo) (bool, AccountInfo, *dbus.Error)
Account is the account-info consent.
func (*Daemon) ChooseApplication ¶
ChooseApplication is the app chooser.
func (*Daemon) ChooseDevices ¶
ChooseDevices is the USB device consent.
func (*Daemon) ConfirmInstall ¶
ConfirmInstall is the dynamic-launcher install confirmation.
func (*Daemon) ConfirmWallpaper ¶
ConfirmWallpaper is the wallpaper preview confirmation.
type Deps ¶
type Deps struct {
// Config is the live config (the dialog animation).
Config func() *config.Config
// Open maps the overlay; Invoke runs on the UI loop.
Open func(cfg app.LayerConfig) (Window, error)
Invoke func(func())
// Font shapes the text; Sheet styles the surface, the labels'
// and entries' ink included.
Font render.Font
Sheet *widget.Stylesheet
// Candidates are the apps offered for a type (desktopentry's
// RecommendedFor, else every app); SetDefault records the
// "always use" choice.
Candidates func(choices []string, contentType string) []desktopentry.App
SetDefault func(id, contentType string) error
// PickImage lets the user choose an image file (the shell's file
// chooser) and calls chosen with its path on the loop; never on a
// cancel. It returns at once.
PickImage func(chosen func(path string))
// Describe names the app a request comes from: its display name
// and icon (desktopentry.Describe).
Describe func(appID string) (name, icon string)
}
Deps are the dialogs' collaborators.
type Device ¶
type Device struct {
// ID is the frontend's device id; Name is how the user knows it.
ID, Name string
// Writable is whether the app asks to write to it.
Writable bool
}
Device is one USB device an app asks to open, (ssb).
type Dialogs ¶
type Dialogs struct {
// contains filtered or unexported fields
}
Dialogs is the dev.stubbe.lys.PortalDialogs1 host: one overlay showing one request, naming the app that asks; requests arriving meanwhile wait their turn, and dismissing a request answers it no (or "" for an app chooser), showing or waiting. Its Host methods may be called from any goroutine; the rest runs on the loop.
func (*Dialogs) Access ¶
Access is the grant/deny prompt: the permission's icon above the title, the subtitle and body below it.
func (*Dialogs) Account ¶
func (h *Dialogs) Account(c portalreq.Caller, reason string, info AccountInfo) (bool, AccountInfo)
Account asks to share the user's name and avatar, previewing it.
func (*Dialogs) ChooseApplication ¶
func (h *Dialogs) ChooseApplication(c portalreq.Caller, r ChooserRequest) string
ChooseApplication is the app chooser: icon + name rows with a live search filter, and "always use" when the type is known. Its choices follow UpdateChoices while it is open.
func (*Dialogs) ChooseDevices ¶
ChooseDevices asks which USB devices the app may open: a check button per device, all checked, naming it and the access asked for.
func (*Dialogs) ConfirmInstall ¶
ConfirmInstall confirms a dynamic launcher: its icon, the URL a web app opens, and its name, in an entry when it is editable. An emptied name installs under the default one.
func (*Dialogs) ConfirmWallpaper ¶
ConfirmWallpaper previews a file:// image before it is set.
type Host ¶
type Host interface {
// Access replies whether the user granted and, when granted, what
// they picked for each choice.
Access(portalreq.Caller, AccessRequest) (bool, []portalreq.Selection)
// Account offers info for sharing and replies whether the user
// shares it, and what they left of it after editing.
Account(c portalreq.Caller, reason string, info AccountInfo) (bool, AccountInfo)
// ConfirmWallpaper previews a file:// image and replies whether to
// set it.
ConfirmWallpaper(c portalreq.Caller, uri string) bool
// ChooseApplication replies the chosen app id, "" on cancel.
ChooseApplication(portalreq.Caller, ChooserRequest) string
// UpdateChoices replaces the app ids offered by the app chooser
// for the request at handle, showing or waiting; false when no
// chooser is open for it.
UpdateChoices(handle string, choices []string) bool
// ChooseDevices replies whether the user allowed the app USB
// devices and the ids of the ones they picked.
ChooseDevices(portalreq.Caller, []Device) (bool, []string)
// ConfirmInstall replies whether to install a dynamic launcher,
// and under what name.
ConfirmInstall(portalreq.Caller, LauncherRequest) (bool, string)
// Dismiss takes down the dialog showing for the request at handle,
// when one is; the app closed the request.
Dismiss(handle string)
}
Host shows the dialogs; each call blocks until the user answers or the request is dismissed, which answers no ("" for a chooser).
type LauncherRequest ¶
type LauncherRequest struct {
// Name is the launcher's default name.
Name string
// Icon is the launcher's image (PNG, JPEG or SVG), empty for none.
Icon []byte
// Target is the URL a web app opens, "" for an application.
Target string
// EditableName lets the user change the name.
EditableName bool
}
LauncherRequest is one dynamic launcher to confirm, (saysb).