fix: padding, spacing, context menu style, and settings buttons

This commit is contained in:
Vukašin Vojinović 2024-09-24 15:52:17 +02:00 committed by GitHub
parent 0a32d27c70
commit 941cbf546b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 694 additions and 538 deletions

889
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@ use cosmic::{
accept_mime_type, finish_dnd, request_dnd_data, set_actions, start_drag,
},
iced_style::{application, svg},
theme::{Button, Container},
theme::{self, Button, Container},
widget::{
button, divider, horizontal_space, icon,
icon::from_name,
@ -62,7 +62,7 @@ use futures::future::pending;
use iced::{widget::container, Alignment, Background, Length};
use itertools::Itertools;
use rand::{thread_rng, Rng};
use std::{collections::HashMap, fs, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
use std::{collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
use switcheroo_control::Gpu;
use tokio::time::sleep;
use url::Url;
@ -262,7 +262,7 @@ impl DockItem {
.into(),
};
let icon_button = cosmic::widget::button(icon_wrapper)
let icon_button = button::custom(icon_wrapper)
.padding(app_icon.padding)
.selected(is_focused)
.style(app_list_icon_style(is_focused));
@ -456,7 +456,7 @@ where
Msg: 'static + Clone,
{
let border = 1.0;
cosmic::widget::button(
button::custom(
container(
column![
container(if let Some(img) = img {
@ -1715,14 +1715,14 @@ impl cosmic::Application for CosmicAppList {
fn menu_button<'a, Message>(
content: impl Into<Element<'a, Message>>,
) -> cosmic::widget::Button<'a, Message> {
cosmic::widget::button(content)
.height(36)
.style(Button::AppletMenu)
button::custom(content)
.height(20 + 2 * theme::active().cosmic().space_xxs())
.style(Button::MenuItem)
.padding(menu_control_padding())
.width(Length::Fill)
}
let mut content = column![].padding([8, 0]).align_items(Alignment::Center);
let mut content = column![].align_items(Alignment::Center);
if let Some(exec) = desktop_info.exec() {
if !toplevels.is_empty() {
@ -1774,7 +1774,7 @@ impl cosmic::Application for CosmicAppList {
.on_press(Message::Exec(exec.into(), None)),
);
}
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
}
if !toplevels.is_empty() {
@ -1791,7 +1791,7 @@ impl cosmic::Application for CosmicAppList {
);
}
content = content.push(list_col);
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
}
let svg_accent = Rc::new(|theme: &cosmic::Theme| {
@ -1820,7 +1820,7 @@ impl cosmic::Application for CosmicAppList {
);
if toplevels.len() > 0 {
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
content = match toplevels.len() {
1 => content.push(
menu_button(text::body(fl!("quit")))
@ -1832,7 +1832,26 @@ impl cosmic::Application for CosmicAppList {
),
};
}
self.core.applet.popup_container(content).into()
container(content)
.padding(1)
//TODO: move style to libcosmic
.style(theme::Container::custom(|theme| {
let cosmic = theme.cosmic();
let component = &cosmic.background.component;
container::Appearance {
icon_color: Some(component.on.into()),
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border: Border {
radius: 8.0.into(),
width: 1.0,
color: component.divider.into(),
},
..Default::default()
}
}))
.width(Length::Fill)
.into()
}
PopupType::TopLevelList => match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => {

View file

@ -1,6 +1,6 @@
output = Output
input = Input
show-media-controls = Show Media Controls on Top Panel
show-media-controls = Show media controls on panel
sound-settings = Sound Settings...
disconnected = PulseAudio Disconnected
no-device = No device selected

View file

@ -15,15 +15,17 @@ use cosmic::{
menu_button, menu_control_padding, padded_control,
token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
},
cctk::sctk::reexports::{calloop, protocols::xdg::shell::client::xdg_positioner::Anchor},
cctk::sctk::reexports::calloop,
cosmic_config::CosmicConfigEntry,
cosmic_theme::Spacing,
iced::{
self,
widget::{self, column, row, slider},
window, Alignment, Length, Limits, Rectangle, Subscription,
window, Alignment, Length, Limits, Subscription,
},
iced_runtime::core::alignment::Horizontal,
iced_style::application,
theme,
widget::{button, divider, horizontal_space, icon, text, Column, Row},
Element, Renderer, Theme,
};
@ -665,6 +667,9 @@ impl cosmic::Application for Audio {
input.mute = value;
}
}
sub_pulse::Event::DefaultSink(_) => {}
sub_pulse::Event::DefaultSource(_) => {}
sub_pulse::Event::CardInfo(_) => {}
},
};
@ -735,16 +740,19 @@ impl cosmic::Application for Audio {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let audio_disabled = matches!(self.pulse_state, PulseState::Disconnected(_));
let out_mute = self.current_output_mute();
let in_mute = self.current_input_mute();
let mut audio_content = if audio_disabled {
column![padded_control(
text(fl!("disconnected"))
text::title3(fl!("disconnected"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(24)
)]
} else {
column![
@ -790,7 +798,7 @@ impl cosmic::Application for Audio {
.spacing(12)
.align_items(Alignment::Center)
),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
revealer(
self.is_open == IsOpen::Output,
fl!("output"),
@ -906,7 +914,8 @@ impl cosmic::Application for Audio {
.into(),
);
audio_content = audio_content.push(padded_control(divider::horizontal::default()));
audio_content = audio_content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
audio_content = audio_content.push(
Row::with_children(elements)
.align_items(Alignment::Center)
@ -916,7 +925,7 @@ impl cosmic::Application for Audio {
}
let content = column![
audio_content,
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
anim!(
// toggler
@ -928,9 +937,8 @@ impl cosmic::Application for Audio {
)
.text_size(14)
.width(Length::Fill)
)
.padding([8, 24]),
padded_control(divider::horizontal::default()),
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
menu_button(text::body(fl!("sound-settings"))).on_press(Message::OpenSettings)
]
.align_items(Alignment::Start)

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Taste
battery = Akku
battery-desc = Reduzierter Stromverbrauch und Leistung.
balanced = Ausgeglichen
@ -12,4 +11,4 @@ hours = h
until-empty = bis leer
power-settings = Energie- und Akkueinstellungen...
dgpu-running = Dedizierte GPU ist aktiv und kann die Akkulaufzeit reduzieren
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Button
battery = Battery
battery-desc = Reduced power usage and performance.
balanced = Balanced
@ -10,6 +9,6 @@ seconds = s
minutes = m
hours = h
until-empty = until empty
power-settings = Power and Battery Settings...
power-settings = Power & Battery settings...
dgpu-running = Discrete GPU is active and can reduce battery life
dgpu-applications = Applications using {$gpu_name} discrete GPU
dgpu-applications = Applications using {$gpu_name} discrete GPU

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Botón de Cosmic
battery = Ahorro de energía
battery-desc = Rendimiento y uso de energía reducido.
balanced = Balanceado

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Botón Cosmic
battery = Batería
battery-desc = Rendimiento y consumo de alimentación reducidos.
balanced = Balanceado

View file

@ -1,4 +1,3 @@
cosmic-applet-button = دکمه Cosmic
battery = باتری
battery-desc = کاهش مصرف برق و عملکرد.
balanced = متعادل

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Painike
battery = Akku
battery-desc = Vähentynyt virrankulutus ja suorituskyky.
balanced = Tasapainoitettu

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Bouton Cosmic
battery = Batterie
battery-desc = Performance et consommation réduites.
balanced = Équilibré
@ -12,4 +11,4 @@ hours = h
until-empty = avant la décharge totale
power-settings = Paramètres d'alimentation...
dgpu-running = Le GPU dédié est actif et peu réduire l'autonomie de la batterie
dgpu-applications = Applications utilisant le GPU dédié {$gpu_name}
dgpu-applications = Applications utilisant le GPU dédié {$gpu_name}

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Gomb
battery = Akkumulátor
battery-desc = Csökkentett energiafogyasztás és teljesítmény.
balanced = Kiegyensúlyozott
@ -12,4 +11,4 @@ hours = h
until-empty = lemerülésig
power-settings = Tápellátás és akkumulátor beállítások...
dgpu-running = A dedikált GPU aktív, és csökkentheti az akkumulátor élettartamát
dgpu-applications = A {$gpu_name} dedikált GPU-t használó alkalmazások
dgpu-applications = A {$gpu_name} dedikált GPU-t használó alkalmazások

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Tombol Cosmic
battery = Baterai
battery-desc = Penggunaan daya dan kinerja yang dikurangi.
balanced = Seimbang
@ -7,9 +6,9 @@ performance = Kinerja Tinggi
performance-desc = Kinerja dan penggunaan daya yang tinggi.
max-charge = Tingkatkan masa pakai baterai Anda dengan mengatur nilai pengisian maksimum 80%
seconds = d
minutes = m
minutes = m
hours = j
until-empty = hingga kosong
power-settings = Pengaturan Daya dan Baterai...
dgpu-running = GPU Diskrit aktif dan dapat mengurangi masa pakai baterai
dgpu-applications = Aplikasi yang menggunakan {$gpu_name} GPU Diskrit
dgpu-applications = Aplikasi yang menggunakan {$gpu_name} GPU Diskrit

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Pulsante Cosmic
battery = Batteria
battery-desc = Consumi e performance ridotte.
balanced = Bilanciato
@ -12,4 +11,4 @@ hours = h
until-empty = fino alla scarica
power-settings = Impostazioni energetiche
dgpu-running = La GPU discreta è attiva e può ridurre la durata della batteria.
dgpu-applications = Applicazioni che stanno usando la GPU discreta {$gpu_name}
dgpu-applications = Applicazioni che stanno usando la GPU discreta {$gpu_name}

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmicボタン
battery = バッテリー
battery-desc = 性能と消費は低くなります。
balanced = バランス

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Knop
battery = Batterij
battery-desc = Verminderd stroom verbruik en prestatie.
balanced = Gebalanceerd

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Przycisk Cosmic
battery = Na Baterii
battery-desc = Zmniejszone zużycie energii i zmniejszona wydajność.
balanced = Zbalansowany

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Botão Cosmic
battery = Bateria
battery-desc = Uso reduzido de energia e desempenho.
balanced = Equilibrado

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Botão Cosmic
battery = Bateria
battery-desc = Uso reduzido de energia e desempenho.
balanced = Equilibrado

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Кнопка Cosmic
battery = Аккумулятор
battery-desc = Пониженные энергопотребление и производительность.
balanced = Сбалансированный
@ -12,4 +11,4 @@ hours = ч.
until-empty = до полного разряда
power-settings = Параметры питания и аккумулятора...
dgpu-running = Дискретная видеокарта активна и может сократить время автономной работы
dgpu-applications = Приложения, использующие видеокарту {$gpu_name}
dgpu-applications = Приложения, использующие видеокарту {$gpu_name}

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Button
battery = Batéria
battery-desc = Obmedzená spotreba energie a výkonu.
balanced = Vyvážený
@ -12,4 +11,4 @@ hours = h
until-empty = pokiaľ prázdne
power-settings = Nastavenia napájania a batérie...
dgpu-running = Diskrétne GPU sa práve používa. To môže ovplyvniť životnosť batérie.
dgpu-applications = Aplikácie, ktoré používajú {$gpu_name} diskrétne GPU
dgpu-applications = Aplikácie, ktoré používajú {$gpu_name} diskrétne GPU

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic дугме
battery = Батерија
battery-desc = Смањене перформансе и потрошња батерије.
balanced = Балансирано

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic dugme
battery = Baterija
battery-desc = Smanjene performanse i potrošnja baterije.
balanced = Balansirano

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Düğmesi
battery = Pil
battery-desc = Daha az güç tüketimi ve başarım.
balanced = Dengeli

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Кнопка Cosmic
battery = Акумулятор
battery-desc = Зменшення споживання енергії та продуктивності.
balanced = Збалансовано

View file

@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic 按钮
battery = 省电
battery-desc = 降低功耗和性能
balanced = 平衡

View file

@ -17,6 +17,7 @@ use cosmic::{
token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
},
cctk::sctk::reexports::calloop,
cosmic_theme::Spacing,
iced::{
alignment::Horizontal,
wayland::popup::{destroy_popup, get_popup},
@ -27,6 +28,7 @@ use cosmic::{
iced_runtime::core::layout::Limits,
iced_style::application,
iced_widget::{Column, Row},
theme,
widget::{divider, horizontal_space, icon, scrollable, text, vertical_space},
Command, Element, Theme,
};
@ -446,6 +448,10 @@ impl cosmic::Application for CosmicBatteryApplet {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let name = text::body(fl!("battery"));
let description = text::caption(if !self.on_battery {
format!("{:.0}%", self.battery_percent)
@ -468,7 +474,9 @@ impl cosmic::Application for CosmicBatteryApplet {
.align_items(Alignment::Center),
)
.into(),
padded_control(divider::horizontal::default()).into(),
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
menu_button(
row![
column![
@ -532,7 +540,9 @@ impl cosmic::Application for CosmicBatteryApplet {
)
.on_press(Message::SelectProfile(Power::Performance))
.into(),
padded_control(divider::horizontal::default()).into(),
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
padded_control(
anim!(
//toggler
@ -546,7 +556,9 @@ impl cosmic::Application for CosmicBatteryApplet {
.width(Length::Fill),
)
.into(),
padded_control(divider::horizontal::default()).into(),
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
];
if let Some(max_screen_brightness) = self.max_screen_brightness {
@ -605,7 +617,11 @@ impl cosmic::Application for CosmicBatteryApplet {
}
}
content.push(padded_control(divider::horizontal::default()).into());
content.push(
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
);
if !self.gpus.is_empty() {
content.push(
@ -637,7 +653,11 @@ impl cosmic::Application for CosmicBatteryApplet {
)
.into(),
);
content.push(padded_control(divider::horizontal::default()).into());
content.push(
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
);
}
for (key, gpu) in &self.gpus {
@ -706,7 +726,11 @@ impl cosmic::Application for CosmicBatteryApplet {
.into(),
);
}
content.push(padded_control(divider::horizontal::default()).into());
content.push(
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s])
.into(),
);
}
content.push(

View file

@ -1,6 +1,6 @@
bluetooth = Bluetooth
other-devices = Other Bluetooth Devices
settings = Bluetooth Settings...
other-devices = Other Bluetooth devices
settings = Bluetooth settings...
connected = Connected
confirm-pin = Please confirm that the following PIN matches the one displayed on {$deviceName}
confirm = Confirm
@ -9,4 +9,4 @@ unsuccessful = Pairing Unsuccessful
check-device = Make sure {$deviceName} is turned on, in range, and is ready to pair.
try-again = Try Again
discoverable = Discoverable
pairable = Pairable
pairable = Pairable

View file

@ -9,6 +9,7 @@ use cosmic::{
use cosmic::{
applet::{menu_button, padded_control},
cosmic_theme::Spacing,
iced::{
self,
wayland::popup::{destroy_popup, get_popup},
@ -21,6 +22,7 @@ use cosmic::{
window,
},
iced_style::application,
theme,
widget::{button, divider, icon, text},
Command, Element, Theme,
};
@ -349,6 +351,10 @@ impl cosmic::Application for CosmicBluetoothApplet {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let mut known_bluetooth = vec![];
for dev in self.bluer_state.devices.iter().filter(|d| {
!self
@ -447,20 +453,21 @@ impl cosmic::Application for CosmicBluetoothApplet {
.align_items(Alignment::Center)
.padding([8, 0]);
if !known_bluetooth.is_empty() {
content = content.push(padded_control(divider::horizontal::default()));
content = content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
content = content.push(Column::with_children(known_bluetooth));
}
let dropdown_icon = if self.show_visible_devices {
"go-down-symbolic"
"go-up-symbolic"
} else {
"go-next-symbolic"
"go-down-symbolic"
};
let available_connections_btn = menu_button(row![
text::body(fl!("other-devices"))
.width(Length::Fill)
.height(Length::Fixed(24.0))
.vertical_alignment(Vertical::Center),
container(icon::from_name(dropdown_icon).size(14).symbolic(true))
container(icon::from_name(dropdown_icon).size(16).symbolic(true))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
@ -468,7 +475,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
])
.on_press(Message::ToggleVisibleDevices(!self.show_visible_devices));
if self.bluer_state.bluetooth_enabled {
content = content.push(padded_control(divider::horizontal::default()));
content = content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
content = content.push(available_connections_btn);
}
let mut list_column: Vec<Element<'_, Message>> =
@ -503,7 +511,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
.align_x(Horizontal::Center),
padded_control(
row![
button(
button::custom(
text::body(fl!("cancel"))
.vertical_alignment(Vertical::Center)
.horizontal_alignment(Horizontal::Center)
@ -512,7 +520,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
.height(Length::Fixed(28.0))
.width(Length::Fixed(105.0))
.on_press(Message::Cancel),
button(
button::custom(
text::body(fl!("confirm"))
.vertical_alignment(Vertical::Center)
.horizontal_alignment(Horizontal::Center)
@ -570,6 +578,9 @@ impl cosmic::Application for CosmicBluetoothApplet {
} else {
content = content.push(Column::with_children(list_column));
}
// content = content
// .push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]))
// .push(menu_button(text::body(fl!("settings"))).on_press(Message::OpenSettings));
self.core.applet.popup_container(content).into()
}

View file

@ -10,6 +10,7 @@ use cosmic::{
app::Core,
applet::{self},
cosmic_config::{self, ConfigSet},
cosmic_theme::Spacing,
iced::{
wayland::popup::{destroy_popup, get_popup},
widget::{column, row},
@ -20,6 +21,7 @@ use cosmic::{
iced_runtime::core::window,
iced_style::application,
prelude::*,
theme,
widget::{self, horizontal_space, vertical_space},
};
use cosmic_comp_config::CosmicCompConfig;
@ -172,7 +174,7 @@ impl cosmic::Application for Window {
.map_or(String::new(), |l| l.layout.clone()),
);
cosmic::widget::button(
cosmic::widget::button::custom(
row!(
column!(
input_source_text,
@ -200,6 +202,10 @@ impl cosmic::Application for Window {
}
fn view_window(&self, _id: Id) -> Element<Self::Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let mut content_list =
widget::column::with_capacity(4 + self.active_layouts.len()).padding([8, 0]);
for layout in &self.active_layouts {
@ -212,7 +218,9 @@ impl cosmic::Application for Window {
}
if !self.active_layouts.is_empty() {
content_list = content_list.push(
applet::padded_control(widget::divider::horizontal::default()).apply(Element::from),
applet::padded_control(widget::divider::horizontal::default())
.padding([space_xxs, space_s])
.apply(Element::from),
);
}
content_list = content_list.push(

View file

@ -30,7 +30,7 @@ where
) -> Self {
let border = 1.0;
Self {
image_button: button(
image_button: button::custom(
container(
container(if let Some(img) = img {
let max_dim = img.img.width().max(img.img.height()).max(1);

View file

@ -1,20 +1,20 @@
network = Network
airplane-mode = Airplane mode
airplane-mode-on = Airplane Mode is on
airplane-mode-on = Airplane mode is on
turn-off-airplane-mode = Turn off to enable Wi-Fi, Bluetooth and mobile broadband.
wifi = Wi-Fi
ipv4 = IPv4 Address
ipv6 = IPv6 Address
ipv4 = IPv4 address
ipv6 = IPv6 address
mac = MAC
megabits-per-second = Mbps
connected = Connected
connecting = Connecting
connect = Connect
cancel = Cancel
settings = Network Settings...
visible-wireless-networks = Visible Wireless Networks
settings = Network settings...
visible-wireless-networks = Visible wireless networks
enter-password = Enter the password or encryption key
router-wps-button = You can also connect by pressing the "WPS" button on the router
unable-to-connect = Unable to connect to network
check-wifi-connection = Make sure Wi-Fi is connected to the internet and the password is correct
reset = Reset
reset = Reset

View file

@ -7,6 +7,7 @@ use cosmic::{
token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
},
cctk::sctk::reexports::calloop,
cosmic_theme::Spacing,
iced::{
wayland::popup::{destroy_popup, get_popup},
widget::{column, row},
@ -19,6 +20,7 @@ use cosmic::{
},
iced_style::application,
iced_widget::Row,
theme,
widget::{
button, container, divider, icon, icon::from_name, scrollable, text, text_input, Column,
},
@ -548,6 +550,10 @@ impl cosmic::Application for CosmicNetworkApplet {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let mut vpn_ethernet_col = column![];
let mut known_wifi = Vec::new();
for conn in &self.nm_state.active_conns {
@ -574,7 +580,8 @@ impl cosmic::Application for CosmicNetworkApplet {
.align_items(Alignment::Center)
.spacing(8)
.padding(menu_control_padding()),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s]),
]);
}
ActiveConnectionInfo::Wired {
@ -609,7 +616,8 @@ impl cosmic::Application for CosmicNetworkApplet {
.align_items(Alignment::Center)
.spacing(8)
.padding(menu_control_padding()),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s]),
]);
}
ActiveConnectionInfo::WiFi {
@ -687,7 +695,7 @@ impl cosmic::Application for CosmicNetworkApplet {
.text_size(14)
.width(Length::Fill)
),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
anim!(
//toggler
@ -705,7 +713,7 @@ impl cosmic::Application for CosmicNetworkApplet {
if self.nm_state.airplane_mode {
content = content.push(
column!(
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
icon::from_name("airplane-mode-symbolic")
.size(48)
.symbolic(true),
@ -719,7 +727,9 @@ impl cosmic::Application for CosmicNetworkApplet {
);
} else {
if self.nm_state.wifi_enabled {
content = content.push(padded_control(divider::horizontal::default()));
content = content.push(
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
);
for known in &self.nm_state.known_access_points {
let mut btn_content = Vec::with_capacity(2);
let ssid = text::body(&known.ssid).width(Length::Fill);
@ -790,19 +800,23 @@ impl cosmic::Application for CosmicNetworkApplet {
let has_known_wifi = !known_wifi.is_empty();
content = content.push(Column::with_children(known_wifi));
if has_known_wifi {
content = content.push(padded_control(divider::horizontal::default()));
content = content.push(
padded_control(divider::horizontal::default())
.padding([space_xxs, space_s]),
);
}
let dropdown_icon = if self.show_visible_networks {
"go-down-symbolic"
"go-up-symbolic"
} else {
"go-next-symbolic"
"go-down-symbolic"
};
let available_connections_btn = menu_button(row![
text::body(fl!("visible-wireless-networks"))
.width(Length::Fill)
.height(Length::Fixed(24.0))
.vertical_alignment(Vertical::Center),
container(icon::from_name(dropdown_icon).size(14).symbolic(true))
container(icon::from_name(dropdown_icon).size(16).symbolic(true))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
@ -935,6 +949,9 @@ impl cosmic::Application for CosmicNetworkApplet {
.push(scrollable(Column::with_children(list_col)).height(Length::Fixed(300.0)));
}
}
content = content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]))
.push(menu_button(text::body(fl!("settings"))).on_press(Message::OpenSettings));
self.core
.applet

View file

@ -10,6 +10,7 @@ use cosmic::{
},
cctk::sctk::reexports::calloop,
cosmic_config::{Config, CosmicConfigEntry},
cosmic_theme::Spacing,
iced::{
wayland::popup::{destroy_popup, get_popup},
widget::{column, row},
@ -17,6 +18,7 @@ use cosmic::{
},
iced_core::alignment::Horizontal,
iced_widget::{scrollable, Column},
theme,
widget::{button, container, divider, icon, text},
Command, Element, Theme,
};
@ -364,6 +366,10 @@ impl cosmic::Application for Notifications {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let do_not_disturb = padded_control(row![anim!(
DO_NOT_DISTURB,
&self.timeline,
@ -421,7 +427,7 @@ impl cosmic::Application for Notifications {
let duration_since = text::caption(duration_ago_msg(n));
let close_notif = button(
let close_notif = button::custom(
icon::from_name("window-close-symbolic")
.size(16)
.symbolic(true),
@ -535,7 +541,7 @@ impl cosmic::Application for Notifications {
};
let main_content = column![
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
notifications,
];

View file

@ -6,6 +6,7 @@ use std::{collections::HashMap, process, time::Duration};
use cosmic::{
app::Command,
applet::{menu_button, padded_control},
cosmic_theme::Spacing,
iced,
iced::{
alignment::{Horizontal, Vertical},
@ -247,6 +248,13 @@ impl cosmic::Application for Power {
}
fn view_window(&self, id: window::Id) -> Element<Message> {
let Spacing {
space_xxs,
space_s,
space_m,
..
} = theme::active().cosmic().spacing;
if matches!(self.popup, Some(p) if p == id) {
let settings = menu_button(text::body(fl!("settings"))).on_press(Message::Settings);
@ -259,7 +267,7 @@ impl cosmic::Application for Power {
text::body(fl!("lock-screen-shortcut")),
]
.align_items(Alignment::Center)
.spacing(8)
.spacing(space_xxs)
)
.on_press(Message::Action(PowerAction::Lock)),
menu_button(
@ -270,7 +278,7 @@ impl cosmic::Application for Power {
text::body(fl!("log-out-shortcut")),
]
.align_items(Alignment::Center)
.spacing(8)
.spacing(space_xxs)
)
.on_press(Message::Action(PowerAction::LogOut)),
];
@ -283,14 +291,14 @@ impl cosmic::Application for Power {
power_buttons("system-shutdown-symbolic", fl!("shutdown"))
.on_press(Message::Action(PowerAction::Shutdown)),
]
.spacing(24)
.padding([0, 24]);
.spacing(space_m)
.padding([0, space_m]);
let content = column![
settings,
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
session,
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
power
]
.align_items(Alignment::Start)
@ -319,7 +327,7 @@ impl cosmic::Application for Power {
HashMap::from_iter(vec![("action", action), ("countdown", countdown)])
))
.primary_action(
button(min_width_and_height(
button::custom(min_width_and_height(
text::body(fl!("confirm", HashMap::from_iter(vec![("action", action)])))
.into(),
142.0,
@ -331,7 +339,7 @@ impl cosmic::Application for Power {
.on_press(Message::Confirm),
)
.secondary_action(
button(min_width_and_height(
button::custom(min_width_and_height(
text::body(fl!("cancel")).into(),
142.0,
32.0,
@ -380,7 +388,7 @@ impl cosmic::Application for Power {
}
fn power_buttons(name: &str, msg: String) -> cosmic::widget::Button<Message> {
cosmic::widget::button(
button::custom(
column![text_icon(name, 40), text::body(msg)]
.spacing(4)
.align_items(Alignment::Center)

View file

@ -7,8 +7,9 @@ use crate::{
use cctk::sctk::reexports::calloop::channel::SyncSender;
use cosmic::{
app::Core,
applet::padded_control,
applet::{menu_button, padded_control},
cosmic_config::{Config, ConfigSet, CosmicConfigEntry},
cosmic_theme::Spacing,
iced::{
wayland::popup::{destroy_popup, get_popup},
window::Id,
@ -16,9 +17,10 @@ use cosmic::{
},
iced_style::application,
iced_widget::{column, row},
theme,
widget::{
container, divider, segmented_button,
segmented_button::{Entity, SingleSelectModel},
container, divider,
segmented_button::{self, Entity, SingleSelectModel},
segmented_control, spin_button, text,
},
Element, Theme,
@ -58,6 +60,7 @@ pub enum Message {
MyConfigUpdate(Box<CosmicCompConfig>),
WorkspaceUpdate(WorkspacesUpdate),
NewWorkspace(Entity),
OpenSettings,
}
impl cosmic::Application for Window {
@ -267,6 +270,11 @@ impl cosmic::Application for Window {
}
});
}
Message::OpenSettings => {
let mut cmd = std::process::Command::new("cosmic-settings");
cmd.arg("window-management");
tokio::spawn(cosmic::process::spawn(cmd));
}
}
Command::none()
}
@ -280,6 +288,13 @@ impl cosmic::Application for Window {
}
fn view_window(&self, _id: Id) -> Element<Self::Message> {
let Spacing {
space_xxxs,
space_xxs,
space_s,
..
} = theme::active().cosmic().spacing;
let new_workspace_behavior_button =
segmented_control::horizontal(&self.new_workspace_behavior_model)
.on_activate(Message::NewWorkspace);
@ -296,12 +311,15 @@ impl cosmic::Application for Window {
.width(Length::Fill),
))
.width(Length::Fill),
padded_control(divider::horizontal::default(),),
padded_control(column![
text::body(fl!("new-workspace")),
new_workspace_behavior_button,
]),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
column![
text::body(fl!("new-workspace")),
new_workspace_behavior_button,
]
.spacing(space_xxxs)
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(row!(
text::body(fl!("navigate-windows")).width(Length::Fill),
text::body(format!("{} + {}", fl!("super"), fl!("arrow-keys"))),
@ -319,7 +337,7 @@ impl cosmic::Application for Window {
text::body(fl!("toggle-floating-window")).width(Length::Fill),
text::body(format!("{} + G", fl!("super"))),
)),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
anim!(
self.active_hint,
@ -331,6 +349,9 @@ impl cosmic::Application for Window {
.text_size(14)
.width(Length::Fill),
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
menu_button(text::body(fl!("window-management-settings")))
.on_press(Message::OpenSettings)
]
.padding([8, 0]);

View file

@ -1,13 +1,14 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use std::{borrow::Cow, str::FromStr};
use std::str::FromStr;
use chrono::{Datelike, Timelike};
use cosmic::{
app,
applet::{cosmic_panel_config::PanelAnchor, menu_button, padded_control},
cctk::sctk::reexports::calloop,
cosmic_theme::Spacing,
iced::{
futures::{channel::mpsc, SinkExt, StreamExt, TryFutureExt},
subscription,
@ -18,6 +19,7 @@ use cosmic::{
iced_core::alignment::{Horizontal, Vertical},
iced_style::application,
iced_widget::{horizontal_rule, Column},
theme,
widget::{
button, container, divider, grid, horizontal_space, icon, rectangle_tracker::*, text,
Button, Grid, Space,
@ -432,7 +434,7 @@ impl cosmic::Application for Window {
PanelAnchor::Top | PanelAnchor::Bottom
);
let button = cosmic::widget::button(if horizontal {
let button = button::custom(if horizontal {
let mut bag = Bag::empty();
if self.config.show_date_in_top_panel {
@ -547,6 +549,10 @@ impl cosmic::Application for Window {
}
fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;
let mut date_bag = Bag::empty();
date_bag.month = Some(components::Month::Long);
date_bag.day = Some(components::Day::NumericDayOfMonth);
@ -622,7 +628,7 @@ impl cosmic::Application for Window {
.align_items(Alignment::Center)
.padding([12, 20]),
calender.padding([0, 12].into()),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
menu_button(text::body(fl!("datetime-settings")))
.on_press(Message::OpenDateTimeSettings),
]
@ -641,14 +647,13 @@ impl cosmic::Application for Window {
fn date_button(day: u32, is_month: bool, is_day: bool) -> Button<'static, Message> {
let style = if is_day {
cosmic::widget::button::Style::Suggested
button::Style::Suggested
} else {
cosmic::widget::button::Style::Text
button::Style::Text
};
let button = button(
text(format!("{day}"))
.size(14.0)
let button = button::custom(
text::body(format!("{day}"))
.horizontal_alignment(Horizontal::Center)
.vertical_alignment(Vertical::Center),
)

View file

@ -123,7 +123,7 @@ impl cosmic::Application for Button {
))
)
.align_items(iced::Alignment::Center);
cosmic::widget::button(content)
cosmic::widget::button::custom(content)
.padding([0, self.core.applet.suggested_padding(true)])
.style(cosmic::theme::Button::AppletIcon)
}