Skip to content

Commit c6dd730

Browse files
wash2mmstick
authored andcommitted
fix(input sources): button size
1 parent 5ae7a29 commit c6dd730

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

cosmic-applet-input-sources/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ pub fn run() -> cosmic::iced::Result {
6363
config,
6464
layouts,
6565
};
66-
cosmic::applet::run::<Window>(true, flags)
66+
cosmic::applet::run::<Window>(false, flags)
6767
}

cosmic-applet-input-sources/src/window.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use cosmic::app::Core;
88
use cosmic::applet::{self};
99
use cosmic::cosmic_config::{self, ConfigSet};
1010
use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
11+
use cosmic::iced::widget::{column, row};
1112
use cosmic::iced::window::Id;
1213
#[allow(unused_imports)]
1314
use cosmic::iced::{alignment, Alignment, Length};
@@ -16,7 +17,7 @@ use cosmic::iced_futures::Subscription;
1617
use cosmic::iced_runtime::core::window;
1718
use cosmic::iced_style::application;
1819
use cosmic::prelude::*;
19-
use cosmic::widget;
20+
use cosmic::widget::{self, horizontal_space, vertical_space};
2021
use cosmic_comp_config::CosmicCompConfig;
2122
use xkb_data::KeyboardLayouts;
2223

@@ -161,17 +162,37 @@ impl cosmic::Application for Window {
161162
}
162163

163164
fn view(&self) -> Element<Self::Message> {
164-
let suggested = self.core.applet.suggested_padding(true);
165-
widget::button(
166-
self.core.applet.text(
167-
self.active_layouts
168-
.first()
169-
.map_or(String::new(), |l| l.layout.clone()),
170-
),
165+
let input_source_text = self.core.applet.text(
166+
self.active_layouts
167+
.first()
168+
.map_or(String::new(), |l| l.layout.clone()),
169+
);
170+
171+
cosmic::widget::button(
172+
row!(
173+
column!(
174+
input_source_text,
175+
horizontal_space(Length::Fixed(
176+
(self.core.applet.suggested_size(true).0
177+
+ 2 * self.core.applet.suggested_padding(true))
178+
as f32
179+
))
180+
)
181+
.width(Length::Shrink)
182+
.height(Length::Shrink)
183+
.align_items(Alignment::Center),
184+
vertical_space(Length::Fixed(
185+
(self.core.applet.suggested_size(true).1
186+
+ 2 * self.core.applet.suggested_padding(true)) as f32
187+
))
188+
)
189+
.align_items(Alignment::Center)
190+
.width(Length::Shrink)
191+
.height(Length::Shrink),
171192
)
172-
.style(cosmic::theme::Button::AppletIcon)
173-
.padding([suggested / 2, suggested])
174193
.on_press(Message::TogglePopup)
194+
.padding(self.core.applet.suggested_padding(true))
195+
.style(cosmic::theme::Button::AppletIcon)
175196
.into()
176197
}
177198

0 commit comments

Comments
 (0)