Skip to content

Commit 21ace41

Browse files
Dorota Czaplejewiczbilelmoussaoui
Dorota Czaplejewicz
authored andcommitted
demo: Add a WIP global shortcuts page
1 parent 56e6e1f commit 21ace41

File tree

9 files changed

+427
-10
lines changed

9 files changed

+427
-10
lines changed

ashpd-demo/data/resources.gresource.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<file compressed="true" preprocess="xml-stripblanks" alias="email.ui">resources/ui/email.ui</file>
1717
<file compressed="true" preprocess="xml-stripblanks" alias="file_chooser.ui">resources/ui/file_chooser.ui</file>
1818
<file compressed="true" preprocess="xml-stripblanks" alias="inhibit.ui">resources/ui/inhibit.ui</file>
19+
<file compressed="true" preprocess="xml-stripblanks" alias="global_shortcuts.ui">resources/ui/global_shortcuts.ui</file>
1920
<file compressed="true" preprocess="xml-stripblanks" alias="location.ui">resources/ui/location.ui</file>
2021
<file compressed="true" preprocess="xml-stripblanks" alias="network_monitor.ui">resources/ui/network_monitor.ui</file>
2122
<file compressed="true" preprocess="xml-stripblanks" alias="notification.ui">resources/ui/notification.ui</file>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<interface>
3+
<template class="GlobalShortcutsPage" parent="PortalPage">
4+
<child>
5+
<object class="AdwClamp">
6+
<child>
7+
<object class="GtkBox">
8+
<property name="hexpand">True</property>
9+
<property name="spacing">12</property>
10+
<property name="orientation">vertical</property>
11+
<child>
12+
<object class="AdwPreferencesGroup">
13+
<property name="title" translatable="yes">Global Shortcuts</property>
14+
<property name="description" translatable="yes">Comma-separated list of shortcuts to request, in the form: "name:description:optional trigger"</property>
15+
<child>
16+
<object class="AdwEntryRow" id="shortcuts">
17+
<property name="title" translatable="yes">Shortcuts</property>
18+
</object>
19+
</child>
20+
</object>
21+
</child>
22+
<child>
23+
<object class="GtkBox">
24+
<property name="orientation">horizontal</property>
25+
<child>
26+
<object class="GtkButton">
27+
<property name="label" translatable="yes">_Start Session</property>
28+
<property name="use-underline">True</property>
29+
<property name="halign">start</property>
30+
<property name="action-name">global_shortcuts.start_session</property>
31+
<style>
32+
<class name="pill" />
33+
<class name="suggested-action" />
34+
</style>
35+
</object>
36+
</child>
37+
<child>
38+
<object class="GtkButton">
39+
<property name="label" translatable="yes">_Close Session</property>
40+
<property name="use-underline">True</property>
41+
<property name="halign">start</property>
42+
<property name="sensitive">False</property>
43+
<property name="action-name">global_shortcuts.stop</property>
44+
<property name="halign">end</property>
45+
<property name="hexpand">True</property>
46+
<style>
47+
<class name="pill" />
48+
<class name="destructive-action" />
49+
</style>
50+
</object>
51+
</child>
52+
</object>
53+
</child>
54+
<child>
55+
<object class="AdwPreferencesGroup" id="activations_group">
56+
<property name="title" translatable="yes">Activations</property>
57+
<property name="visible">False</property>
58+
<property name="margin-top">24</property>
59+
<child>
60+
<object class="GtkLabel" id="activations_label">
61+
<property name="valign">center</property>
62+
</object>
63+
</child>
64+
</object>
65+
</child>
66+
<child>
67+
<object class="AdwPreferencesGroup" id="general_group">
68+
<property name="title" translatable="yes">Info</property>
69+
<property name="margin-top">24</property>
70+
<child>
71+
<object class="AdwActionRow">
72+
<property name="title" translatable="yes">Binding changes count</property>
73+
<child>
74+
<object class="GtkLabel" id="rebind_count_label">
75+
<property name="valign">center</property>
76+
<style>
77+
<class name="dim-label" />
78+
</style>
79+
</object>
80+
</child>
81+
</object>
82+
</child>
83+
</object>
84+
</child>
85+
</object>
86+
</child>
87+
<style>
88+
<class name="page-content" />
89+
</style>
90+
</object>
91+
</child>
92+
</template>
93+
</interface>

ashpd-demo/data/resources/ui/window.ui

+14
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
<property name="page-name">file_chooser</property>
102102
</object>
103103
</child>
104+
<child>
105+
<object class="SidebarRow">
106+
<property name="title" translatable="yes">Global Shortcuts</property>
107+
<property name="page-name">global_shortcuts</property>
108+
</object>
109+
</child>
104110
<child>
105111
<object class="SidebarRow">
106112
<property name="title" translatable="yes">Inhibit</property>
@@ -267,6 +273,14 @@
267273
</property>
268274
</object>
269275
</child>
276+
<child>
277+
<object class="GtkStackPage">
278+
<property name="name">global_shortcuts</property>
279+
<property name="child">
280+
<object class="GlobalShortcutsPage" id="global_shortcuts" />
281+
</property>
282+
</object>
283+
</child>
270284
<child>
271285
<object class="GtkStackPage">
272286
<property name="name">location</property>

ashpd-demo/po/POTFILES.in

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ data/resources/ui/camera.ui
77
data/resources/ui/email.ui
88
data/resources/ui/file_chooser.ui
99
data/resources/ui/inhibit.ui
10+
data/resources/ui/global_shortcuts.ui
1011
data/resources/ui/location.ui
1112
data/resources/ui/notification.ui
1213
data/resources/ui/open_uri.ui

ashpd-demo/src/portals/desktop/file_chooser.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use adw::{prelude::*, subclass::prelude::*};
22
use ashpd::{
3-
desktop::file_chooser::{OpenFileRequest, SaveFileRequest, SaveFilesRequest, FileFilter},
3+
desktop::file_chooser::{FileFilter, OpenFileRequest, SaveFileRequest, SaveFilesRequest},
44
WindowIdentifier,
55
};
66
use gtk::glib;
@@ -102,12 +102,15 @@ glib::wrapper! {
102102
}
103103

104104
impl FileChooserPage {
105-
106105
fn filters(&self, pos: u32) -> Vec<FileFilter> {
107106
let mut filters = Vec::new();
108107

109108
if pos > 0 {
110-
filters.push(FileFilter::new("Text files").mimetype("text/*").glob("*.txt"));
109+
filters.push(
110+
FileFilter::new("Text files")
111+
.mimetype("text/*")
112+
.glob("*.txt"),
113+
);
111114
};
112115
if pos > 1 {
113116
filters.push(FileFilter::new("Images").mimetype("image/*"));

0 commit comments

Comments
 (0)