[fractal] notify: Use GBytesIcon
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] notify: Use GBytesIcon
- Date: Tue, 14 May 2019 06:59:52 +0000 (UTC)
commit af742af0ba480aa710a5b3fbc472da494015b324
Author: Christopher Davis <brainblasted disroot org>
Date: Thu May 9 14:21:05 2019 -0400
notify: Use GBytesIcon
Previously we sent a GFileIcon for notifications, but the
flatpak portal does not support GFileIcon (https://github.com/flatpak/xdg-desktop-portal/issues/317).
Because of this notifications from the flatpak were
being dropped.
Now we create a GBytesIcon by loading a GFile and reading
the bytes, and set that as the icon for notifications.
Closes https://gitlab.gnome.org/GNOME/fractal/issues/490
fractal-gtk/Cargo.toml | 5 ++++-
fractal-gtk/src/appop/notify.rs | 11 +++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/fractal-gtk/Cargo.toml b/fractal-gtk/Cargo.toml
index 2fec22a8..7c4f0987 100644
--- a/fractal-gtk/Cargo.toml
+++ b/fractal-gtk/Cargo.toml
@@ -16,7 +16,6 @@ gdk = "0.9.0"
gdk-pixbuf = "0.5.0"
gdk-pixbuf-sys = "0.7.0"
gstreamer-editing-services = "0.12.2"
-gio = "0.5.1"
glib = "0.6.1"
itertools = "0.8.0"
lazy_static = "1.2.0"
@@ -72,3 +71,7 @@ features = ["v3_22"]
[dependencies.serde]
version = "1.0.82"
features = ["derive"]
+
+[dependencies.gio]
+version = "0.5.1"
+features = ["v2_56"]
diff --git a/fractal-gtk/src/appop/notify.rs b/fractal-gtk/src/appop/notify.rs
index ceec8b5c..82f61a1e 100644
--- a/fractal-gtk/src/appop/notify.rs
+++ b/fractal-gtk/src/appop/notify.rs
@@ -1,8 +1,10 @@
use gio::ApplicationExt;
+use gio::FileExt;
use gio::Notification;
use gio::NotificationExt;
use gtk;
use gtk::prelude::*;
+use log::info;
use std::sync::mpsc::channel;
use std::sync::mpsc::TryRecvError;
use std::sync::mpsc::{Receiver, Sender};
@@ -87,8 +89,13 @@ fn create_notification(room_id: &str, title: &str, body: &str, avatar: &str) ->
let notification = Notification::new(title);
notification.set_body(body);
notification.set_priority(gio::NotificationPriority::High);
- let avatar = gio::FileIcon::new(&gio::File::new_for_path(avatar));
- notification.set_icon(&avatar);
+ info!("Creating notification with avatar: {}", avatar);
+ let cancellable: Option<&gio::Cancellable> = None;
+ let file = gio::File::new_for_path(avatar);
+ let _ = file.load_bytes(cancellable).map(|(b, _)| {
+ let avatar = gio::BytesIcon::new(&b);
+ notification.set_icon(&avatar);
+ });
let data = glib::Variant::from(room_id);
notification.set_default_action_and_target_value("app.open-room", Some(&data));
notification
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]