Skip to content

Commit

Permalink
chore: nearly finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Aug 10, 2024
1 parent ee8d2ce commit b32fb38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
37 changes: 29 additions & 8 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,35 @@ impl MultiApplication for LalaMusicBar {
}
}
LaLaInfo::Notify(notify) => {
let btnwidgets: Element<Message> = button(column![
text(notify.summery.clone()).shaping(text::Shaping::Advanced),
text(notify.body.clone()).shaping(text::Shaping::Advanced)
])
.width(Length::Fill)
.height(Length::Fill)
.on_press(Message::RemoveNotify(id))
.into();
let btnwidgets: Element<Message> =
if let Some((width, height, pixels)) = notify.hint.image_data() {
button(row![
image(image::Handle::from_pixels(
width as u32,
height as u32,
pixels
)),
Space::with_width(4.),
column![
text(notify.summery.clone()).shaping(text::Shaping::Advanced),
text(notify.body.clone()).shaping(text::Shaping::Advanced)
]
])
.width(Length::Fill)
.height(Length::Fill)
.on_press(Message::RemoveNotify(id))
.into()
} else {
button(column![
text(notify.summery.clone()).shaping(text::Shaping::Advanced),
text(notify.body.clone()).shaping(text::Shaping::Advanced)
])
.width(Length::Fill)
.height(Length::Fill)
.on_press(Message::RemoveNotify(id))
.into()
};

let notifywidget = self.notifications.get(&id).unwrap();
if notify.inline_reply_support() {
return column![
Expand Down
11 changes: 9 additions & 2 deletions notification_iced/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//!
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
use serde::{Deserialize, Serialize};
use zbus::{interface, object_server::SignalContext, zvariant::OwnedValue};

use futures::{channel::mpsc::Sender, never::Never};
Expand Down Expand Up @@ -54,7 +53,15 @@ pub enum NotifyMessage {

#[derive(Debug, Clone)]
pub struct NotifyHint {
pub image_data: Option<ImageData>,
image_data: Option<ImageData>,
}

impl NotifyHint {
pub fn image_data(&self) -> Option<(i32, i32, Vec<u8>)> {
self.image_data
.as_ref()
.map(|data| (data.width, data.height, data.data.clone()))
}
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit b32fb38

Please sign in to comment.