Skip to content

Commit

Permalink
backend: Add generic types for now
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Sep 15, 2022
1 parent 3082e78 commit b19a5f2
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ version = "0.4.0"

[features]
default = ["async-std"]
backend = []
gtk3_x11 = ["gdk3x11", "dep:gtk3"]
gtk3_wayland = ["gdk3wayland", "dep:gtk3"]
gtk3 = ["gtk3_x11", "gtk3_wayland"]
Expand Down
27 changes: 27 additions & 0 deletions src/backend/access.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::collections::HashMap;

use zbus::dbus_interface;
use zvariant::{OwnedValue, Value};

use crate::{
desktop::{request::Response, HandleToken, ResponseError},
WindowIdentifierType,
};

pub struct Access {}

#[dbus_interface(name = "org.freedesktop.impl.portal.Access")]
impl Access {
fn access_dialog(
&self,
_handle: HandleToken,
_app_id: &str,
_window_identifier: WindowIdentifierType,
_title: &str,
_subtitle: &str,
_body: &str,
_options: HashMap<&str, Value<'_>>,
) -> Response<HashMap<String, OwnedValue>> {
Response::Err(ResponseError::Cancelled)
}
}
32 changes: 32 additions & 0 deletions src/backend/account.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use zbus::dbus_interface;
use zvariant::DeserializeDict;

use crate::{
desktop::{
account::UserInfo,
request::{Response, ResponseError},
HandleToken,
},
WindowIdentifierType,
};

#[derive(Debug, DeserializeDict, zvariant::Type)]
#[zvariant(signature = "dict")]
pub struct UserInfoOptions {
reason: Option<String>,
}

pub struct Account {}

#[dbus_interface(name = "org.freedesktop.impl.portal.Account")]
impl Account {
async fn get_user_information(
&self,
handle: HandleToken,
app_id: &str,
window_identifier: WindowIdentifierType,
options: UserInfoOptions,
) -> Response<UserInfo> {
Response::Err(ResponseError::Cancelled)
}
}
5 changes: 5 additions & 0 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod access;
mod account;
mod request;
mod session;
mod wallpaper;
10 changes: 10 additions & 0 deletions src/backend/request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use zbus::dbus_interface;

pub struct Request {}

#[dbus_interface(name = "org.freedesktop.impl.portal.Request")]
impl Request {
async fn close(&self) -> zbus::fdo::Result<()> {
Ok(())
}
}
18 changes: 18 additions & 0 deletions src/backend/session.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use zbus::{dbus_interface, SignalContext};

pub struct Session {}

#[dbus_interface(name = "org.freedesktop.impl.portal.Session")]
impl Session {
async fn close(&self) -> zbus::fdo::Result<()> {
Ok(())
}

#[dbus_interface(property)]
fn version(&self) -> u32 {
2
}

#[dbus_interface(signal)]
async fn closed(signal_ctxt: &SignalContext<'_>, message: &str) -> zbus::Result<()>;
}
36 changes: 36 additions & 0 deletions src/backend/wallpaper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use zbus::dbus_interface;
use zvariant::{DeserializeDict, Type};

use crate::{
desktop::{
request::{BasicResponse, Response},
wallpaper::SetOn,
HandleToken,
},
WindowIdentifierType,
};

#[derive(DeserializeDict, Type, Debug, Default)]
#[zvariant(signature = "dict")]
pub struct WallpaperOptions {
#[zvariant(rename = "show-preview")]
show_preview: Option<bool>,
#[zvariant(rename = "set-on")]
set_on: Option<SetOn>,
}

pub struct Wallpaper {}

#[dbus_interface(name = "org.freedesktop.impl.portal.Wallpaper")]
impl Wallpaper {
async fn set_wallpaper_uri(
&self,
handle: HandleToken,
app_id: &str,
window_identifier: WindowIdentifierType,
uri: url::Url,
options: WallpaperOptions,
) -> Response<BasicResponse> {
todo!()
}
}
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub mod documents;
mod error;
mod window_identifier;
pub use self::window_identifier::WindowIdentifier;
#[cfg(feature = "backend")]
pub use self::window_identifier::WindowIdentifierType;
#[cfg(feature = "backend")]
pub mod backend;
/// Spawn commands outside the sandbox or monitor if the running application has
/// received an update & install it.
pub mod flatpak;
Expand Down

0 comments on commit b19a5f2

Please sign in to comment.