app.rs: Add an action for showing error notification.

This commit is contained in:
Jordan Petridis 2018-05-16 17:30:43 +03:00
parent 7035fe05c4
commit 118dac5a1a
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use gtk::SettingsExt as GtkSettingsExt;
use hammond_data::Podcast; use hammond_data::Podcast;
use appnotif::{InAppNotification, UndoState};
use headerbar::Header; use headerbar::Header;
use settings::{self, WindowGeometry}; use settings::{self, WindowGeometry};
use stacks::{Content, PopulatedState}; use stacks::{Content, PopulatedState};
@ -18,7 +19,8 @@ use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc; use std::sync::Arc;
#[derive(Clone, Debug)] #[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum Action { pub enum Action {
RefreshAllViews, RefreshAllViews,
RefreshEpisodesView, RefreshEpisodesView,
@ -34,6 +36,7 @@ pub enum Action {
HeaderBarHideUpdateIndicator, HeaderBarHideUpdateIndicator,
MarkAllPlayerNotification(Arc<Podcast>), MarkAllPlayerNotification(Arc<Podcast>),
RemoveShow(Arc<Podcast>), RemoveShow(Arc<Podcast>),
ErrorNotification(String),
} }
#[derive(Debug)] #[derive(Debug)]
@ -200,6 +203,15 @@ impl App {
let notif = remove_show_notif(pd, sender.clone()); let notif = remove_show_notif(pd, sender.clone());
notif.show(&overlay); notif.show(&overlay);
} }
Ok(Action::ErrorNotification(err)) => {
error!("An error notification was triggered: {}", err);
// FIXME: this is not good user-facing messages.
// should match on the error type and return a proper description of the Error.
let text = &err;
let callback = || glib::Continue(false);
let notif = InAppNotification::new(text, callback, || {}, UndoState::Hidden);
notif.show(&overlay);
}
Err(_) => (), Err(_) => (),
} }

View File

@ -5,7 +5,6 @@ use gtk::prelude::*;
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
#[allow(dead_code)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum UndoState { pub enum UndoState {
Shown, Shown,