Skip to content

Commit

Permalink
demo: Add a WIP global shortcuts page
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorota Czaplejewicz authored and bilelmoussaoui committed Feb 14, 2025
1 parent 56e6e1f commit 21ace41
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 10 deletions.
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>
<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 @@ -267,6 +273,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
9 changes: 6 additions & 3 deletions ashpd-demo/src/portals/desktop/file_chooser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use adw::{prelude::*, subclass::prelude::*};
use ashpd::{
desktop::file_chooser::{OpenFileRequest, SaveFileRequest, SaveFilesRequest, FileFilter},
desktop::file_chooser::{FileFilter, OpenFileRequest, SaveFileRequest, SaveFilesRequest},
WindowIdentifier,
};
use gtk::glib;
Expand Down Expand Up @@ -102,12 +102,15 @@ glib::wrapper! {
}

impl FileChooserPage {

fn filters(&self, pos: u32) -> Vec<FileFilter> {
let mut filters = Vec::new();

if pos > 0 {
filters.push(FileFilter::new("Text files").mimetype("text/*").glob("*.txt"));
filters.push(
FileFilter::new("Text files")
.mimetype("text/*")
.glob("*.txt"),
);
};
if pos > 1 {
filters.push(FileFilter::new("Images").mimetype("image/*"));
Expand Down
Loading

0 comments on commit 21ace41

Please sign in to comment.