Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MalpenZibo committed Jan 10, 2025
1 parent 3c1369c commit c1b35f7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub fn menu_wrapper(
.height(Length::Shrink)
.width(Length::Shrink)
.max_width(menu_size.size())
.padding(16)
.style(|theme: &Theme| Style {
background: Some(theme.palette().background.into()),
border: Border {
Expand Down
1 change: 0 additions & 1 deletion src/modules/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ impl Settings {
.push_maybe(self.brightness.as_ref().map(|b| b.brightness_slider()))
.push(quick_settings)
.spacing(16)
.padding(16)
.into()
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/modules/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum TrayMessage {
Event(ServiceEvent<TrayService>),
OpenMenu(Id, String, ButtonUIRef),
ToggleSubmenu(i32),
MenuClick(String, i32),
MenuSelected(String, i32),
}

#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -73,11 +73,11 @@ impl TrayModule {
}
Task::none()
}
TrayMessage::MenuClick(name, id) => {
TrayMessage::MenuSelected(name, id) => {
if let Some(service) = self.service.as_mut() {
debug!("Tray menu click: {}", id);
service
.command(TrayCommand::MenuClick(name, id))
.command(TrayCommand::MenuSelected(name, id))
.map(|event| crate::app::Message::Tray(TrayMessage::Event(event)))
} else {
Task::none()
Expand Down Expand Up @@ -130,7 +130,6 @@ impl TrayModule {
{
Column::with_children(item.menu.2.iter().map(|menu| self.menu_voice(name, menu)))
.spacing(8)
.padding(16)
.into()
} else {
Row::new().into()
Expand All @@ -150,7 +149,7 @@ impl TrayModule {
let name = name.to_owned();
let id = layout.0;

move |_| TrayMessage::MenuClick(name.to_owned(), id)
move |_| TrayMessage::MenuSelected(name.to_owned(), id)
})
.width(Length::Fill)
.into(),
Expand Down Expand Up @@ -196,7 +195,7 @@ impl TrayModule {
label: Some(label), ..
} => button(text(label.replace("_", "")))
.style(GhostButtonStyle.into_style())
.on_press(TrayMessage::MenuClick(name.to_owned(), layout.0))
.on_press(TrayMessage::MenuSelected(name.to_owned(), layout.0))
.width(Length::Fill)
.padding([8, 8])
.into(),
Expand Down
1 change: 0 additions & 1 deletion src/modules/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ impl Updates {
.width(Length::Fill),
)
.spacing(4)
.padding(16)
.into()
}

Expand Down
1 change: 0 additions & 1 deletion src/services/network/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ impl<'a> NetworkDbus<'a> {
let mut scan_changed = wireless_device.receive_last_scan_changed().await;
if let Some(t) = scan_changed.next().await {
if let Ok(-1) = t.get().await {
eprintln!("scan errored");
return Ok(Default::default());
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/services/tray/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,13 @@ pub trait StatusNotifierItem {
#[zbus(property)]
fn icon_name(&self) -> zbus::Result<String>;

// https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/Icons
#[zbus(property)]
fn icon_pixmap(&self) -> zbus::Result<Vec<Icon>>;

#[zbus(property)]
fn menu(&self) -> zbus::Result<OwnedObjectPath>;
}

// type Layout = (u32, (i32, HashMap<String, OwnedValue>, Vec<OwnedValue>));

#[derive(Clone, Debug, Type)]
#[zvariant(signature = "(ia{sv}av)")]
pub struct Layout(pub i32, pub LayoutProps, pub Vec<Layout>);
Expand Down
13 changes: 8 additions & 5 deletions src/services/tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl TrayService {
menu_layout_change.push(layout_updated.filter_map({
let name = name.clone();
let menu_proxy = item.menu_proxy.clone();
println!("menu layout changed");
debug!("menu layout changed");
move |_| {
let name = name.clone();
let menu_proxy = menu_proxy.clone();
Expand Down Expand Up @@ -307,7 +307,10 @@ impl TrayService {
}
}

async fn click_menu_voice(menu_proxy: &DBusMenuProxy<'_>, id: i32) -> anyhow::Result<Layout> {
async fn menu_voice_selected(
menu_proxy: &DBusMenuProxy<'_>,
id: i32,
) -> anyhow::Result<Layout> {
let value = zbus::zvariant::Value::I32(32).try_to_owned()?;
menu_proxy
.event(
Expand Down Expand Up @@ -377,15 +380,15 @@ impl ReadOnlyService for TrayService {

#[derive(Debug, Clone)]
pub enum TrayCommand {
MenuClick(String, i32),
MenuSelected(String, i32),
}

impl Service for TrayService {
type Command = TrayCommand;

fn command(&mut self, command: Self::Command) -> Task<ServiceEvent<Self>> {
match command {
TrayCommand::MenuClick(name, id) => {
TrayCommand::MenuSelected(name, id) => {
let menu = self.data.iter().find(|item| item.name == name);
if let Some(menu) = menu {
let name_cb = name.clone();
Expand All @@ -395,7 +398,7 @@ impl Service for TrayService {

async move {
debug!("Click tray menu voice {} : {}", name, id);
TrayService::click_menu_voice(&proxy, id).await
TrayService::menu_voice_selected(&proxy, id).await
}
},
move |new_layout| {
Expand Down

0 comments on commit c1b35f7

Please sign in to comment.