mycitadel/model/
ui.rs

1// MyCitadel desktop wallet: bitcoin & RGB wallet based on GTK framework.
2//
3// Written in 2022 by
4//     Dr. Maxim Orlovsky <orlovsky@pandoraprime.ch>
5//
6// Copyright (C) 2022 by Pandora Prime SA, Switzerland.
7//
8// This software is distributed without any warranty. You should have received
9// a copy of the AGPL-3.0 License along with this software. If not, see
10// <https://www.gnu.org/licenses/agpl-3.0-standalone.html>.
11
12use bpro::HistoryEntry;
13use gtk::{gdk, MessageType};
14
15#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
16pub struct Notification {
17    pub msg: String,
18    pub ty: MessageType,
19}
20
21pub trait UI {
22    fn color(&self) -> gdk::RGBA;
23}
24
25impl UI for HistoryEntry {
26    fn color(&self) -> gdk::RGBA {
27        match self.balance() {
28            x if x > 0 => gdk::RGBA::new(38.0 / 256.0, 162.0 / 256.0, 105.0 / 256.0, 1.0),
29            x if x < 0 => gdk::RGBA::new(165.0 / 256.0, 29.0 / 256.0, 45.0 / 256.0, 1.0),
30            0 => gdk::RGBA::new(119.0 / 256.0, 118.0 / 256.0, 123.0 / 256.0, 1.0),
31            _ => unreachable!(),
32        }
33    }
34}