portaldialogs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 NewClient

func NewClient(conn *dbus.Conn) *Client

NewClient addresses the host over conn.

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.

func (*Client) Dismiss

func (c *Client) Dismiss(ctx context.Context, handle string) error

Dismiss takes down the dialog showing for the request at handle.

func (*Client) UpdateChoices

func (c *Client) UpdateChoices(ctx context.Context, handle string, choices []string) (found bool, err error)

UpdateChoices replaces the app ids the chooser open for handle offers; false when none is open for it.

type Daemon

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

Daemon serves a Host as dev.stubbe.lys.PortalDialogs1.

func NewDaemon

func NewDaemon(host Host) *Daemon

NewDaemon wraps the host for export.

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

func (d *Daemon) ChooseApplication(c portalreq.Caller, r ChooserRequest) (string, *dbus.Error)

ChooseApplication is the app chooser.

func (*Daemon) ChooseDevices

func (d *Daemon) ChooseDevices(c portalreq.Caller, devices []Device) (bool, []string, *dbus.Error)

ChooseDevices is the USB device consent.

func (*Daemon) ConfirmInstall

func (d *Daemon) ConfirmInstall(c portalreq.Caller, r LauncherRequest) (bool, string, *dbus.Error)

ConfirmInstall is the dynamic-launcher install confirmation.

func (*Daemon) ConfirmWallpaper

func (d *Daemon) ConfirmWallpaper(c portalreq.Caller, uri string) (bool, *dbus.Error)

ConfirmWallpaper is the wallpaper preview confirmation.

func (*Daemon) Dismiss

func (d *Daemon) Dismiss(handle string) *dbus.Error

Dismiss takes down the dialog showing for the request at handle.

func (*Daemon) Export

func (d *Daemon) Export(conn *dbus.Conn) (func(), error)

Export serves the interface under its name; the returned release drops the name.

func (*Daemon) UpdateChoices

func (d *Daemon) UpdateChoices(handle string, choices []string) (bool, *dbus.Error)

UpdateChoices updates the app chooser open for handle.

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 New

func New(d Deps) *Dialogs

New builds the host; nothing maps until a request.

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

func (h *Dialogs) ChooseDevices(c portalreq.Caller, devices []Device) (bool, []string)

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

func (h *Dialogs) ConfirmInstall(c portalreq.Caller, r LauncherRequest) (bool, string)

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

func (h *Dialogs) ConfirmWallpaper(c portalreq.Caller, uri string) bool

ConfirmWallpaper previews a file:// image before it is set.

func (*Dialogs) Dismiss

func (h *Dialogs) Dismiss(handle string)

Dismiss answers no to the request at handle: the dialog showing for it is taken down, a waiting one never shows. Another request's dialog stays.

func (*Dialogs) UpdateChoices

func (h *Dialogs) UpdateChoices(handle string, choices []string) bool

UpdateChoices replaces the choices of the app chooser open for handle, refilling its list when it shows.

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).

type Window

type Window interface{ Close() }

Window is the overlay surface the dialog maps (app.LayerWindow).

Jump to

Keyboard shortcuts

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