diff --git a/Cargo.toml b/Cargo.toml index 861ce45..ca0b740 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ chrono = "0.4.40" serde_default = "0.2.0" socks = "0.3.4" libnotify = { version = "1.0.3", optional = true } -gdk-pixbuf = "0.3.0" +gdk-pixbuf = { version = "0.3.0", optional = true } [features] default = ["libnotify"] -libnotify = ["dep:libnotify"] +libnotify = ["dep:libnotify", "dep:gdk-pixbuf"] diff --git a/src/chat/gui.rs b/src/chat/gui.rs index 05d2e67..d8ef55b 100644 --- a/src/chat/gui.rs +++ b/src/chat/gui.rs @@ -1,4 +1,4 @@ -use std::{sync::{mpsc::{channel, Receiver}, Arc, RwLock}, time::UNIX_EPOCH}; +use std::sync::{mpsc::{channel, Receiver}, Arc, RwLock}; use std::cell::RefCell; use std::time::{Duration, SystemTime}; use std::thread; @@ -32,7 +32,7 @@ ctx::Context, on_send_message, parse_message, print_message, recv_tick, sanitize struct UiModel { chat_box: GtkBox, chat_scrolled: ScrolledWindow, - app: Application, + // app: Application, window: ApplicationWindow, #[cfg(feature = "libnotify")] notifications: Arc>> @@ -57,13 +57,6 @@ fn load_pixbuf(data: &[u8]) -> Pixbuf { loader.pixbuf().unwrap() } -fn load_gdk_pixbuf(data: &[u8]) -> gdk_pixbuf::Pixbuf { - let loader = gdk_pixbuf::PixbufLoader::new(); - loader.loader_write(data).unwrap(); - loader.close().unwrap(); - loader.get_pixbuf().unwrap() -} - macro_rules! gui_entry_setting { ($e:expr, $i:ident, $ctx:ident, $vbox:ident) => { { @@ -596,14 +589,14 @@ fn build_ui(ctx: Arc, app: &Application) -> UiModel { UiModel { chat_scrolled, chat_box, - app: app.clone(), + // app: app.clone(), window: window.clone(), #[cfg(feature = "libnotify")] notifications: Arc::new(RwLock::new(Vec::::new())) } } -fn setup(app: &Application, ctx: Arc, ui: UiModel) { +fn setup(_: &Application, ctx: Arc, ui: UiModel) { let (sender, receiver) = channel(); *ctx.sender.write().unwrap() = Some(Arc::new(sender)); @@ -686,7 +679,10 @@ fn send_notification(_: Arc, ui: &UiModel, title: &str, message: &str) let notification = Notification::new(title, message, None); notification.set_app_name("bRAC"); - notification.set_image_from_pixbuf(&load_gdk_pixbuf(include_bytes!("images/icon.png"))); + let pixbuf_loader = gdk_pixbuf::PixbufLoader::new(); + pixbuf_loader.loader_write(include_bytes!("images/icon.png")).unwrap(); + pixbuf_loader.close().unwrap(); + notification.set_image_from_pixbuf(&pixbuf_loader.get_pixbuf().unwrap()); notification.show().expect("libnotify send error"); ui.notifications.write().unwrap().push(notification);