Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add globalshortcuts demo #214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ashpd-demo/Cargo.lock

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

2 changes: 1 addition & 1 deletion ashpd-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "0.4.1"
[dependencies]
adw = {version = "0.6", package = "libadwaita", features = ["v1_4"]}
anyhow = "1.0"
ashpd = {version = "^0.8", features = ["gtk4", "tracing", "pipewire"]}
ashpd = {git = "https://github.com/dcz-self/ashpd/", branch = "reb", features = ["gtk4", "tracing", "pipewire"]}
chrono = {version = "0.4", default-features = false, features = ["clock"]}
futures-util = "0.3"
gettext-rs = {version = "0.7", features = ["gettext-system"]}
Expand Down
1 change: 1 addition & 0 deletions ashpd-demo/data/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<file compressed="true" preprocess="xml-stripblanks" alias="email.ui">resources/ui/email.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="file_chooser.ui">resources/ui/file_chooser.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="inhibit.ui">resources/ui/inhibit.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="global_shortcuts.ui">resources/ui/global_shortcuts.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="location.ui">resources/ui/location.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="network_monitor.ui">resources/ui/network_monitor.ui</file>
<file compressed="true" preprocess="xml-stripblanks" alias="notification.ui">resources/ui/notification.ui</file>
Expand Down
93 changes: 93 additions & 0 deletions ashpd-demo/data/resources/ui/global_shortcuts.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GlobalShortcutsPage" 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">
<property name="title" translatable="yes">Global Shortcuts</property>
<property name="description" translatable="yes">Comma-separated list of shortcuts to request, in the form: "name:description:optional trigger"</property>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of putting this in a single entry, instead I would do something like notifications buttons

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I do that? Is there an example I could use as a guide?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are examples in both emails attachments and notifications buttons

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and I failed. Those examples don't show how to modify a property of a widget inside the list. Finding the inside widgets in the obvious way (by treating the widget as a list of widgets) fails in incomprehensible ways.

<child>
<object class="AdwEntryRow" id="shortcuts">
<property name="title" translatable="yes">Shortcuts</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Start Session</property>
<property name="use-underline">True</property>
<property name="halign">start</property>
<property name="action-name">global_shortcuts.start_session</property>
<style>
<class name="pill" />
<class name="suggested-action" />
</style>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">_Close Session</property>
<property name="use-underline">True</property>
<property name="halign">start</property>
<property name="sensitive">False</property>
<property name="action-name">global_shortcuts.stop</property>
<property name="halign">end</property>
<property name="hexpand">True</property>
<style>
<class name="pill" />
<class name="destructive-action" />
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="activations_group">
<property name="title" translatable="yes">Activations</property>
<property name="visible">False</property>
<property name="margin-top">24</property>
<child>
<object class="GtkLabel" id="activations_label">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup" id="general_group">
<property name="title" translatable="yes">Info</property>
<property name="margin-top">24</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Binding changes count</property>
<child>
<object class="GtkLabel" id="rebind_count_label">
<property name="valign">center</property>
<style>
<class name="dim-label" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="page-content" />
</style>
</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 @@ -101,6 +101,12 @@
<property name="page-name">file_chooser</property>
</object>
</child>
<child>
<object class="SidebarRow">
<property name="title" translatable="yes">Global Shortcuts</property>
<property name="page-name">global_shortcuts</property>
</object>
</child>
<child>
<object class="SidebarRow">
<property name="title" translatable="yes">Inhibit</property>
Expand Down Expand Up @@ -261,6 +267,14 @@
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">global_shortcuts</property>
<property name="child">
<object class="GlobalShortcutsPage" id="global_shortcuts" />
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">location</property>
Expand Down
1 change: 1 addition & 0 deletions ashpd-demo/po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data/resources/ui/camera.ui
data/resources/ui/email.ui
data/resources/ui/file_chooser.ui
data/resources/ui/inhibit.ui
data/resources/ui/global_shortcuts.ui
data/resources/ui/location.ui
data/resources/ui/notification.ui
data/resources/ui/open_uri.ui
Expand Down
Loading
Loading