Method

XdpPortalopen_file

Declaration [src]

void
xdp_portal_open_file (
  XdpPortal* portal,
  XdpParent* parent,
  const char* title,
  GVariant* filters,
  GVariant* current_filter,
  GVariant* choices,
  XdpOpenFileFlags flags,
  GCancellable* cancellable,
  GAsyncReadyCallback callback,
  gpointer data
)

Description [src]

Asks the user to open one or more files.

The format for the filters argument is a(sa(us)). Each item in the array specifies a single filter to offer to the user. The first string is a user-visible name for the filter. The a(us) specifies a list of filter strings, which can be either a glob pattern (indicated by 0) or a mimetype (indicated by 1).

Example: [('Images', [(0, '*.ico'), (1, 'image/png')]), ('Text', [(0, '*.txt')])]

The format for the choices argument is a(ssa(ss)s). For each element, the first string is an ID that will be returned with the response, te second string is a user-visible label. The a(ss) is the list of choices, each being a is an ID and a user-visible label. The final string is the initial selection, or "", to let the portal decide which choice will be initially selected. None of the strings, except for the initial selection, should be empty.

As a special case, passing an empty array for the list of choices indicates a boolean choice that is typically displayed as a check button, using "true" and "false" as the choices.

Example: [('encoding', 'Encoding', [('utf8', 'Unicode (UTF-8)'), ('latin15', 'Western')], 'latin15'), ('reencode', 'Reencode', [], 'false')]

When the request is done, callback will be called. You can then call xdp_portal_open_file_finish() to get the results.

Parameters

parent

Type: XdpParent

Parent window information.

The argument can be NULL.
The data is owned by the caller of the method.
title

Type: const char*

Title for the file chooser dialog.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.
filters

Type: GVariant

A GVariant describing file filters.

The argument can be NULL.
The data is owned by the caller of the method.
current_filter

Type: GVariant

A GVariant describing the current file filter.

The argument can be NULL.
The data is owned by the caller of the method.
choices

Type: GVariant

A GVariant describing extra widgets.

The argument can be NULL.
The data is owned by the caller of the method.
flags

Type: XdpOpenFileFlags

Options for this call.

cancellable

Type: GCancellable

Optional GCancellable

The argument can be NULL.
The data is owned by the caller of the method.
callback

Type: GAsyncReadyCallback

A callback to call when the request is done.

The argument can be NULL.
data

Type: gpointer

Data to pass to callback.

The argument can be NULL.
The data is owned by the caller of the method.