Skip to content

Commit 17c738e

Browse files
committed
feat: type to search
1 parent 1b2aba0 commit 17c738e

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

cosmic-settings/src/app.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use cosmic::{
3030
iced::{
3131
self, Length, Subscription,
3232
event::{self, PlatformSpecific},
33-
window,
33+
keyboard, window,
3434
},
3535
prelude::*,
3636
surface,
@@ -160,6 +160,7 @@ pub enum Message {
160160
#[cfg(feature = "wayland")]
161161
PanelConfig(CosmicPanelConfig),
162162
SearchActivate,
163+
SearchActivateWith(String),
163164
SearchChanged(String),
164165
SearchClear,
165166
SearchSubmit,
@@ -297,8 +298,7 @@ impl cosmic::Application for SettingsApp {
297298
daytime,
298299
)))
299300
}),
300-
#[cfg(feature = "wayland")]
301-
event::listen_with(|event, _, _id| match event {
301+
event::listen_with(|event, status, _id| match event {
302302
#[cfg(feature = "wayland")]
303303
iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
304304
wayland::Event::Output(wayland::OutputEvent::Created(Some(info)), o),
@@ -307,6 +307,13 @@ impl cosmic::Application for SettingsApp {
307307
iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
308308
wayland::Event::Output(wayland::OutputEvent::Removed, o),
309309
)) => Some(Message::OutputRemoved(o)),
310+
iced::Event::Keyboard(keyboard::Event::KeyPressed {
311+
modifiers: m,
312+
text: Some(t),
313+
..
314+
}) if status == event::Status::Ignored && !m.control() && !m.alt() && !m.logo() => {
315+
Some(Message::SearchActivateWith(t.to_string()))
316+
}
310317
_ => None,
311318
}),
312319
#[cfg(feature = "wayland")]
@@ -354,9 +361,10 @@ impl cosmic::Application for SettingsApp {
354361
return self.search_changed(phrase);
355362
}
356363

357-
Message::SearchActivate => {
358-
self.search_active = true;
359-
return cosmic::widget::text_input::focus(self.search_id.clone());
364+
Message::SearchActivate => return self.on_search(),
365+
366+
Message::SearchActivateWith(phrase) => {
367+
return self.on_search().chain(self.search_changed(phrase));
360368
}
361369

362370
Message::SearchClear => {

libcosmic-dynamic/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "libcosmic"
3+
version = "0.1.0"
4+
edition = "2024"
5+
license = "GPL-3.0-only"
6+
7+
[lib]
8+
crate-type = ["dylib"]
9+
name = "cosmic"
10+
11+
[dependencies.libcosmic]
12+
features = ["multi-window", "winit", "tokio"]
13+
#path = "libcosmic-dynamic"
14+
git = "https://github.com/pop-os/libcosmic"
15+
16+
[features]
17+
dbus-config = ["libcosmic/dbus-config"]
18+
a11y = ["libcosmic/a11y"]
19+
multi-window = ["libcosmic/multi-window"]
20+
winit = ["libcosmic/winit"]
21+
tokio = ["libcosmic/tokio"]
22+
single-instance = ["libcosmic/single-instance"]
23+
wayland = ["libcosmic/wayland"]
24+
wgpu = ["libcosmic/wgpu"]
25+
xdg-portal = ["libcosmic/xdg-portal"]

libcosmic-dynamic/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub use cosmic::*;

0 commit comments

Comments
 (0)