Skip to content

Commit

Permalink
Allow setting activation_token
Browse files Browse the repository at this point in the history
  • Loading branch information
apricotbucket28 committed Jun 20, 2024
1 parent cf99f85 commit a014b0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/desktop/dynamic_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,15 @@ impl<'a> DynamicLauncherProxy<'a> {
/// See also [`Launch`](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.DynamicLauncher.html#org-freedesktop-portal-dynamiclauncher-launch).
#[doc(alias = "Launch")]
#[doc(alias = "xdp_portal_dynamic_launcher_launch")]
pub async fn launch(&self, desktop_file_id: &str) -> Result<(), Error> {
// TODO: handle activation_token
let options: HashMap<&str, zvariant::Value<'_>> = HashMap::new();
pub async fn launch(
&self,
desktop_file_id: &str,
activation_token: impl Into<Option<String>>,
) -> Result<(), Error> {
let mut options: HashMap<&str, zvariant::Value<'_>> = HashMap::new();
if let Some(activation_token) = activation_token.into() {
options.insert("activation_token", activation_token.into());
}
self.0.call("Launch", &(desktop_file_id, &options)).await
}

Expand Down
14 changes: 14 additions & 0 deletions src/desktop/open_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ impl OpenFileRequest {
self
}

#[must_use]
/// Sets the token that can be used to activate the chosen application.
pub fn activation_token(mut self, activation_token: impl Into<Option<String>>) -> Self {
self.options.activation_token = activation_token.into();
self
}

/// Send the request for a file.
pub async fn send_file(self, file: &BorrowedFd<'_>) -> Result<Request<()>, Error> {
let proxy = OpenURIProxy::new().await?;
Expand Down Expand Up @@ -203,6 +210,13 @@ impl OpenDirectoryRequest {
self
}

#[must_use]
/// Sets the token that can be used to activate the chosen application.
pub fn activation_token(mut self, activation_token: impl Into<Option<String>>) -> Self {
self.options.activation_token = activation_token.into();
self
}

/// Send the request.
pub async fn send(self, directory: &BorrowedFd<'_>) -> Result<Request<()>, Error> {
let proxy = OpenURIProxy::new().await?;
Expand Down

0 comments on commit a014b0e

Please sign in to comment.