Skip to content

Commit db12d2b

Browse files
backend: Add generic types for now
1 parent bb59faf commit db12d2b

File tree

8 files changed

+133
-0
lines changed

8 files changed

+133
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = "0.4.0-alpha.1"
1212

1313
[features]
1414
default = ["async-std"]
15+
backend = []
1516
gtk3_x11 = ["gdk3x11", "dep:gtk3"]
1617
gtk3_wayland = ["gdk3wayland", "dep:gtk3"]
1718
gtk3 = ["gtk3_x11", "gtk3_wayland"]

src/backend/access.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::collections::HashMap;
2+
3+
use zbus::dbus_interface;
4+
use zvariant::{OwnedValue, Value};
5+
6+
use crate::{
7+
desktop::{request::Response, HandleToken, ResponseError},
8+
WindowIdentifierType,
9+
};
10+
11+
pub struct Access {}
12+
13+
#[dbus_interface(name = "org.freedesktop.impl.portal.Access")]
14+
impl Access {
15+
fn access_dialog(
16+
&self,
17+
_handle: HandleToken,
18+
_app_id: &str,
19+
_window_identifier: WindowIdentifierType,
20+
_title: &str,
21+
_subtitle: &str,
22+
_body: &str,
23+
_options: HashMap<&str, Value<'_>>,
24+
) -> Response<HashMap<String, OwnedValue>> {
25+
Response::Err(ResponseError::Cancelled)
26+
}
27+
}

src/backend/account.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use zbus::dbus_interface;
2+
use zvariant::DeserializeDict;
3+
4+
use crate::{
5+
desktop::{
6+
account::UserInfo,
7+
request::{Response, ResponseError},
8+
HandleToken,
9+
},
10+
WindowIdentifierType,
11+
};
12+
13+
#[derive(Debug, DeserializeDict, zvariant::Type)]
14+
#[zvariant(signature = "dict")]
15+
pub struct UserInfoOptions {
16+
reason: Option<String>,
17+
}
18+
19+
pub struct Account {}
20+
21+
#[dbus_interface(name = "org.freedesktop.impl.portal.Account")]
22+
impl Account {
23+
async fn get_user_information(
24+
&self,
25+
handle: HandleToken,
26+
app_id: &str,
27+
window_identifier: WindowIdentifierType,
28+
options: UserInfoOptions,
29+
) -> Response<UserInfo> {
30+
Response::Err(ResponseError::Cancelled)
31+
}
32+
}

src/backend/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mod access;
2+
mod account;
3+
mod request;
4+
mod session;
5+
mod wallpaper;

src/backend/request.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use zbus::dbus_interface;
2+
3+
pub struct Request {}
4+
5+
#[dbus_interface(name = "org.freedesktop.impl.portal.Request")]
6+
impl Request {
7+
async fn close(&self) -> zbus::fdo::Result<()> {
8+
Ok(())
9+
}
10+
}

src/backend/session.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use zbus::{dbus_interface, SignalContext};
2+
3+
pub struct Session {}
4+
5+
#[dbus_interface(name = "org.freedesktop.impl.portal.Session")]
6+
impl Session {
7+
async fn close(&self) -> zbus::fdo::Result<()> {
8+
Ok(())
9+
}
10+
11+
#[dbus_interface(property)]
12+
fn version(&self) -> u32 {
13+
2
14+
}
15+
16+
#[dbus_interface(signal)]
17+
async fn closed(signal_ctxt: &SignalContext<'_>, message: &str) -> zbus::Result<()>;
18+
}

src/backend/wallpaper.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use zbus::dbus_interface;
2+
use zvariant::{DeserializeDict, Type};
3+
4+
use crate::{
5+
desktop::{
6+
request::{BasicResponse, Response},
7+
wallpaper::SetOn,
8+
HandleToken,
9+
},
10+
WindowIdentifierType,
11+
};
12+
13+
#[derive(DeserializeDict, Type, Debug, Default)]
14+
#[zvariant(signature = "dict")]
15+
pub struct WallpaperOptions {
16+
#[zvariant(rename = "show-preview")]
17+
show_preview: Option<bool>,
18+
#[zvariant(rename = "set-on")]
19+
set_on: Option<SetOn>,
20+
}
21+
22+
pub struct Wallpaper {}
23+
24+
#[dbus_interface(name = "org.freedesktop.impl.portal.Wallpaper")]
25+
impl Wallpaper {
26+
async fn set_wallpaper_uri(
27+
&self,
28+
handle: HandleToken,
29+
app_id: &str,
30+
window_identifier: WindowIdentifierType,
31+
uri: url::Url,
32+
options: WallpaperOptions,
33+
) -> Response<BasicResponse> {
34+
todo!()
35+
}
36+
}

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ pub mod documents;
2525
mod error;
2626
mod window_identifier;
2727
pub use self::window_identifier::WindowIdentifier;
28+
#[cfg(feature = "backend")]
29+
pub use self::window_identifier::WindowIdentifierType;
30+
#[cfg(feature = "backend")]
31+
pub mod backend;
2832
/// Spawn commands outside the sandbox or monitor if the running application has
2933
/// received an update & install it.
3034
pub mod flatpak;

0 commit comments

Comments
 (0)