Open: libportal Reference Manual

## Open Open — handle URIs |

## Functions

void | xdp_portal_open_uri ()
gboolean | xdp_portal_open_uri_finish ()
void | xdp_portal_open_directory ()
gboolean | xdp_portal_open_directory_finish ()

## Description

These functions let applications open URIs in external handlers. A typical example is to open a pdf file in a document viewer.

The underlying portal is org.freedesktop.portal.OpenURI.

## Functions

### xdp_portal_open_uri ()

    void
    xdp_portal_open_uri (XdpPortal *portal,
                         XdpParent *parent,
                         const char *uri,
                         gboolean writable,
                         GCancellable *cancellable,
                         GAsyncReadyCallback callback,
                         gpointer data);

Opens `uri` with an external hamdler.

#### Parameters

portal | a XdpPortal |
parent | parent window information |
uri | the URI to open |
writable | whether to make the file writable |
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_portal_open_uri_finish ()

    gboolean
    xdp_portal_open_uri_finish (XdpPortal *portal,
                                GAsyncResult *result,
                                GError **error);

Finishes the open-uri request, and returns the result in the form of a boolean.

#### Parameters

portal | a XdpPortal |
result | a GAsyncResult |
error | return location for an error |

#### Returns

`TRUE` if the call succeeded

### xdp_portal_open_directory ()

    void
    xdp_portal_open_directory (XdpPortal *portal,
                               XdpParent *parent,
                               const char *uri,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer data);

Opens the directory containing the file specified by the `uri` . which must be a file: uri pointing to a file that the application has access to.

#### Parameters

portal | a XdpPortal |
parent | parent window information |
uri | the URI to open |
writable | whether to make the file writable |
cancellable | optional GCancellable. | [nullable]
callback | a callback to call when the request is done. | [scope async]
data | data to pass to `callback` . | [closure]

### xdp_portal_open_directory_finish ()

    gboolean
    xdp_portal_open_directory_finish (XdpPortal *portal,
                                      GAsyncResult *result,
                                      GError **error);

Finishes the open-directory request, and returns the result in the form of a boolean.

#### Parameters

portal | a XdpPortal |
result | a GAsyncResult |
error | return location for an error |

#### Returns

`TRUE` if the call succeeded