Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,057 changes: 1,741 additions & 1,316 deletions Cargo.lock

Large diffs are not rendered by default.

64 changes: 40 additions & 24 deletions iced_zbus_notification/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,41 @@ pub struct LaLaMako<T: From<NotifyMessage> + Send> {
capabilities: Vec<String>,
sender: Box<dyn MessageSender<T> + Send + Sync>,
version: VersionInfo,
notify_check: Box<dyn FnMut(u32) -> bool + Send + Sync>,
}

impl<T: From<NotifyMessage> + Send + 'static> LaLaMako<T> {
pub fn new<MsgSender>(
sender: MsgSender,
capabilities: Vec<String>,
version: VersionInfo,
) -> Self
where
MsgSender: MessageSender<T> + 'static + Send + Sync,
{
Self {
sender: Box::new(sender),
capabilities,
version,
notify_check: Box::new(|_| true),
}
}

/// check if the id is already existed in current state
/// If result is true, then the replaced_id will be keeped
/// If the result is no, we will use the new id
pub fn with_check(mut self, check: impl FnMut(u32) -> bool + Send + Sync + 'static) -> Self {
self.notify_check = Box::new(check);
self
}

pub async fn connect(self) -> Result<zbus::Connection, zbus::Error> {
connection::Builder::session()?
.name("org.freedesktop.Notifications")?
.serve_at("/org/freedesktop/Notifications", self)?
.build()
.await
}
}

#[interface(name = "org.freedesktop.Notifications")]
Expand Down Expand Up @@ -338,7 +373,11 @@ impl<T: From<NotifyMessage> + Send + 'static> LaLaMako<T> {
let id = if replaced_id == 0 {
Id::unique()
} else {
Id(replaced_id)
if (self.notify_check)(replaced_id) {
Id(replaced_id)
} else {
Id::unique()
}
};
let mut image_data: Option<ImageData> =
hints.remove("image-data").and_then(|v| v.try_into().ok());
Expand Down Expand Up @@ -417,26 +456,3 @@ pub const NOTIFICATION_CLOSED: &str = "notification_closed";

/// default action name
pub const DEFAULT_ACTION: &str = "default";

/// start a connection
pub async fn start_connection<
T: From<NotifyMessage> + Send + 'static,
MsgSender: MessageSender<T> + 'static + Send + Sync,
>(
sender: MsgSender,
capabilities: Vec<String>,
version: VersionInfo,
) -> Result<zbus::Connection, zbus::Error> {
connection::Builder::session()?
.name("org.freedesktop.Notifications")?
.serve_at(
"/org/freedesktop/Notifications",
LaLaMako {
sender: Box::new(sender),
capabilities,
version,
},
)?
.build()
.await
}
18 changes: 10 additions & 8 deletions lala_bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = { version = "0.13.1", features = [
iced = { features = [
"tokio",
"debug",
"image",
"advanced",
"svg",
"markdown",
] }
iced_runtime = "0.13.2"
tokio = { version = "1.47", features = ["full"] }
iced_layershell = "0.13.7"
iced_futures = "0.13.2"
], version = "0.14.0" }

iced_layershell = "0.14.0-beta3"

iced_runtime = "0.14.0"
tokio = { version = "1.45", features = ["full"] }
iced_futures = "0.14.0"
env_logger = "0.11.6"
tracing = "0.1.41"

Expand All @@ -48,5 +50,5 @@ futures.workspace = true
iced_zbus_notification.workspace = true
chrono = "0.4.39"
async-trait.workspace = true
iced_aw = "0.12.0"
iced_fonts = "0.2.1"
iced_aw = "0.13"
open = "5.3.2"
12 changes: 7 additions & 5 deletions lala_bar/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ use super::Message;

use std::sync::LazyLock;

static SCROLLABLE_ID: LazyLock<scrollable::Id> = LazyLock::new(scrollable::Id::unique);
pub static INPUT_ID: LazyLock<text_input::Id> = LazyLock::new(text_input::Id::unique);
use iced::widget::operation::focus;

static SCROLLABLE_ID: LazyLock<iced::widget::Id> = LazyLock::new(iced::widget::Id::unique);
pub static INPUT_ID: LazyLock<iced::widget::Id> = LazyLock::new(iced::widget::Id::unique);

pub struct Launcher {
text: String,
Expand Down Expand Up @@ -39,7 +41,7 @@ impl Launcher {
}

pub fn focus_input(&self) -> Command<super::Message> {
text_input::focus(INPUT_ID.clone())
focus(INPUT_ID.clone())
}

pub fn update(&mut self, message: LaunchMessage, id: iced::window::Id) -> Command<Message> {
Expand Down Expand Up @@ -120,12 +122,12 @@ impl Launcher {
_ => {}
}
}
text_input::focus(INPUT_ID.clone())
focus(INPUT_ID.clone())
}
}
}

pub fn view(&self) -> Element<Message> {
pub fn view(&'_ self) -> Element<'_, Message> {
let re = regex::Regex::new(&self.text).ok();
let text_ip: Element<Message> = text_input("put the launcher name", &self.text)
.padding(10)
Expand Down
6 changes: 3 additions & 3 deletions lala_bar/src/launcher/applications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ pub struct App {
impl App {
pub fn launch(&self) {
if let Err(err) = self.appinfo.launch(&[], AppLaunchContext::NONE) {
println!("{}", err);
println!("{err}");
};
}

pub fn title(&self) -> &str {
&self.name
}

fn icon(&self) -> Element<Message> {
fn icon(&self) -> Element<'_, Message> {
match &self.icon {
Some(path) => {
if path
Expand Down Expand Up @@ -69,7 +69,7 @@ impl App {
}
}

pub fn view(&self, index: usize, selected: bool) -> Element<Message> {
pub fn view(&'_ self, index: usize, selected: bool) -> Element<'_, Message> {
button(
row![
self.icon(),
Expand Down
8 changes: 6 additions & 2 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use crate::music_bar::LalaMusicBar;
use crate::notify::NotifyCommand;
use notify::NotifyUnitWidgetInfo;

pub fn main() -> Result<(), iced_layershell::Error> {
#[tokio::main]
async fn main() -> Result<(), iced_layershell::Error> {
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::fmt::time::LocalTime;
tracing_subscriber::fmt()
Expand Down Expand Up @@ -76,14 +77,17 @@ pub enum Message {
QuiteMode(bool),
CloseErrorNotification(iced::window::Id),
Ready(Sender<NotifyCommand>),
ReadyCheck(Sender<bool>),
CheckId(u32),
#[allow(unused)]
LinkClicked(markdown::Url),
LinkClicked(markdown::Uri),
ToggleCalendar,
CancelDate,
SubmitDate(Date),
ToggleTime,
CancelTime,
SubmitTime(Time),
WindowClosed(iced::window::Id),
}

impl From<NotifyMessage> for Message {
Expand Down
Loading