From 4488bcc9711bd085f2d54b242c428cd03f1bd958 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Thu, 15 Dec 2022 15:18:48 -0500 Subject: [PATCH] fix: initialize window size & add some popup padding --- applets/cosmic-app-list/src/app.rs | 46 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/applets/cosmic-app-list/src/app.rs b/applets/cosmic-app-list/src/app.rs index ad967fc7..5f8af8d2 100644 --- a/applets/cosmic-app-list/src/app.rs +++ b/applets/cosmic-app-list/src/app.rs @@ -19,6 +19,7 @@ use cosmic::iced::wayland::SurfaceIdWrapper; use cosmic::iced::widget::event_container; use cosmic::iced::widget::{column, row}; use cosmic::iced::{executor, window, Application, Command, Subscription}; +use cosmic::iced_native::alignment::Horizontal; use cosmic::iced_native::subscription::events_with; use cosmic::iced_style::application::{self, Appearance}; use cosmic::iced_style::Color; @@ -108,7 +109,7 @@ enum Message { Ignore, NewSeat(WlSeat), RemovedSeat(WlSeat), - Rectangle((RectangleUpdate)), + Rectangle(RectangleUpdate), } #[derive(Debug, Clone, Default)] @@ -167,25 +168,28 @@ impl Application for CosmicAppList { fn new(_flags: ()) -> (Self, Command) { let config = config::AppListConfig::load().unwrap_or_default(); let mut toplevel_ctr = 0; + let self_ = CosmicAppList { + toplevel_list: desktop_info_for_app_ids(config.favorites.clone()) + .into_iter() + .map(|e| { + toplevel_ctr += 1; + Toplevel { + id: toplevel_ctr, + toplevels: Default::default(), + desktop_info: e, + popup: None, + } + }) + .collect(), + config, + toplevel_ctr, + ..Default::default() + }; + let (w, h) = self_.window_size(); + ( - CosmicAppList { - toplevel_list: desktop_info_for_app_ids(config.favorites.clone()) - .into_iter() - .map(|e| { - toplevel_ctr += 1; - Toplevel { - id: toplevel_ctr, - toplevels: Default::default(), - desktop_info: e, - popup: None, - } - }) - .collect(), - config, - toplevel_ctr, - ..Default::default() - }, - Command::none(), + self_, + resize_window(window::Id::new(0), w, h), ) } @@ -507,12 +511,12 @@ impl Application for CosmicAppList { || self.config.favorites.contains(&desktop_info.name); let mut content = column![ - iced::widget::text(&desktop_info.name), + iced::widget::text(&desktop_info.name).horizontal_alignment(Horizontal::Center), cosmic::widget::button(Button::Text) .custom(vec![iced::widget::text(fl!("new-window")).into()]) .on_press(Message::Exec(desktop_info.exec.clone())), ] - .padding(4) + .padding(8) .spacing(4) .align_items(Alignment::Center); if !toplevels.is_empty() {