Switch back to libcosmic upstream

This commit is contained in:
Eduardo Flores 2023-09-18 08:31:27 -07:00 committed by Ashley Wulber
parent c7b25daa71
commit 276ecc7d6c
19 changed files with 247 additions and 232 deletions

113
Cargo.lock generated
View file

@ -904,43 +904,20 @@ dependencies = [
"wayland-client 0.30.2",
]
[[package]]
name = "cosmic-config"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
dependencies = [
"atomicwrites",
"cosmic-config-derive 0.1.0 (git+https://github.com/edfloreshz/libcosmic)",
"dirs 5.0.1",
"iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)",
"notify",
"ron",
"serde",
]
[[package]]
name = "cosmic-config"
version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789"
dependencies = [
"atomicwrites",
"cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic)",
"cosmic-config-derive",
"dirs 5.0.1",
"iced_futures 0.7.0 (git+https://github.com/pop-os/libcosmic)",
"iced_futures",
"notify",
"ron",
"serde",
]
[[package]]
name = "cosmic-config-derive"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
dependencies = [
"quote",
"syn 1.0.109",
]
[[package]]
name = "cosmic-config-derive"
version = "0.1.0"
@ -966,16 +943,16 @@ dependencies = [
[[package]]
name = "cosmic-notifications-config"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/cosmic-notifications#58e948e6260d2088a7da9128173c76b9cb6db7f3"
source = "git+https://github.com/pop-os/cosmic-notifications#e42d4a0e3ef00dbe2d1478d7563cbe326f6b8311"
dependencies = [
"cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)",
"cosmic-config",
"serde",
]
[[package]]
name = "cosmic-notifications-util"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/cosmic-notifications#58e948e6260d2088a7da9128173c76b9cb6db7f3"
source = "git+https://github.com/pop-os/cosmic-notifications#e42d4a0e3ef00dbe2d1478d7563cbe326f6b8311"
dependencies = [
"bytemuck",
"fast_image_resize",
@ -999,7 +976,7 @@ version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-panel#7b56316ddcdd3e921b61cf3fe3f69b4bcae437d3"
dependencies = [
"anyhow",
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic)",
"cosmic-config",
"ron",
"serde",
"tracing",
@ -1043,10 +1020,10 @@ dependencies = [
[[package]]
name = "cosmic-theme"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"almost",
"cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)",
"cosmic-config",
"csscolorparser",
"lazy_static",
"palette",
@ -1057,7 +1034,7 @@ dependencies = [
[[package]]
name = "cosmic-time"
version = "0.3.0"
source = "git+https://github.com/edfloreshz/cosmic-time#dfe7211c5c402685cc361b17a148574f37d86df2"
source = "git+https://github.com/pop-os/cosmic-time#71116b2eefb536bedbd3438e70cba49d54c3a5d5"
dependencies = [
"float-cmp",
"libcosmic",
@ -2383,11 +2360,11 @@ dependencies = [
[[package]]
name = "iced"
version = "0.10.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"iced_accessibility",
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"iced_futures",
"iced_renderer",
"iced_sctk",
"iced_widget",
@ -2398,7 +2375,7 @@ dependencies = [
[[package]]
name = "iced_accessibility"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"accesskit",
"accesskit_unix",
@ -2407,7 +2384,7 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.10.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789"
dependencies = [
"bitflags 1.3.2",
"iced_accessibility",
@ -2419,53 +2396,29 @@ dependencies = [
"twox-hash",
]
[[package]]
name = "iced_core"
version = "0.10.0"
source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789"
dependencies = [
"bitflags 1.3.2",
"instant",
"log",
"thiserror",
"twox-hash",
]
[[package]]
name = "iced_futures"
version = "0.7.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789"
dependencies = [
"futures",
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"log",
"tokio",
"wasm-bindgen-futures",
"wasm-timer",
]
[[package]]
name = "iced_futures"
version = "0.7.0"
source = "git+https://github.com/pop-os/libcosmic#b404497e7636d44ba0fffa9b88e26f5b76d2b789"
dependencies = [
"futures",
"iced_core 0.10.0 (git+https://github.com/pop-os/libcosmic)",
"log",
"wasm-bindgen-futures",
"wasm-timer",
]
[[package]]
name = "iced_graphics"
version = "0.9.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"bitflags 1.3.2",
"bytemuck",
"glam",
"half",
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"image",
"kamadak-exif",
"log",
@ -2476,7 +2429,7 @@ dependencies = [
[[package]]
name = "iced_renderer"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"iced_graphics",
"iced_tiny_skia",
@ -2489,11 +2442,11 @@ dependencies = [
[[package]]
name = "iced_runtime"
version = "0.1.1"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"iced_accessibility",
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"iced_futures",
"smithay-client-toolkit 0.17.0",
"thiserror",
]
@ -2501,12 +2454,12 @@ dependencies = [
[[package]]
name = "iced_sctk"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"enum-repr",
"float-cmp",
"futures",
"iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_futures",
"iced_graphics",
"iced_runtime",
"iced_style",
@ -2523,9 +2476,9 @@ dependencies = [
[[package]]
name = "iced_style"
version = "0.9.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"once_cell",
"palette",
]
@ -2533,7 +2486,7 @@ dependencies = [
[[package]]
name = "iced_tiny_skia"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"bytemuck",
"cosmic-text",
@ -2551,7 +2504,7 @@ dependencies = [
[[package]]
name = "iced_wgpu"
version = "0.11.1"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"bitflags 1.3.2",
"bytemuck",
@ -2572,7 +2525,7 @@ dependencies = [
[[package]]
name = "iced_widget"
version = "0.1.3"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"iced_renderer",
"iced_runtime",
@ -2838,19 +2791,19 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "libcosmic"
version = "0.1.0"
source = "git+https://github.com/edfloreshz/libcosmic#5167c6ba4b155d8110415e1bb53247f1445a95ae"
source = "git+https://github.com/pop-os/libcosmic#453cc6588e6d849318e704e4626913dc8894e243"
dependencies = [
"apply",
"ashpd",
"cosmic-config 0.1.0 (git+https://github.com/edfloreshz/libcosmic)",
"cosmic-config",
"cosmic-panel-config",
"cosmic-theme",
"derive_setters",
"fraction",
"freedesktop-icons",
"iced",
"iced_core 0.10.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_futures 0.7.0 (git+https://github.com/edfloreshz/libcosmic)",
"iced_core",
"iced_futures",
"iced_renderer",
"iced_runtime",
"iced_sctk",

View file

@ -23,11 +23,11 @@ cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-c
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default-features = false, features = [
"client",
], rev = "e39748e" }
cosmic-time = { git = "https://github.com/edfloreshz/cosmic-time", default-features = false, features = [
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features = false, features = [
"libcosmic",
"once_cell",
] }
libcosmic = { git = "https://github.com/edfloreshz/libcosmic", default-features = false, features = [
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
"applet",
"tokio",
"wayland",

View file

@ -9,10 +9,6 @@ use cctk::sctk::reexports::calloop::channel::Sender;
use cctk::toplevel_info::ToplevelInfo;
use cctk::wayland_client::protocol::wl_data_device_manager::DndAction;
use cctk::wayland_client::protocol::wl_seat::WlSeat;
use cosmic::app::{
applet::{cosmic_panel_config::PanelAnchor, CosmicAppletHelper},
Command,
};
use cosmic::cosmic_config;
use cosmic::cosmic_config::Config;
use cosmic::iced;
@ -40,6 +36,10 @@ use cosmic::widget::divider;
use cosmic::widget::rectangle_tracker::rectangle_tracker_subscription;
use cosmic::widget::rectangle_tracker::RectangleTracker;
use cosmic::widget::rectangle_tracker::RectangleUpdate;
use cosmic::{
applet::{cosmic_panel_config::PanelAnchor, Context},
Command,
};
use cosmic::{Element, Theme};
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
use freedesktop_desktop_entry::DesktopEntry;
@ -61,7 +61,7 @@ use url::Url;
static MIME_TYPE: &str = "text/uri-list";
pub fn run() -> cosmic::iced::Result {
cosmic::app::applet::run::<CosmicAppList>(true, ())
cosmic::applet::run::<CosmicAppList>(true, ())
}
#[derive(Debug, Clone, Default)]
@ -102,7 +102,7 @@ impl DockItem {
fn as_icon(
&self,
applet_helper: &CosmicAppletHelper,
applet: &Context,
rectangle_tracker: Option<&RectangleTracker<u32>>,
interaction_enabled: bool,
) -> Element<'_, Message> {
@ -115,7 +115,7 @@ impl DockItem {
let cosmic_icon = cosmic::widget::icon::from_path(PathBuf::from(&desktop_info.icon))
.icon()
.size(applet_helper.suggested_size().0);
.size(applet.suggested_size().0);
let dot_radius = 2;
let dots = (0..toplevels.len())
@ -138,7 +138,7 @@ impl DockItem {
.into()
})
.collect_vec();
let icon_wrapper: Element<_> = match applet_helper.anchor {
let icon_wrapper: Element<_> = match applet.anchor {
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), cosmic_icon.into()])
.align_items(iced::Alignment::Center)
.spacing(4)
@ -373,7 +373,10 @@ impl cosmic::Application for CosmicAppList {
type Flags = ();
const APP_ID: &'static str = config::APP_ID;
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (Self, iced::Command<cosmic::app::Message<Self::Message>>) {
let config = config::AppListConfig::load().unwrap_or_default();
let mut self_ = CosmicAppList {
core,
@ -402,7 +405,10 @@ impl cosmic::Application for CosmicAppList {
&mut self.core
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::Popup(id) => {
if let Some((popup_id, _toplevel)) = self.popup.take() {
@ -423,7 +429,7 @@ impl cosmic::Application for CosmicAppList {
let new_id = window::Id(self.surface_id_ctr);
self.popup = Some((new_id, toplevel_group.clone()));
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -564,8 +570,8 @@ impl cosmic::Application for CosmicAppList {
}
}
Message::DndEnter(x, y) => {
let item_size = self.core.applet_helper.suggested_size().0;
let pos_in_list = match self.core.applet_helper.anchor {
let item_size = self.core.applet.suggested_size().0;
let pos_in_list = match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => x,
PanelAnchor::Left | PanelAnchor::Right => y,
};
@ -595,8 +601,8 @@ impl cosmic::Application for CosmicAppList {
}
Message::DndMotion(x, y) => {
if let Some(DndOffer { preview_index, .. }) = self.dnd_offer.as_mut() {
let item_size = self.core.applet_helper.suggested_size().0;
let pos_in_list = match self.core.applet_helper.anchor {
let item_size = self.core.applet.suggested_size().0;
let pos_in_list = match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => x,
PanelAnchor::Left | PanelAnchor::Right => y,
};
@ -853,7 +859,7 @@ impl cosmic::Application for CosmicAppList {
}
fn view(&self) -> Element<Message> {
let is_horizontal = match self.core.applet_helper.anchor {
let is_horizontal = match self.core.applet.anchor {
PanelAnchor::Top | PanelAnchor::Bottom => true,
PanelAnchor::Left | PanelAnchor::Right => false,
};
@ -862,7 +868,7 @@ impl cosmic::Application for CosmicAppList {
.iter()
.map(|dock_item| {
dock_item.as_icon(
&self.core.applet_helper,
&self.core.applet,
self.rectangle_tracker.as_ref(),
self.popup.is_none(),
)
@ -874,13 +880,13 @@ impl cosmic::Application for CosmicAppList {
.as_ref()
.and_then(|o| o.dock_item.as_ref().map(|item| (item, o.preview_index)))
{
favorites.insert(index, item.as_icon(&self.core.applet_helper, None, false));
favorites.insert(index, item.as_icon(&self.core.applet, None, false));
} else if self.is_listening_for_dnd && self.favorite_list.is_empty() {
// show star indicating favorite_list is drag target
favorites.push(
container(
cosmic::widget::icon::from_name("starred-symbolic.symbolic")
.size(self.core.applet_helper.suggested_size().0),
.size(self.core.applet.suggested_size().0),
)
.padding(8)
.into(),
@ -892,7 +898,7 @@ impl cosmic::Application for CosmicAppList {
.iter()
.map(|dock_item| {
dock_item.as_icon(
&self.core.applet_helper,
&self.core.applet,
self.rectangle_tracker.as_ref(),
self.popup.is_none(),
)
@ -906,7 +912,7 @@ impl cosmic::Application for CosmicAppList {
dnd_listener(row(favorites)),
row(active).into(),
container(vertical_rule(1))
.height(self.core.applet_helper.suggested_size().1)
.height(self.core.applet.suggested_size().1)
.into(),
)
} else {
@ -916,7 +922,7 @@ impl cosmic::Application for CosmicAppList {
dnd_listener(column(favorites)),
column(active).into(),
container(divider::horizontal::light())
.width(self.core.applet_helper.suggested_size().1)
.width(self.core.applet.suggested_size().1)
.into(),
)
};
@ -963,12 +969,12 @@ impl cosmic::Application for CosmicAppList {
} else {
vec![
cosmic::widget::icon::from_name("com.system76.CosmicAppList")
.size(self.core.applet_helper.suggested_size().0)
.size(self.core.applet.suggested_size().0)
.into(),
]
};
let content = match &self.core.applet_helper.anchor {
let content = match &self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => container(
Column::with_children(content_list)
.spacing(4)
@ -998,7 +1004,7 @@ impl cosmic::Application for CosmicAppList {
if let Some((_, item, _)) = self.dnd_source.as_ref().filter(|s| s.0 == id) {
cosmic::widget::icon::from_path(PathBuf::from(&item.desktop_info.icon))
.icon()
.size(self.core.applet_helper.suggested_size().0)
.size(self.core.applet.suggested_size().0)
.into()
} else if let Some((
_popup_id,
@ -1065,7 +1071,7 @@ impl cosmic::Application for CosmicAppList {
.on_press(Message::Quit(desktop_info.id.clone())),
),
};
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
} else {
iced::widget::text("").into()
}
@ -1124,7 +1130,7 @@ impl cosmic::Application for CosmicAppList {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {

View file

@ -5,7 +5,7 @@ use cosmic::iced::widget;
use cosmic::iced::Limits;
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::app::applet::applet_button_theme;
use cosmic::applet::button_theme;
use cosmic::widget::{button, divider, icon};
use cosmic::Renderer;
@ -32,7 +32,7 @@ pub fn main() -> cosmic::iced::Result {
// Prepare i18n
localize();
cosmic::app::applet::run::<Audio>(false, ())
cosmic::applet::run::<Audio>(false, ())
}
static SHOW_MEDIA_CONTROLS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
@ -160,7 +160,7 @@ impl cosmic::Application for Audio {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn update(&mut self, message: Message) -> Command<Message> {
@ -177,7 +177,7 @@ impl cosmic::Application for Audio {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -338,7 +338,7 @@ impl cosmic::Application for Audio {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -459,17 +459,14 @@ impl cosmic::Application for Audio {
.padding([12, 24])
.width(Length::Fill),
button(text(fl!("sound-settings")).size(14))
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.width(Length::Fill)
]
.align_items(Alignment::Start)
.padding([8, 0]);
self.core
.applet_helper
.popup_container(container(content))
.into()
self.core.applet.popup_container(container(content)).into()
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {
@ -491,7 +488,7 @@ fn revealer(
|col, (id, name)| {
col.push(
button(text(name).size(14))
.style(applet_button_theme())
.style(button_theme())
.on_press(change(id.clone()))
.width(Length::Fill)
.padding([8, 48]),
@ -513,7 +510,7 @@ fn revealer_head(
text(title).width(Length::Fill).size(14),
text(selected).size(10),
])
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.width(Length::Fill)
.on_press(toggle)

View file

@ -10,7 +10,6 @@ use crate::upower_device::{device_subscription, DeviceDbusEvent};
use crate::upower_kbdbacklight::{
kbd_backlight_subscription, KeyboardBacklightRequest, KeyboardBacklightUpdate,
};
use cosmic::app::{applet::applet_button_theme, Command};
use cosmic::iced::alignment::Horizontal;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::{
@ -20,6 +19,7 @@ use cosmic::iced::{
use cosmic::iced_runtime::core::layout::Limits;
use cosmic::iced_style::application;
use cosmic::widget::{button, divider, icon};
use cosmic::{applet::button_theme, Command};
use cosmic::{Element, Theme};
use cosmic_time::{anim, chain, id, once_cell::sync::Lazy, Instant, Timeline};
@ -44,7 +44,7 @@ fn format_duration(duration: Duration) -> String {
}
pub fn run() -> cosmic::iced::Result {
cosmic::app::applet::run::<CosmicBatteryApplet>(false, ())
cosmic::applet::run::<CosmicBatteryApplet>(false, ())
}
static MAX_CHARGE: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
@ -153,7 +153,13 @@ impl cosmic::Application for CosmicBatteryApplet {
type Flags = ();
const APP_ID: &'static str = config::APP_ID;
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (
Self,
cosmic::iced::Command<cosmic::app::Message<Self::Message>>,
) {
(
CosmicBatteryApplet {
core,
@ -173,7 +179,10 @@ impl cosmic::Application for CosmicBatteryApplet {
&mut self.core
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> cosmic::iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::Frame(now) => self.timeline.now(now),
Message::SetKbdBrightness(brightness) => {
@ -213,7 +222,7 @@ impl cosmic::Application for CosmicBatteryApplet {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -284,7 +293,7 @@ impl cosmic::Application for CosmicBatteryApplet {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -304,7 +313,7 @@ impl cosmic::Application for CosmicBatteryApplet {
})
.size(10);
self.core
.applet_helper
.applet
.popup_container(
column![
row![
@ -330,7 +339,7 @@ impl cosmic::Application for CosmicBatteryApplet {
]
.align_items(Alignment::Center)
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectProfile(Power::Battery))
.width(Length::Fill),
@ -347,7 +356,7 @@ impl cosmic::Application for CosmicBatteryApplet {
]
.align_items(Alignment::Center)
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectProfile(Power::Balanced))
.width(Length::Fill),
@ -364,7 +373,7 @@ impl cosmic::Application for CosmicBatteryApplet {
]
.align_items(Alignment::Center)
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectProfile(Power::Performance))
.width(Length::Fill),
@ -424,7 +433,7 @@ impl cosmic::Application for CosmicBatteryApplet {
.width(Length::Fill)
.padding([0, 12]),
button(text(fl!("power-settings")).size(14).width(Length::Fill))
.style(applet_button_theme())
.style(button_theme())
.on_press(Message::OpenBatterySettings)
.width(Length::Fill)
.padding([8, 24])
@ -472,6 +481,6 @@ impl cosmic::Application for CosmicBatteryApplet {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
}

View file

@ -1,6 +1,6 @@
use crate::bluetooth::{BluerDeviceStatus, BluerRequest, BluerState};
use cosmic::app::{applet::applet_button_theme, Command};
use cosmic::widget::button::StyleSheet;
use cosmic::{applet::button_theme, Command};
use cosmic::{
iced::{
self,
@ -26,7 +26,7 @@ use crate::bluetooth::{bluetooth_subscription, BluerDevice, BluerEvent};
use crate::{config, fl};
pub fn run() -> cosmic::iced::Result {
cosmic::app::applet::run::<CosmicBluetoothApplet>(false, ())
cosmic::applet::run::<CosmicBluetoothApplet>(false, ())
}
#[derive(Default)]
@ -71,7 +71,10 @@ impl cosmic::Application for CosmicBluetoothApplet {
type Flags = ();
const APP_ID: &'static str = config::APP_ID;
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (Self, iced::Command<cosmic::app::Message<Self::Message>>) {
(
CosmicBluetoothApplet {
core,
@ -90,7 +93,10 @@ impl cosmic::Application for CosmicBluetoothApplet {
&mut self.core
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
@ -101,7 +107,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -283,7 +289,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -348,7 +354,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
known_bluetooth = known_bluetooth.push(
button(row)
.style(applet_button_theme())
.style(button_theme())
.on_press(match dev.status {
BluerDeviceStatus::Connected => {
Message::Request(BluerRequest::DisconnectDevice(dev.address))
@ -496,7 +502,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
.spacing(12);
visible_devices = visible_devices.push(
button(row.width(Length::Fill))
.style(applet_button_theme())
.style(button_theme())
.on_press(Message::Request(BluerRequest::PairDevice(
dev.address.clone(),
)))
@ -520,7 +526,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
} else {
content = content.push(Column::with_children(list_column));
}
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
}
fn subscription(&self) -> Subscription<Message> {
@ -528,7 +534,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {

View file

@ -8,5 +8,5 @@ use window::*;
pub fn main() -> cosmic::iced::Result {
localize::localize();
cosmic::app::applet::run::<Window>(true, ())
cosmic::applet::run::<Window>(true, ())
}

View file

@ -1,16 +1,16 @@
use crate::dbus::{self, PowerDaemonProxy};
use crate::fl;
use crate::graphics::{get_current_graphics, set_graphics, Graphics};
use cosmic::app::{
applet::{applet_button_theme, cosmic_panel_config::PanelAnchor},
Command,
};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_runtime::core::Alignment;
use cosmic::iced_style::application;
use cosmic::theme::Button;
use cosmic::widget::icon;
use cosmic::{
applet::{button_theme, cosmic_panel_config::PanelAnchor},
Command,
};
use cosmic::{
iced::widget::{column, container, row, text},
iced::{self, Length},
@ -66,7 +66,10 @@ impl cosmic::Application for Window {
type Message = Message;
const APP_ID: &'static str = ID;
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (Self, iced::Command<cosmic::app::Message<Self::Message>>) {
let window = Window {
core,
..Default::default()
@ -87,7 +90,10 @@ impl cosmic::Application for Window {
&mut self.core
}
fn update(&mut self, message: Message) -> Command<Self::Message> {
fn update(
&mut self,
message: Self::Message,
) -> iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::SelectGraphicsMode(new) => {
if let Some((_, proxy)) = self.dbus.as_ref() {
@ -120,7 +126,7 @@ impl cosmic::Application for Window {
|cur_graphics| Message::CurrentGraphics(cur_graphics.ok()),
));
}
let popup_settings = self.core.applet_helper.get_popup_settings(
let popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -210,10 +216,10 @@ impl cosmic::Application for Window {
}
fn view(&self) -> Element<Message> {
match self.core.applet_helper.anchor {
match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => self
.core
.applet_helper
.applet
.icon_button(ID)
.on_press(Message::TogglePopup)
.style(Button::Text)
@ -221,7 +227,7 @@ impl cosmic::Application for Window {
PanelAnchor::Top | PanelAnchor::Bottom => button(
row![
icon::from_name(ID)
.size(self.core.applet_helper.suggested_size().0)
.size(self.core.applet.suggested_size().0)
.symbolic(true),
text(match self.graphics_mode.map(|g| g.inner()) {
Some(Graphics::Integrated) => fl!("integrated"),
@ -233,7 +239,7 @@ impl cosmic::Application for Window {
.size(14)
]
.spacing(8)
.padding([0, self.core.applet_helper.suggested_size().0 / 2])
.padding([0, self.core.applet.suggested_size().0 / 2])
.align_items(Alignment::Center),
)
.style(Button::Standard)
@ -276,7 +282,7 @@ impl cosmic::Application for Window {
]
.align_items(Alignment::Center),
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Integrated))
.width(Length::Fill)
@ -298,7 +304,7 @@ impl cosmic::Application for Window {
]
.align_items(Alignment::Center),
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Nvidia))
.width(Length::Fill)
@ -323,7 +329,7 @@ impl cosmic::Application for Window {
]
.align_items(Alignment::Center),
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Hybrid))
.width(Length::Fill)
@ -348,7 +354,7 @@ impl cosmic::Application for Window {
]
.align_items(Alignment::Center),
)
.style(applet_button_theme())
.style(button_theme())
.padding([8, 24])
.on_press(Message::SelectGraphicsMode(Graphics::Compute))
.width(Length::Fill)
@ -356,7 +362,7 @@ impl cosmic::Application for Window {
];
self.core
.applet_helper
.applet
.popup_container(
column(vec![
text(fl!("graphics-mode"))
@ -377,7 +383,7 @@ impl cosmic::Application for Window {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {

View file

@ -36,7 +36,7 @@ use crate::{
};
pub fn run() -> cosmic::iced::Result {
cosmic::app::applet::run::<CosmicNetworkApplet>(false, ())
cosmic::applet::run::<CosmicNetworkApplet>(false, ())
}
#[derive(Debug)]
@ -220,7 +220,7 @@ impl cosmic::Application for CosmicNetworkApplet {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -398,7 +398,7 @@ impl cosmic::Application for CosmicNetworkApplet {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -781,7 +781,7 @@ impl cosmic::Application for CosmicNetworkApplet {
.push(scrollable(Column::with_children(list_col)).height(Length::Fixed(300.0)));
}
}
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
}
fn subscription(&self) -> Subscription<Message> {
@ -808,7 +808,7 @@ impl cosmic::Application for CosmicNetworkApplet {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {

View file

@ -9,19 +9,30 @@ anyhow = "1"
libcosmic.workspace = true
cosmic-time.workspace = true
nix = "0.26"
tokio = { version = "1.24.1", features = ["sync", "rt", "tracing", "macros", "net", "io-util", "io-std"] }
cosmic-notifications-util = { git = "https://github.com/edfloreshz/cosmic-notifications" }
cosmic-notifications-config = { git = "https://github.com/edfloreshz/cosmic-notifications" }
tokio = { version = "1.24.1", features = [
"sync",
"rt",
"tracing",
"macros",
"net",
"io-util",
"io-std",
] }
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications" }
cosmic-notifications-config = { git = "https://github.com/pop-os/cosmic-notifications" }
# cosmic-notifications-util = { path = "../../cosmic-notifications-daemon/cosmic-notifications-util" }
# cosmic-notifications-config = { path = "../../cosmic-notifications-daemon/cosmic-notifications-config" }
tracing = "0.1"
ron = "0.8"
sendfd = { version = "0.4", features = [ "tokio" ] }
sendfd = { version = "0.4", features = ["tokio"] }
bytemuck = "1"
tracing-subscriber = "0.3"
zbus = {version = "3.14", features = [ "tokio" ]}
zbus = { version = "3.14", features = ["tokio"] }
# Application i18n
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
i18n-embed = { version = "0.13.4", features = [
"fluent-system",
"desktop-requester",
] }
i18n-embed-fl = "0.6.4"
rust-embed = "6.3.0"
rust-embed-utils = "7.5.0"

View file

@ -1,7 +1,6 @@
mod localize;
mod subscriptions;
use cosmic::app::{applet::applet_button_theme, Command};
use cosmic::cosmic_config::{config_subscription, Config, CosmicConfigEntry};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::Limits;
@ -10,6 +9,7 @@ use cosmic::iced::{
window, Alignment, Length, Subscription,
};
use cosmic::iced_core::alignment::Horizontal;
use cosmic::{applet::button_theme, Command};
use cosmic::iced_style::application;
@ -35,7 +35,7 @@ pub async fn main() -> cosmic::iced::Result {
info!("Notifications applet");
cosmic::app::applet::run::<Notifications>(false, ())
cosmic::applet::run::<Notifications>(false, ())
}
static DO_NOT_DISTURB: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
@ -99,7 +99,13 @@ impl cosmic::Application for Notifications {
type Flags = ();
const APP_ID: &'static str = "com.system76.CosmicAppletNotifications";
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (
Self,
cosmic::iced::Command<cosmic::app::Message<Self::Message>>,
) {
let helper = Config::new(
cosmic_notifications_config::ID,
NotificationsConfig::version(),
@ -136,7 +142,7 @@ impl cosmic::Application for Notifications {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn subscription(&self) -> Subscription<Message> {
@ -163,7 +169,10 @@ impl cosmic::Application for Notifications {
])
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> cosmic::iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::Frame(now) => {
self.timeline.now(now);
@ -176,7 +185,7 @@ impl cosmic::Application for Notifications {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -306,7 +315,7 @@ impl cosmic::Application for Notifications {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -488,7 +497,7 @@ impl cosmic::Application for Notifications {
.spacing(12)
.padding([16, 0]);
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {
@ -506,7 +515,7 @@ fn row_button(content: Vec<Element<Message>>) -> cosmic::widget::Button<Message,
.width(Length::Fill)
.height(Length::Fixed(36.0))
.padding([0, 24])
.style(applet_button_theme())
.style(button_theme())
}
fn text_icon(name: &str, size: u16) -> cosmic::widget::Icon {

View file

@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::process;
use std::time::Duration;
use cosmic::app::applet::applet_button_theme;
use cosmic::applet::button_theme;
use cosmic::iced;
use cosmic::iced::alignment::{Horizontal, Vertical};
use cosmic::iced::event::wayland::{self, LayerEvent};
@ -44,7 +44,7 @@ use crate::session_manager::SessionManagerProxy;
pub fn main() -> cosmic::iced::Result {
localize::localize();
cosmic::app::applet::run::<Power>(false, ())
cosmic::applet::run::<Power>(false, ())
}
#[derive(Default)]
@ -128,7 +128,7 @@ impl cosmic::Application for Power {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -225,7 +225,7 @@ impl cosmic::Application for Power {
fn view(&self) -> Element<Message> {
self.core
.applet_helper
.applet
.icon_button(&self.icon_name)
.on_press(Message::TogglePopup)
.into()
@ -279,7 +279,7 @@ impl cosmic::Application for Power {
.spacing(12)
.padding([8, 0]);
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
} else if matches!(self.action_to_confirm, Some((c_id, _)) if c_id == id) {
let action = match self.action_to_confirm.as_ref().unwrap().1 {
PowerAction::Lock => "lock-screen",
@ -344,7 +344,7 @@ impl cosmic::Application for Power {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
}
@ -356,7 +356,7 @@ fn row_button(content: Vec<Element<Message>>) -> cosmic::widget::Button<Message,
.spacing(4)
.align_items(Alignment::Center),
)
.style(applet_button_theme())
.style(button_theme())
.width(Length::Fill)
.padding([8, 24])
}

View file

@ -50,7 +50,7 @@ impl App {
}
fn resize_window(&self) -> Command<Msg> {
let icon_size = self.core.applet_helper.suggested_size().0 as u32 + APPLET_PADDING * 2;
let icon_size = self.core.applet.suggested_size().0 as u32 + APPLET_PADDING * 2;
let n = self.menus.len() as u32;
resize_window(window::Id(0), 1.max(icon_size * n), icon_size)
}
@ -81,7 +81,7 @@ impl cosmic::Application for App {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(app::applet::style())
Some(cosmic::applet::style())
}
fn update(&mut self, message: Msg) -> Command<Msg> {
@ -144,7 +144,7 @@ impl cosmic::Application for App {
if self.open_menu.is_some() {
if self.popup.is_none() {
let id = self.next_popup_id();
let popup_settings = self.core.applet_helper.get_popup_settings(
let popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
id,
None,
@ -181,7 +181,7 @@ impl cosmic::Application for App {
.iter()
.map(|(id, menu)| {
self.core
.applet_helper
.applet
.icon_button(menu.icon_name())
.on_press(Msg::TogglePopup(*id))
.into()
@ -196,7 +196,7 @@ impl cosmic::Application for App {
Some(id) => match self.menus.get(&id) {
Some(menu) => self
.core
.applet_helper
.applet
.popup_container(menu.popup_view().map(move |msg| Msg::StatusMenu((id, msg))))
.into(),
None => unreachable!(),
@ -211,5 +211,5 @@ impl cosmic::Application for App {
}
pub fn main() -> iced::Result {
app::applet::run::<App>(true, ())
cosmic::applet::run::<App>(true, ())
}

View file

@ -1,4 +1,4 @@
use cosmic::app::applet::applet_button_theme;
use cosmic::applet::button_theme;
use cosmic::iced;
use crate::subscriptions::status_notifier_item::{Layout, StatusNotifierItem};
@ -167,7 +167,7 @@ fn row_button(content: Vec<cosmic::Element<Msg>>) -> cosmic::widget::Button<Msg,
.align_items(iced::Alignment::Center)
.width(iced::Length::Fill),
)
.style(applet_button_theme())
.style(button_theme())
.width(iced::Length::Fill)
.padding([8, 24])
}

View file

@ -6,5 +6,5 @@ mod window;
fn main() -> cosmic::iced::Result {
localize::localize();
cosmic::app::applet::run::<Window>(true, ())
cosmic::applet::run::<Window>(true, ())
}

View file

@ -3,14 +3,13 @@ use cosmic::app::Core;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::window::Id;
use cosmic::iced::{Command, Length, Limits, Subscription};
use cosmic::iced_runtime::core::window;
use cosmic::iced_style::application;
use cosmic::iced_widget::row;
use cosmic::widget::{column, container, divider, spin_button, text};
use cosmic::{Element, Theme};
use cosmic_time::{anim, chain, id, Timeline};
use once_cell::sync::Lazy;
use std::time::Instant;
use cosmic::iced_widget::row;
const ID: &str = "com.system76.CosmicAppletTiling";
const ON: &str = "com.system76.CosmicAppletTiling.On";
@ -89,7 +88,7 @@ impl cosmic::Application for Window {
self.popup.replace(new_id);
let mut popup_settings =
self.core
.applet_helper
.applet
.get_popup_settings(Id(0), new_id, None, None, None);
popup_settings.positioner.size_limits = Limits::NONE
.max_width(372.0)
@ -127,7 +126,7 @@ impl cosmic::Application for Window {
fn view(&self) -> Element<Self::Message> {
self.core
.applet_helper
.applet
.icon_button(OFF)
.on_press(Message::TogglePopup)
.into()
@ -184,15 +183,18 @@ impl cosmic::Application for Window {
)
.padding([0, 12]),
)
.push(row!(
text(fl!("gaps")).size(14).width(Length::Fill),
spin_button(self.gaps.value.to_string(), Message::HandleGaps),
).padding([0, 10, 0, 10]));
.push(
row!(
text(fl!("gaps")).size(14).width(Length::Fill),
spin_button(self.gaps.value.to_string(), Message::HandleGaps),
)
.padding([0, 10, 0, 10]),
);
self.core.applet_helper.popup_container(content_list).into()
self.core.applet.popup_container(content_list).into()
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
}

View file

@ -1,12 +1,11 @@
use cosmic::app::{self, applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::{
time,
widget::{button, column, text, vertical_space},
widget::{column, text, vertical_space},
window, Alignment, Length, Rectangle, Subscription,
};
use cosmic::iced_style::application;
use cosmic::theme;
use cosmic::{app, applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::{
widget::{icon, rectangle_tracker::*},
Element, Theme,
@ -16,7 +15,7 @@ use chrono::{DateTime, Local, Timelike};
use std::time::Duration;
pub fn main() -> cosmic::iced::Result {
cosmic::app::applet::run::<Time>(true, ())
cosmic::applet::run::<Time>(true, ())
}
struct Time {
@ -51,7 +50,10 @@ impl cosmic::Application for Time {
type Flags = ();
const APP_ID: &'static str = "com.system76.CosmicAppletTime";
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, app::Command<Message>) {
fn init(
core: app::Core,
_flags: Self::Flags,
) -> (Self, cosmic::iced::Command<app::Message<Self::Message>>) {
(
Time {
core,
@ -76,7 +78,7 @@ impl cosmic::Application for Time {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn subscription(&self) -> Subscription<Message> {
@ -103,7 +105,10 @@ impl cosmic::Application for Time {
])
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> cosmic::iced::Command<app::Message<Self::Message>> {
match message {
Message::TogglePopup => {
if let Some(p) = self.popup.take() {
@ -127,7 +132,7 @@ impl cosmic::Application for Time {
let new_id = window::Id(self.id_ctr);
self.popup.replace(new_id);
let mut popup_settings = self.core.applet_helper.get_popup_settings(
let mut popup_settings = self.core.applet.get_popup_settings(
window::Id(0),
new_id,
None,
@ -174,16 +179,18 @@ impl cosmic::Application for Time {
}
fn view(&self) -> Element<Message> {
let button = button(
let button = cosmic::widget::button(
if matches!(
self.core.applet_helper.anchor,
self.core.applet.anchor,
PanelAnchor::Top | PanelAnchor::Bottom
) {
column![cosmic::widget::text(self.now.format("%b %-d %-I:%M %p").to_string()).size(14)]
column![
cosmic::widget::text(self.now.format("%b %-d %-I:%M %p").to_string()).size(14)
]
} else {
let mut date_time_col = column![
icon::from_name("emoji-recent-symbolic")
.size(self.core.applet_helper.suggested_size().0)
.size(self.core.applet.suggested_size().0)
.symbolic(true),
text(self.now.format("%I").to_string()).size(14),
text(self.now.format("%M").to_string()).size(14),
@ -191,7 +198,7 @@ impl cosmic::Application for Time {
vertical_space(Length::Fixed(4.0)),
// TODO better calendar icon?
icon::from_name("calendar-go-today-symbolic")
.size(self.core.applet_helper.suggested_size().0)
.size(self.core.applet.suggested_size().0)
.symbolic(true),
]
.align_items(Alignment::Center)
@ -203,7 +210,7 @@ impl cosmic::Application for Time {
},
)
.on_press(Message::TogglePopup)
.style(theme::iced::Button::Text);
.style(cosmic::theme::Button::Standard);
if let Some(tracker) = self.rectangle_tracker.as_ref() {
tracker.container(0, button).into()
@ -220,7 +227,7 @@ impl cosmic::Application for Time {
.push(text(&self.msg).size(14))
.padding(8);
self.core.applet_helper.popup_container(content).into()
self.core.applet.popup_container(content).into()
}
fn on_close_requested(&self, id: window::Id) -> Option<Message> {

View file

@ -1,10 +1,10 @@
use cctk::sctk::reexports::{calloop::channel::SyncSender, client::backend::ObjectId};
use cosmic::app::{applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::iced::alignment::{Horizontal, Vertical};
use cosmic::iced::mouse::{self, ScrollDelta};
use cosmic::iced::widget::{column, container, row, text};
use cosmic::iced::{subscription, widget::button, Event::Mouse, Length, Subscription};
use cosmic::iced_style::application;
use cosmic::{applet::cosmic_panel_config::PanelAnchor, Command};
use cosmic::{Element, Theme};
use cosmic_protocols::workspace::v1::client::zcosmic_workspace_handle_v1;
@ -15,7 +15,7 @@ use crate::wayland::{WorkspaceEvent, WorkspaceList};
use crate::wayland_subscription::{workspaces, WorkspacesUpdate};
pub fn run() -> cosmic::iced::Result {
cosmic::app::applet::run::<IcedWorkspacesApplet>(true, ())
cosmic::applet::run::<IcedWorkspacesApplet>(true, ())
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -45,10 +45,16 @@ impl cosmic::Application for IcedWorkspacesApplet {
type Flags = ();
const APP_ID: &'static str = config::APP_ID;
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, Command<Message>) {
fn init(
core: cosmic::app::Core,
_flags: Self::Flags,
) -> (
Self,
cosmic::iced::Command<cosmic::app::Message<Self::Message>>,
) {
(
IcedWorkspacesApplet {
layout: match &core.applet_helper.anchor {
layout: match &core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => Layout::Column,
PanelAnchor::Top | PanelAnchor::Bottom => Layout::Row,
},
@ -68,7 +74,10 @@ impl cosmic::Application for IcedWorkspacesApplet {
&mut self.core
}
fn update(&mut self, message: Message) -> Command<Message> {
fn update(
&mut self,
message: Self::Message,
) -> cosmic::iced::Command<cosmic::app::Message<Self::Message>> {
match message {
Message::WorkspaceUpdate(msg) => match msg {
WorkspacesUpdate::Workspaces(mut list) => {
@ -125,10 +134,10 @@ impl cosmic::Application for IcedWorkspacesApplet {
.height(Length::Fill),
)
.width(Length::Fixed(
self.core.applet_helper.suggested_size().0 as f32 + 16.0,
self.core.applet.suggested_size().0 as f32 + 16.0,
))
.height(Length::Fixed(
self.core.applet_helper.suggested_size().0 as f32 + 16.0,
self.core.applet.suggested_size().0 as f32 + 16.0,
))
.on_press(Message::WorkspacePressed(w.2.clone()))
.padding(0);
@ -183,6 +192,6 @@ impl cosmic::Application for IcedWorkspacesApplet {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
}

View file

@ -39,7 +39,7 @@ impl cosmic::Application for Button {
}
fn style(&self) -> Option<<Theme as application::StyleSheet>::Style> {
Some(cosmic::app::applet::style())
Some(cosmic::applet::style())
}
fn update(&mut self, message: Msg) -> app::Command<Msg> {
@ -89,5 +89,5 @@ pub fn main() -> iced::Result {
let desktop = desktop.expect(&format!(
"Failed to find valid desktop file '{filename}' in search paths"
));
cosmic::app::applet::run::<Button>(true, desktop)
cosmic::applet::run::<Button>(true, desktop)
}