Documentation
¶
Overview ¶
Package printdialog is the shell's dev.stubbe.lys.Print1 host (lys-shell services/print and shell/print): the print dialog and spooler behind the portal backend's Print.
Index ¶
- Constants
- func SuggestedOutput(env xdg.Env, home, format string) (string, error)
- type Client
- func (c *Client) Dismiss(ctx context.Context, handle string) error
- func (c *Client) Prepare(ctx context.Context, caller portaldialogs.Caller, r PrepareRequest) (granted bool, settings []Setting, setup PageSetup, token uint32, err error)
- func (c *Client) Print(ctx context.Context, caller portaldialogs.Caller, title string, ...) (sent bool, err error)
- type Daemon
- func (d *Daemon) Dismiss(handle string) *dbus.Error
- func (d *Daemon) Export(conn *dbus.Conn) (func(), error)
- func (d *Daemon) Prepare(c portaldialogs.Caller, r PrepareRequest) (bool, []Setting, PageSetup, uint32, *dbus.Error)
- func (d *Daemon) Print(c portaldialogs.Caller, title string, document dbus.UnixFD, token uint32) (bool, *dbus.Error)
- type Deps
- type Dialog
- type Host
- type PageSetup
- type PrepareRequest
- type Setting
- type Window
Constants ¶
const ( ServiceName = "dev.stubbe.lys.Print1" ServicePath = dbus.ObjectPath("/dev/stubbe/lys/Print") )
D-Bus identity (wayle-ipc print.rs).
Variables ¶
This section is empty.
Functions ¶
func SuggestedOutput ¶
SuggestedOutput is where Print to File proposes to write, GTK's default: output.<format> in env's documents directory, else the home directory. The error reports a user-dirs.dirs that cannot say where the documents directory is; the path is then the one in home.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the shell's print host; Prepare waits on the user.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon serves a Host as dev.stubbe.lys.Print1.
func (*Daemon) Export ¶
Export serves the interface under its name; the returned release drops the name.
type Deps ¶
type Deps struct {
// Config is the live config (the print animation).
Config func() *config.Config
// Open maps the overlay; Invoke runs on the UI loop; KeySym reads
// its keys through the seat's keymap.
Open func(cfg app.LayerConfig) (Window, error)
Invoke func(func())
KeySym keys.Translator
// Font shapes the text; Sheet styles the surface, the labels'
// and entries' ink included.
Font render.Font
Sheet *widget.Stylesheet
// Printers lists the CUPS queues and Spool sends a job to one.
Printers func(context.Context) ([]ipp.Printer, error)
Spool func(context.Context, ipp.Job) error
// PickOutput lets the user choose the file Print to File writes
// (the shell's file chooser), starting from suggested, and calls
// chosen with its path on the loop; never on a cancel. It returns
// at once.
PickOutput func(suggested string, chosen func(path string))
// Home is the home directory, for the suggested output file.
Home string
// User names the job's owner.
User string
}
Deps are the dialog's collaborators.
type Dialog ¶
type Dialog struct {
// contains filtered or unexported fields
}
Dialog is the dev.stubbe.lys.Print1 host: one dialog showing one request; requests arriving meanwhile wait their turn, and dismissing a request cancels it, showing or waiting. Prepare and Print may be called from any goroutine; the UI runs on the loop.
func (*Dialog) Dismiss ¶
Dismiss cancels the request at handle: the dialog showing for it is taken down, a waiting one never shows. Another request's dialog stays.
func (*Dialog) Prepare ¶
func (h *Dialog) Prepare(c portaldialogs.Caller, r PrepareRequest) (bool, []Setting, PageSetup, uint32)
Prepare shows the printer picker and settings form for the request; a confirmed one is stashed under the returned token, a random one only the same app can print with, until it expires.
type Host ¶
type Host interface {
// Prepare lets the user pick a printer and settings for the
// request and stashes them under the returned token, for that app
// alone; granted is false on a cancel or when the request is
// dismissed.
Prepare(portaldialogs.Caller, PrepareRequest) (granted bool, settings []Setting, setup PageSetup, token uint32)
// Print spools document (a PDF the host takes ownership of) to the
// printer the app prepared under token, or, without a token,
// through the dialog first; it reports whether it was sent.
Print(c portaldialogs.Caller, title string, document *os.File, token uint32) bool
// Dismiss takes down the dialog showing for the request at handle.
Dismiss(handle string)
}
Host shows the dialog and spools the jobs.
type PageSetup ¶
type PageSetup struct {
PPDName, Name, DisplayName string
Width, Height float64
MarginTop, MarginBottom, MarginLeft, MarginRight float64
Orientation string
}
PageSetup is a GtkPageSetup: the paper's GTK and display names, its size and margins in millimetres, and the orientation; (sssddddddss), PPDName first.
type PrepareRequest ¶
type PrepareRequest struct {
Title string
Settings []Setting
PageSetup PageSetup
AcceptLabel string
HasCurrentPage, HasSelectedPages bool
OutputFormats []string
}
PrepareRequest is what an app asks a print dialog with, (sa(ss) (sssddddddss)sbbas): the job title, its current settings and page setup to start from, the confirm button's label ("" for Print), whether it can print just its current page or a selection, and the formats it can write for Print to File (none means pdf).