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

[Applets] Center applet text without a description in the applets context drawer #793

Merged
merged 1 commit into from
Dec 3, 2024
Merged
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
498 changes: 254 additions & 244 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ lto = "thin"
# smithay-client-toolkit = { git = "https://github.com/smithay/client-toolkit//", rev = "c583de8" }

[patch.'https://github.com/pop-os/cosmic-protocols']
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols//", rev = "27d70b6" }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols//", rev = "d218c76" }

# For development and testing purposes
# [patch.'https://github.com/pop-os/libcosmic']
Expand Down
4 changes: 2 additions & 2 deletions cosmic-settings/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ impl SettingsApp {
}

let view = self
.page_container(settings::view_column(sections_column).padding(0))
.page_container(settings::view_column(sections_column))
.apply(scrollable)
.height(Length::Fill)
.apply(|w| id_container(w, self.id()));
Expand Down Expand Up @@ -1050,7 +1050,7 @@ impl SettingsApp {
}
}

self.page_container(settings::view_column(sections).padding(0))
self.page_container(settings::view_column(sections))
.apply(scrollable)
.into()
}
Expand Down
8 changes: 4 additions & 4 deletions cosmic-settings/src/pages/bluetooth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ fn status() -> Section<crate::pages::Message> {
} else {
text::body(&descriptions[bluetooth_heading]).into()
},
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
if page.popup_setting {
widget::popover(
widget::button::icon(widget::icon::from_name(
Expand Down Expand Up @@ -735,7 +735,7 @@ fn connected_devices() -> Section<crate::pages::Message> {
.wrapping(Wrapping::Word)
.into()
},
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
match device.enabled {
Active::Enabled => widget::text(&descriptions[device_connected]).into(),
Active::Enabling => widget::text(&descriptions[device_connecting])
Expand Down Expand Up @@ -790,7 +790,7 @@ fn available_devices() -> Section<crate::pages::Message> {
let mut items = vec![
widget::icon::from_name(device.icon).size(16).into(),
text(device.alias_or_addr()).wrapping(Wrapping::Word).into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
];

if device.enabled == Active::Enabling {
Expand Down Expand Up @@ -840,7 +840,7 @@ fn multiple_adapter() -> Section<crate::pages::Message> {
.into(),
widget::horizontal_space().width(theme.space_xxs()).into(),
text(&adapter.alias).wrapping(Wrapping::Word).into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
widget::icon::from_name("go-next-symbolic").into(),
];
if page.adapter_connected(path) {
Expand Down
3 changes: 1 addition & 2 deletions cosmic-settings/src/pages/desktop/appearance/font_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::sync::Arc;

use cosmic::{
config::{CosmicTk, FontConfig},
iced::Length,
iced_core::text::Wrapping,
theme,
widget::{self, settings, svg},
Expand Down Expand Up @@ -89,7 +88,7 @@ pub fn selection_context<'a>(
widget::text::body(&**family)
.wrapping(Wrapping::Word)
.into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
if selected {
widget::icon::from_name("object-select-symbolic")
.size(16)
Expand Down
6 changes: 2 additions & 4 deletions cosmic-settings/src/pages/desktop/appearance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,9 +1568,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
.title(fl!("mode-and-colors"))
.descriptions(descriptions)
.view::<Page>(move |_binder, page, section| {
let Spacing {
space_xxs, space_s, ..
} = cosmic::theme::active().cosmic().spacing;
let Spacing { space_xxs, .. } = cosmic::theme::active().cosmic().spacing;

let descriptions = &section.descriptions;
let palette = &page.theme_builder.palette.as_ref();
Expand Down Expand Up @@ -1728,7 +1726,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
)
.direction(Direction::Horizontal(Scrollbar::new()))
]
.padding([16, space_s, 0, space_s])
.padding([16, 0, 0, 0])
.spacing(space_xxs),
)
.add(
Expand Down
13 changes: 8 additions & 5 deletions cosmic-settings/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ impl Page {
) -> Element<crate::pages::Message> {
let cosmic::cosmic_theme::Spacing {
space_xxxs,
space_xxs,
space_xs,
space_s,
space_l,
..
} = theme::active().cosmic().spacing;
let mut list_column = list_column();
Expand Down Expand Up @@ -262,7 +261,11 @@ impl Page {
icon::from_name(&*info.icon).size(32).icon().into(),
column::with_capacity(2)
.push(text::body(info.name.clone()))
.push(text::caption(info.description.clone()))
.push_maybe(if info.description.is_empty() {
None
} else {
Some(text::caption(info.description.clone()))
})
.spacing(space_xxxs)
.width(Length::Fill)
.into(),
Expand Down Expand Up @@ -295,7 +298,7 @@ impl Page {
.on_press(msg_map(Message::AddApplet(info.clone())))
.into(),
])
.padding([0, space_s])
.padding([space_xxxs, 0])
.spacing(space_xs)
.align_y(Alignment::Center),
);
Expand All @@ -317,7 +320,7 @@ impl Page {
.push(search)
.push(list_column)
.align_x(Alignment::Center)
.spacing(space_xxs)
.spacing(space_l)
.into()
}

Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/desktop/panel/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
.find(|(_, v)| v.id == page.applets_page_id())
{
let control = row::with_children(vec![
horizontal_space().width(Length::Fill).into(),
horizontal_space().into(),
icon::from_name("go-next-symbolic").size(16).into(),
]);

Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/desktop/wallpaper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ pub fn settings() -> Section<crate::pages::Message> {
},
)
.push(category_selection)
.push(cosmic::widget::horizontal_space().width(Length::Fill))
.push(cosmic::widget::horizontal_space())
.push_maybe(add_button)
.into(),
);
Expand Down
22 changes: 13 additions & 9 deletions cosmic-settings/src/pages/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,15 +1073,16 @@ pub fn display_arrangement() -> Section<crate::pages::Message> {
.show_while::<Page>(|page| page.list.outputs.len() > 1)
.view::<Page>(move |_binder, page, section| {
let descriptions = &section.descriptions;
let theme = cosmic::theme::active();
let cosmic::cosmic_theme::Spacing {
space_xxs, space_m, ..
} = cosmic::theme::active().cosmic().spacing;

column()
.padding(cosmic::iced::Padding::from([
theme.cosmic().space_s(),
theme.cosmic().space_m(),
]))
.spacing(theme.cosmic().space_xs())
.push(widget::text::body(&descriptions[display_arrangement_desc]))
.push(
text::body(&descriptions[display_arrangement_desc])
.apply(container)
.padding([space_xxs, space_m]),
)
.push({
Arrangement::new(&page.list, &page.display_tabs)
.on_select(|id| pages::Message::Displays(Message::Display(id)))
Expand All @@ -1094,9 +1095,12 @@ pub fn display_arrangement() -> Section<crate::pages::Message> {
.width(Length::Shrink)
.direction(Direction::Horizontal(Scrollbar::new()))
.apply(container)
.padding([48, 32, 32, 32])
.center_x(Length::Fill)
})
.apply(widget::list::container)
.apply(container)
.class(cosmic::theme::Container::List)
.width(Length::Fill)
.into()
})
}
Expand Down Expand Up @@ -1224,7 +1228,7 @@ pub fn display_configuration() -> Section<crate::pages::Message> {
content = content.push(display_switcher).push(display_enable);
} else {
content = content
.push(widget::text::heading(&descriptions[options_label]))
.push(text::heading(&descriptions[options_label]))
.push_maybe(display_options.map(|items| {
let mut column = list_column();
for item in items {
Expand Down
47 changes: 28 additions & 19 deletions cosmic-settings/src/pages/display/night_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

use super::{Message, NightLight};
use crate::pages;
use cosmic::iced_core::{Alignment, Length, Padding};
use cosmic::prelude::CollectionWidget;
use cosmic::widget::{button, column, icon, list_column, row, toggler};
use cosmic::iced_core::{Alignment, Length};
use cosmic::widget::{
button, column, container, icon, list_column, row, settings, text, toggler, vertical_space,
};
use cosmic::{Apply, Element, Task};
use std::sync::Arc;

Expand All @@ -14,33 +15,40 @@ pub fn view(
description: &'static str,
button: Option<(&'static str, Message)>,
) -> Element<'static, Message> {
let theme = cosmic::theme::active();
let theme = theme.cosmic();
let cosmic::cosmic_theme::Spacing {
space_xxs, space_l, ..
} = cosmic::theme::active().cosmic().spacing;
let has_checkmark = button.is_none();

let content = column::with_capacity(3)
.padding(Padding::from([theme.space_xxs(), theme.space_l()]))
.push(cosmic::widget::text::body(mode))
.push(cosmic::widget::text::caption(description))
.push(cosmic::widget::Space::new(Length::Fill, 12))
let content = column::with_capacity(4)
.padding([space_xxs, space_l])
.push(text::body(mode))
.push(text::caption(description))
.push(vertical_space().height(12))
.push_maybe(button.map(|(text, message)| {
button::text(text)
.class(cosmic::theme::Button::Link)
.trailing_icon(icon::from_name("go-next-symbolic").size(16))
.padding(0)
.on_press(message)
}));

if has_checkmark {
row::with_capacity(2)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.push(content)
.push(icon::from_name("object-select-symbolic").size(24))
.apply(Element::from)
.apply(cosmic::widget::list::container)
.apply(container)
.class(cosmic::theme::Container::List)
.padding(8)
.width(Length::Fill)
.into()
} else {
cosmic::widget::list::container(content).into()
container(content)
.class(cosmic::theme::Container::List)
.padding(8)
.width(Length::Fill)
.into()
}
}

Expand All @@ -50,14 +58,15 @@ impl super::Page {

// Displays the night light status, and a button for configuring it.
container = container.add(
cosmic::widget::settings::item::builder(&*super::text::NIGHT_LIGHT)
settings::item::builder(&*super::text::NIGHT_LIGHT)
.description(&*super::text::NIGHT_LIGHT_DESCRIPTION)
.control(
row()
.align_items(Alignment::Center)
.push(toggler(self.config.night_light_enabled, |enable| {
Message::NightLight(NightLight::Toggle(enable))
}))
.align_y(Alignment::Center)
.push(
toggler(self.config.night_light_enabled)
.on_toggle(Message::NightLight(NightLight::Toggle)),
)
.push(
button::icon(icon::from_name("go-next-symbolic"))
.extra_small()
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/networking/vpn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ fn devices_view() -> Section<crate::pages::Message> {

let widget = widget::settings::item_row(vec![
identifier.into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
controls.into(),
]);

Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/networking/wifi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ fn devices_view() -> Section<crate::pages::Message> {

let widget = widget::settings::item_row(vec![
identifier.into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
controls.into(),
]);

Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/networking/wired.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl Page {

let widget = widget::settings::item_row(vec![
identifier.into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
controls.into(),
]);

Expand Down
3 changes: 1 addition & 2 deletions cosmic-settings/src/pages/time/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::str::FromStr;
use chrono::{Datelike, Timelike};
use cosmic::{
cosmic_config::{self, ConfigGet, ConfigSet},
iced::Length,
iced_core::text::Wrapping,
widget::{self, dropdown, settings},
Apply, Element, Task,
Expand Down Expand Up @@ -339,7 +338,7 @@ impl Page {
fn timezone_context_item<'a>(&self, id: usize, timezone: &'a str) -> Element<'a, Message> {
widget::button::custom(widget::settings::item_row(vec![
widget::text::body(timezone).wrapping(Wrapping::Word).into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
]))
.on_press(Message::Timezone(id))
.class(cosmic::theme::Button::Icon)
Expand Down
2 changes: 1 addition & 1 deletion cosmic-settings/src/pages/time/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl Page {
})
.wrapping(Wrapping::Word)
.into(),
widget::horizontal_space().width(Length::Fill).into(),
widget::horizontal_space().into(),
if is_installed {
widget::icon::from_name("object-select-symbolic")
.size(16)
Expand Down
10 changes: 5 additions & 5 deletions cosmic-settings/src/widget/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn search_page_link<Message: 'static>(title: &str) -> button::TextButton<Mes
pub fn page_title<Message: 'static>(page: &page::Info) -> Element<Message> {
row::with_capacity(2)
.push(text::title3(page.title.as_str()))
.push(horizontal_space().width(Length::Fill))
.push(horizontal_space())
.into()
}

Expand All @@ -110,9 +110,9 @@ pub fn display_container<'a, Message: 'a>(widget: Element<'a, Message>) -> Eleme
.class(crate::theme::display_container_frame());

row::with_capacity(3)
.push(horizontal_space().width(Length::Fill))
.push(horizontal_space())
.push(display)
.push(horizontal_space().width(Length::Fill))
.push(horizontal_space())
.padding([0, 0, 8, 0])
.into()
}
Expand Down Expand Up @@ -190,7 +190,7 @@ pub fn sub_page_header<'a, Message: 'static + Clone>(
pub fn go_next_item<Msg: Clone + 'static>(description: &str, msg: Msg) -> cosmic::Element<'_, Msg> {
settings::item_row(vec![
text::body(description).wrapping(Wrapping::Word).into(),
horizontal_space().width(Length::Fill).into(),
horizontal_space().into(),
icon::from_name("go-next-symbolic").size(16).icon().into(),
])
.apply(widget::container)
Expand All @@ -208,7 +208,7 @@ pub fn go_next_with_item<'a, Msg: Clone + 'static>(
) -> cosmic::Element<'_, Msg> {
settings::item_row(vec![
text::body(description).wrapping(Wrapping::Word).into(),
horizontal_space().width(Length::Fill).into(),
horizontal_space().into(),
widget::row::with_capacity(2)
.push(item)
.push(icon::from_name("go-next-symbolic").size(16).icon())
Expand Down
Loading