Skip to content

Commit bfda993

Browse files
committed
refactor: more dropdown popups
1 parent 805683f commit bfda993

File tree

13 files changed

+511
-146
lines changed

13 files changed

+511
-146
lines changed

Cargo.lock

+32-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ cosmic-client-toolkit = { git = "https://github.com/pop-os/cosmic-protocols//",
5757

5858
# For development and testing purposes
5959
[patch.'https://github.com/pop-os/libcosmic']
60-
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "fontconfig" }
61-
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "fontconfig" }
62-
# cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "fontconfig" }
63-
libcosmic = { path = "../libcosmic" }
64-
cosmic-config = { path = "../libcosmic/cosmic-config" }
65-
cosmic-theme = { path = "../libcosmic/cosmic-theme" }
60+
libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
61+
cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
62+
cosmic-theme = { git = "https://github.com/pop-os/libcosmic//", branch = "drop-menu-tree-changes" }
63+
# libcosmic = { path = "../libcosmic" }
64+
# cosmic-config = { path = "../libcosmic/cosmic-config" }
65+
# cosmic-theme = { path = "../libcosmic/cosmic-theme" }
6666

6767
# [patch.'https://github.com/pop-os/dbus-settings-bindings']
6868
# cosmic-dbus-networkmanager = { path = "../dbus-settings-bindings/networkmanager" }

cosmic-settings/src/app.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,9 @@ impl cosmic::Application for SettingsApp {
573573

574574
#[cfg(feature = "page-power")]
575575
crate::pages::Message::Power(message) => {
576-
page::update!(self.pages, message, power::Page);
576+
if let Some(page) = self.pages.page_mut::<power::Page>() {
577+
return page.update(message).map(Into::into);
578+
}
577579
}
578580

579581
#[cfg(feature = "page-networking")]

cosmic-settings/src/pages/accessibility/magnifier.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::collections::HashSet;
33
use cosmic::{
44
iced::{Element, Length},
55
iced_core::text::Wrapping,
6+
surface,
67
widget::{self, icon, settings, svg, text},
78
Apply,
89
};
@@ -39,6 +40,7 @@ pub enum Message {
3940
SetIncrement(usize),
4041
SetSignin(bool),
4142
SetMovement(ZoomMovement),
43+
Surface(surface::Action),
4244
}
4345

4446
impl Default for Page {
@@ -184,14 +186,26 @@ pub fn magnifier() -> section::Section<crate::pages::Message> {
184186
widget::toggler(page.magnifier_state).on_toggle(Message::SetMagnifier),
185187
),
186188
)
187-
.add(settings::item(
188-
&descriptions[increment],
189-
widget::dropdown(
189+
.add(settings::item(&descriptions[increment], {
190+
let dropdown = widget::dropdown(
190191
&page.increment_values,
191192
page.increment_idx,
192193
Message::SetIncrement,
193-
),
194-
))
194+
);
195+
#[cfg(feature = "wayland")]
196+
let dropdown = {
197+
dropdown.with_popup(
198+
cosmic::iced::window::Id::RESERVED,
199+
Message::Surface,
200+
|a| {
201+
crate::app::Message::PageMessage(
202+
crate::pages::Message::AccessibilityMagnifier(a),
203+
)
204+
},
205+
)
206+
};
207+
dropdown
208+
}))
195209
.add(settings::item(
196210
&descriptions[signin],
197211
widget::toggler(page.zoom_config.start_on_login).on_toggle(Message::SetSignin),
@@ -332,6 +346,9 @@ impl Page {
332346
));
333347
}
334348
}
349+
Message::Surface(a) => {
350+
return cosmic::task::message(crate::app::Message::Surface(a));
351+
}
335352
}
336353

337354
cosmic::iced::Task::none()

cosmic-settings/src/pages/desktop/dock/mod.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ impl Page {
6666

6767
Task::none()
6868
}
69-
Message::Inner(inner) => self
70-
.inner
71-
.update(inner)
72-
.map(Message::Inner)
73-
.map(crate::pages::Message::Dock)
74-
.map(crate::app::Message::PageMessage),
69+
Message::Inner(inner) => {
70+
if let inner::Message::Surface(a) = inner {
71+
return cosmic::task::message(crate::app::Message::Surface(a));
72+
} else {
73+
self.inner
74+
.update(inner)
75+
.map(Message::Inner)
76+
.map(crate::pages::Message::Dock)
77+
.map(crate::app::Message::PageMessage)
78+
}
79+
}
7580
}
7681
}
7782
}

0 commit comments

Comments
 (0)