Skip to content

Commit

Permalink
demo: Added USB portal support
Browse files Browse the repository at this point in the history
- Added UI for USB
- Added rusb to the crates.
- Added libusb to the manifest.

Signed-off-by: Hubert Figuière <[email protected]>
  • Loading branch information
hfiguiere committed Dec 7, 2024
1 parent 28fef92 commit 85d3611
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 1 deletion.
29 changes: 29 additions & 0 deletions ashpd-demo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ashpd-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gettext-rs = {version = "0.7", features = ["gettext-system"]}
gst = {package = "gstreamer", version = "0.23"}
gst4gtk = {package = "gst-plugin-gtk4", version = "0.13", features = ["wayland", "x11egl", "x11glx", "gtk_v4_14"]}
gtk = {package = "gtk4", version = "0.9", features = ["v4_14"]}
rusb = "0.9.4"
serde = {version = "1.0", features = ["derive"]}
shumate = {version = "0.6", package = "libshumate"}
tracing = "0.1"
Expand Down
11 changes: 11 additions & 0 deletions ashpd-demo/build-aux/com.belmoussaoui.ashpd.demo.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"--socket=wayland",
"--device=dri",
"--own-name=com.belmoussaoui.ashpd.demo",
"--usb=all",
"--env=RUST_LOG=ashpd_demo=debug,ashpd=debug",
"--env=G_MESSAGES_DEBUG=none",
"--env=RUST_BACKTRACE=1"
Expand All @@ -31,6 +32,16 @@
]
},
"modules": [
{
"name": "libusb",
"sources": [
{
"type": "archive",
"url": "https://github.com/libusb/libusb/releases/download/v1.0.27/libusb-1.0.27.tar.bz2",
"sha256": "ffaa41d741a8a3bee244ac8e54a72ea05bf2879663c098c82fc5757853441575"
}
]
},
{
"name": "libshumate",
"buildsystem": "meson",
Expand Down
2 changes: 2 additions & 0 deletions ashpd-demo/data/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<file compressed="true" preprocess="xml-stripblanks" alias="screenshot.ui">resources/ui/screenshot.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="screencast.ui">resources/ui/screencast.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="secret.ui">resources/ui/secret.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="usb.ui">resources/ui/usb.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="usb_device_row.ui">resources/ui/usb_device_row.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="wallpaper.ui">resources/ui/wallpaper.ui</file>

<file compressed="true" alias="style.css">resources/style.css</file>
Expand Down
63 changes: 63 additions & 0 deletions ashpd-demo/data/resources/ui/usb.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="UsbPage" parent="PortalPage">
<child>
<object class="AdwClamp">
<child>
<object class="GtkBox">
<property name="hexpand">True</property>
<property name="spacing">12</property>
<property name="orientation">vertical</property>
<child>
<object class="AdwPreferencesGroup" id="usb_devices">
<property name="title" translatable="yes">Device Access</property>
<property name="description" translatable="yes">Calls AcquireDevices or ReleaseDevices on org.freedesktop.portal.Usb.</property>
<property name="header-suffix">
<object class="GtkButton">
<property name="label" translatable="yes">Refresh</property>
<property name="icon-name">view-refresh-symbolic</property>
<property name="action-name">usb.refresh</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="label">_Start Session</property>
<property name="use-underline">True</property>
<property name="halign">start</property>
<property name="action-name">usb.start_session</property>
<style>
<class name="pill" />
<class name="suggested-action" />
</style>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">_Stop Session</property>
<property name="use-underline">True</property>
<property name="sensitive">false</property>
<property name="halign">end</property>
<property name="hexpand">true</property>
<property name="action-name">usb.stop_session</property>
<style>
<class name="pill" />
<class name="destructive-action" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="page-content" />
</style>
</object>
</child>
</template>
</interface>
31 changes: 31 additions & 0 deletions ashpd-demo/data/resources/ui/usb_device_row.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="UsbDeviceRow" parent="AdwActionRow">
<child type="prefix">
<object class="GtkCheckButton" id="checkbox">
<property name="sensitive">false</property>
</object>
</child>
<child type="suffix">
<object class="GtkBox" id="box1">
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<style>
<class name="linked" />
</style>
<child>
<object class="GtkButton" id="acquire">
<signal name="clicked" handler="handle_acquire_clicked" swapped="true" />
<property name="icon-name">preferences-system-sharing-symbolic</property>
</object>
</child>
<child type="suffix">
<object class="GtkButton" id="release">
<signal name="clicked" handler="handle_release_clicked" swapped="true"/>
<property name="icon-name">process-stop-symbolic</property>
</object>
</child>
</object>
</child>
</template>
</interface>
14 changes: 14 additions & 0 deletions ashpd-demo/data/resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
<property name="page-name">secret</property>
</object>
</child>
<child>
<object class="SidebarRow">
<property name="title" translatable="yes">USB</property>
<property name="page-name">usb</property>
</object>
</child>
<child>
<object class="SidebarRow">
<property name="title" translatable="yes">Wallpaper</property>
Expand Down Expand Up @@ -325,6 +331,14 @@
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">usb</property>
<property name="child">
<object class="UsbPage" id="usb" />
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">wallpaper</property>
Expand Down
2 changes: 2 additions & 0 deletions ashpd-demo/src/portals/desktop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod remote_desktop;
mod screencast;
mod screenshot;
mod secret;
mod usb;
mod wallpaper;

pub use account::AccountPage;
Expand All @@ -36,4 +37,5 @@ pub use remote_desktop::RemoteDesktopPage;
pub use screencast::ScreenCastPage;
pub use screenshot::ScreenshotPage;
pub use secret::SecretPage;
pub use usb::UsbPage;
pub use wallpaper::WallpaperPage;
Loading

0 comments on commit 85d3611

Please sign in to comment.